Gangsta Wrapper        

Gangsta is a physics wrapper currently being developed by monster. Details of progress can be found at this thread.
An early version is available at this thread.

Gangsta currently is only available via SourceForge anonymous CVS. Check out the CVS version using the instructions on the Gangsta SF page ( The module names are "GangstaWrapper" and "Gangsta_Ogre".

Gangsta Wrapper follows the basic API of the typical physics library, so knowing how to use one of them is 90% of knowing how to use Gangsta. For example, reading the Novodex docs at goes a long way towards understanding most of how Gangsta works.

Integration with Ogre is another part of the Gangsta project. This is accomplished with the Gangsta_Ogre addon. This addon provides a class that implements Gangsta's physics simulation callback interface for the purpose of adjusting entity transforms in an Ogre scene graph.

Typical initialization of a Gangsta-enabled physics simulation can be understood by examining Sample_Common_Ogre.h in the Samples/Common directory in the Gangsta_Ogre project. For example,

#include <Gangsta.h>

Ga::GaPtr<Ga::PhysicsDriver> _driver = Ga::Manager::getInstance()->loadPhysicsDriver("ODE");
Ga::GaPtr<Ga::World> _world = _driver->createWorld("world1");

// "Ogre::SceneManager *sceneMgr" is initialized elsewhere
Ga::GaPtr<Ga::CallbackInterface_Ogre> _callback = new Ga::CallbackInterface_Ogre(sceneMgr);

The four currently supported physics drivers are "ODE" (demonstrated above), "Newton", "Novodex" and "TrueAxis". These are NOT provided by Gangsta and must be obtained and installed independently, and available at runtime (Gangsta does not have any compile-time dependencies on any physics libraries).

The Gangsta Ogre callback interface implementation is responsible for loading .mesh data and creating the relevant physics library mappings from it (vertices, etc). Currently, only physical .mesh file loading is supported (SceneManager::createEntity() is used in the implementation to load .mesh files into Ogre Entity objects). Model loading is done as follows (from Sample_Engines_Ogre.cpp, the file that does the box stacks in the forums article linked above):

Ga::ParameterList params;

// Create a box body
Ga::GaPtr<Ga::Body> body = Ga::GaPtr<Ga::Body>(_world->createBody("box","Gangsta_Crate.mesh"));

// note that the demo works with four engines, each using a box shaded with a material containing a decal
// that corresponds to the physics lib being used; the next line is how you would create one of the boxes with 
// the ODE logo on it            

// uniform mass distribution in all three directions
params["inertia_tensor"] = Ga::GaVec3(1,1,1);
// 1 mass unit (typically kg, depends on lib being used whether units or unitless)
params["mass"] = (Ga::GaFloat)1;


// arbitrary position values; keep in mind that this code came from a demo that creates four stacks
// of boxes distributed along a line
Ga::GaVec3 pos = Ga::GaVec3(-2.25,0.75,0);

// Create a box shape; this creates a "hitbox" or contact volume that represents the actual 
// geometry in the physics simulation. In a more complex environment you might use a trimesh or 
// a collection of shapes to represent your model or geometry.
Ga::GaPtr<Ga::Shape> shape = _world->createShape("box",body);
params["size"] = Ga::GaVec3(1,1,1);


Keep in mind that the mesh and material files referenced above depend on normal Ogre Resource location definitions (either in a resources.cfg or defined programmatically). The material used above comes with the Gangsta demos in the Samples/Media folder.

Also, Gangsta is not multithreaded by itself, even if the underlying physics library is (for example, Novodex). Therefore, Gangsta is not to be considered thread-safe.

This article is meant to be a very quick-and-dirty primer on getting going with Gangsta and Gangsta_Ogre. For more on reacting to collisions, applying forces and torques and setting up practical physical simulations, refer to the Gangsta Samples and to physics library documentation such as that which exists for Novodex.