What is IPhysics?

  • IPhysics is a set of interface classes for easily integrating Newton and Irrlicht.
  • No dependancies or new vector types - everything uses Irrlicht types like vector3df, so the integration is seamless.
  • Really easy to use - all the important things that you need to get started are already there, like terrain support and vehicles.
  • Simple and powerful interface - to create any kind of entity, from a simple cube to a driveable car, you simply need to fill out a struct and pass it to IPhysics.
  • Clean interface - you only have access to the functions that you need.

Basic Design

The basic design of the IPhysics interface is:

  • To create an entity, you fill out a struct of the type you want, and pass it to IPhysics.
  • The entity pointer you are returned then provides functionality for using the entity afterwards.

For example...

// in code somewhere

// default constructor creates a 10x10x10 cube
ISceneNode *cubeNode = smgr->addCubeSceneNode();

cubeNode->setMaterialFlag(EMF_LIGHTING, false);

SPhysicsCube cube;

cube.bodyType = EBT_DYNAMIC; // dynamic body - affected by gravity
cube.node = cubeNode; // scenenode that we just created
cube.size_x = 10.0f;
cube.size_y = 10.0f;
cube.size_z = 10.0f;
cube.mass = 20.f;

IPhysicsEntity *myEntity = physics->addEntity(&cube); // create entity
myEntity->setPosition(vector3df(10, 20, 30)); // now we can move it somewhere

And that's it! Look at the examples to see how to use all the different features.

Including IPhysics in your project

  • In your IDE, add the directories /include under include files and /lib under library files, for example:
    c:/somewhere/in/your/hd/IPhysics/include
    c:/somewhere/in/your/hd/IPhysics/lib
  • Then in your project, you just need to include IPhysics.h
    #include <IPhysics.h>