Source

pygame / include / pgBodyObject.h

#ifndef _PYGAME_PHYSICS_BODY_
#define _PYGAME_PHYSICS_BODY_


#include "pgVector2.h"
#include "pgDeclare.h"

//! typedef struct _pgWorldObject pgWorldObject;
//! typedef struct _pgShapeObject pgShapeObject;

struct _pgBodyObject{
	PyObject_HEAD

	double		fMass;
	pgVector2	vecLinearVelocity;
	double		fAngleVelocity;
	int			bStatic;

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

	double		fRestitution;
	double		fFriction;

	pgShapeObject* shape;

};

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_AngleToLinear1(pgBodyObject* body, pgVector2* global_p);
pgVector2 PG_AngleToLinear(pgVector2* r, double w);

//translate vector from coordinate B to coordinate A
pgVector2 PG_GetRelativePos(pgBodyObject* bodyA, pgBodyObject* bodyB, pgVector2* p_in_B);


//bind rect shape with body
void PG_Bind_RectShape(pgBodyObject* body, double width, double height, double seta);

#endif //_PYGAME_PHYSICS_BODY_
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.