Go to the documentation of this file.00001 #ifndef MASS_H
00002 #define MASS_H
00003 #include <ngl/Vector.h>
00004 #include "Cloth.h"
00005 #include <ngl/Transformation.h>
00006 #include <ngl/TransformStack.h>
00007 #include <ngl/Colour.h>
00008 #include "HashTableData.h"
00009
00010 class Integrator;
00011 class Cloth;
00012
00019
00023
00024
00025 class Mass
00026 {
00027 private:
00029 Cloth* m_cloth;
00031 ngl::Vector position;
00033 ngl::Vector m_normal;
00035 ngl::Vector oldPosition;
00037 ngl::Vector oldVelocity;
00039 ngl::Vector velocity;
00041 ngl::Vector acceleration;
00043 float mass;
00045 ngl::Vector externalForces;
00047 ngl::Vector force;
00049 ngl::Vector stiffenessVector;
00051 ngl::Colour m_colour;
00053 float m_radius;
00055 bool fixed;
00057 float DAMPING;
00059 float TIME_STEPSIZE;
00060
00062
00063 float m_t;
00064
00065
00066
00067 public:
00068
00069
00070 Mass(ngl::Vector _position, float _mass, float m_radius, ngl::Colour m_colour, ngl::TransformStack *_transform, Cloth* _cloth);
00071 inline Mass(ngl::Vector _pos,
00072 ngl::Vector _vel
00073 ) : position(_pos), velocity(_vel){;}
00074
00076
00077 inline Mass(){;}
00078 virtual ~Mass();
00079
00080 inline ngl::Vector getNormal() const {return m_normal;}
00081 inline void addNormal(const ngl::Vector& normal) {m_normal += normal;}
00082 inline void setNormal(const ngl::Vector& normal) {m_normal = normal;}
00083
00086 void SetSizeOfMasses(int _radius) {m_radius = _radius;}
00087
00090 void setTimeStep(float _timeStep) {TIME_STEPSIZE = _timeStep;}
00091
00092
00095 void setStiffenessVector(ngl::Vector _stiffenessVector) {stiffenessVector = _stiffenessVector;}
00096
00099 void setOldPosition(ngl::Vector _oldPosition) {oldPosition = _oldPosition;}
00100
00103 void setOldVelocity(ngl::Vector _oldVelocity) {oldVelocity = _oldVelocity;}
00104
00106 bool isFixed() {return fixed;}
00107
00109 float getTimeStep() {return TIME_STEPSIZE;}
00110
00113 void setDamping(float _damping) {DAMPING = _damping;}
00114
00116 float getDamping() {return DAMPING;}
00117
00119 ngl::Vector getStiffenessVector() {return stiffenessVector;}
00120
00121
00124 void SetColour(ngl::Colour _colour) {m_colour = _colour;}
00125
00128 void setForce(ngl::Vector _force) {force = _force;}
00129
00132 void setExternaForces(ngl::Vector _externalForces) {externalForces = _externalForces;}
00133
00136 void addExternaForce(ngl::Vector _externalForce) {externalForces += _externalForce;}
00137
00140 void setVelocity(ngl::Vector _velocity) {velocity = _velocity;}
00141
00143 ngl::Vector getForce() {return force;}
00144
00146 ngl::Vector getPosition() {return position;}
00147
00149 ngl::Vector getVelocity() {return velocity;}
00150
00152 ngl::Vector getOldPosition() {return oldPosition;}
00153
00155 ngl::Vector getOldVelocity() {return oldVelocity;}
00156
00158 float getMass() {return mass;}
00159
00162 void setPosition(ngl::Vector _position) {position = _position;}
00163
00166 void setMass(float _mass) {mass = _mass;}
00167
00169 ngl::Vector normal;
00170 void calculateAcceleration(ngl::Vector force);
00171 bool isEuler;
00172
00174 void update();
00175
00177 void updateMass();
00178
00180 void draw();
00181
00182 void offsetPosition(const ngl::Vector velocity);
00183
00185 void makeFixed();
00186
00188 void makeFree();
00189
00191 void addForce(ngl::Vector force);
00192
00193 ngl::Vector getNormal() { return normal;}
00195 unsigned int vertexIndex;
00196
00198 std::vector<HashTableData> m_neighbours;
00199
00200 ngl::Vector BBMin, BBMax;
00201
00203 ngl::Vector m_correctedVelocities;
00204
00206 unsigned int m_velNumber;
00207
00208
00209 protected:
00210
00212 ngl::TransformStack *m_transform;
00213 private:
00215 void VerletIntegration();
00216
00218 void ExplicitEulerIntegration();
00219
00220 };
00221
00222 #endif // MASS_H