summaryrefslogtreecommitdiff
path: root/mass.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2010-08-18 14:38:34 +0000
committerIan C <ianc@noddybox.co.uk>2010-08-18 14:38:34 +0000
commit19bbd5822593c7198dd54eb0f5d38fa1ed8d8fb7 (patch)
tree97f7f8849c3a8282ba571a64ff2a655cdf5d41aa /mass.h
parent0d2f672482fee91a9642a7cb6eb01fcdded79159 (diff)
Reformatted code and altered the attraction rule to something a bit more
correct. Also added two tests to prove it works.
Diffstat (limited to 'mass.h')
-rw-r--r--mass.h188
1 files changed, 94 insertions, 94 deletions
diff --git a/mass.h b/mass.h
index 0b18071..9c58660 100644
--- a/mass.h
+++ b/mass.h
@@ -30,100 +30,100 @@
#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();
- };
+{
+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