#include "config.h" #include "spring.h" class Joint { private: int index; int fixed; float dx,dy; float x,y; float t; float dt; Vector force; Vector velocity; Vector acceleration; Spring *springs[JOINT_MAX_SPRINGS]; int springwhich[JOINT_MAX_SPRINGS]; int springcount; class xTooManySprings {}; static float S_gravity; static float S_mass; static float S_world_width; friend class World; public: Joint(float nx, float ny) { x = nx; y = ny; t = 0; fixed = 0; index = 0; } Joint(float nx, float ny, int nf) { x = nx; y = ny; t = 0; fixed = nf; index = 0; } Joint(float nx, float ny, int nf, int i) { x = nx; y = ny; t = 0; fixed = nf; index = i; } Joint() { x=0; y=0; t=0; fixed=0; index=0; } float X() { return x; } float Y() { return y; } float DX() { return dx; } float DY() { return dy; } int Index() { return index; } void Fix(); void Unfix(); int IsFixed() { return fixed; } int Springs() { return springcount; } Spring *GetSpring(int i) { return springs[i]; } int SpringEnd(int i) { return springwhich[i]; } float SpringX(int i,int j) { return springs[i]->X(j); } float SpringY(int i,int j) { return springs[i]->Y(j); } void Translate() { if (!fixed) this->MoveTo(x+dx,y+dy); } void MoveTo(float nx, float ny); void OnTimeSlice(float ndt); void ApplyForce(float na, float nf); void ApplyForce(Vector F); void BounceY(); void BounceX(); //bool ConnectedTo(Joint *J); Spring *ConnectedTo(Joint *J); void ConnectSpring(Spring &s, int i); Spring* DisconnectSpring(int s); Spring* ConnectJoint(Joint &j); static float Gravity() { return S_gravity; } static float Gravity(float g) { return S_gravity = g; } static float Mass() { return S_mass; } static float Mass(float m) { return S_mass = m; } static float WorldWidth() { return S_world_width; } static float WorldWidth(float w) { return S_world_width = w; } };