pygame / include / pgBodyObject.h

Full commit

#include "pgVector2.h"

typedef struct _pgWorldObject pgWorldObject;
typedef struct _pgShapeObject pgShapeObject;

typedef struct _pgBodyObject{

	double		fMass;
	pgVector2	vecLinearVelocity;
	double		fAngleVelocity;

	pgVector2	vecPosition;
	double		fRotation;
	pgVector2	vecImpulse;
	pgVector2	vecForce;
	double		fTorque;

	double		fRestitution;
	double		fFriction;

	pgShapeObject* shape;

} pgBodyObject;

pgBodyObject* PG_BodyNew();
void	PG_BodyDestroy(pgBodyObject* body);

void PG_FreeUpdateBodyVel(pgWorldObject* world, pgBodyObject* body, double dt);
void PG_FreeUpdateBodyPos(pgWorldObject* world, pgBodyObject* body, double dt);

//transform point local_p's position from body's local coordinate to the world's global one.
//TODO: is the local coordinate necessary? anyway let it alone right now.
pgVector2 PG_GetGlobalPos(pgBodyObject* body, pgVector2* local_p);

//return the global velocity of a point p (on the rigid body)
//(notice: here p is defined in the global coordinate)
pgVector2 PG_GetVelocity(pgBodyObject* body, pgVector2* global_p);

pgVector2 PG_GetVelocity1(pgVector2 r, double w);

//return p_in_A
pgVector2 PG_GetRelativePos(pgBodyObject* bodyA, pgBodyObject* bodyB, pgVector2* p_in_B);