// // glgrav - OpenGL N-Body gravity simulator // // Copyright (C) 2003 Ian Cowburn (ianc@noddybox.demon.co.uk) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------- // // Mass // // $Id$ // #ifndef MASS_H #define MASS_H #include "global.h" class Mass { public: enum DrawItem {eMass, eRing}; Mass(); Mass(const string& name, double mass, double scale, double posx, double posy, double posz, double dx, double dy, double dz, GLfloat r, GLfloat g, GLfloat b, double rot, int sheild=0); virtual ~Mass(); // Define a ring // void setRing(double from, double to, GLfloat r, GLfloat g, GLfloat b, GLfloat alpha, double rot, double angle); // Set up an Open GL texture ID to use. It is assumed that // texturing is not used till this member is called. // // The get function returns true if a texture has been assigned. // void setTexture(GLuint id); bool getTexture(GLuint& id) const; void setRingTexture(GLuint id); bool getRingTexture(GLuint& id) const; // Get Mass information // string getName() const; double getMass() const; double getSize() const; void getPosition(double& x, double& y, double& z) const; void getPreviousPosition(double& x, double& y, double& z) const; void getDelta(double& dx, double& dy, double& dz) const; void getColour(GLfloat& r, GLfloat& g, GLfloat& b) const; bool isMassless() const; // All resetting of various controls for collisions // void reset(double mass, double dx, double dy, double dz); void reset(double mass); // Attract the object to the provided mass. Note that the supplied // mass is left unaltered. // // Returns true if the two objects have collided // bool calcAttraction(Mass& m, double gr_const); // Move the mass along it's delta // void move(); void draw(bool solid, bool texture, DrawItem item) const; // Streaming // friend ostream& operator<<(ostream& os, const Mass& m); private: string m_name; double m_size; double m_mass; double m_scale; double m_x,m_y,m_z; double m_prevx,m_prevy,m_prevz; double m_dx,m_dy,m_dz; GLfloat m_r,m_g,m_b; bool m_massless; double m_rot; double m_ang; int m_shield; bool m_textured; GLuint m_texture_id; bool m_ring; double m_ring_from,m_ring_to; double m_ring_rot,m_ring_ang,m_ring_tilt; GLfloat m_rr,m_rg,m_rb; GLfloat m_ring_alpha; bool m_ring_textured; GLuint m_ring_id; double calcDistance2(Mass& m, double& dx, double& dy, double& dz); void calcSize(); }; // Routine to find masses from a vector of them // bool findMass(vector& m, const string& name, Mass& ret); bool findMass(vector& m, const string& name, vector::size_type& index); #endif // END OF FILE //