IPhysics: CPhysics Class Reference

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# CPhysics Class Reference

`#include <CPhysics.h>`

Inherits IPhysicsWorld.

List of all members.

## Public Member Functions

| CPhysics ()
| Constructor.
| ~CPhysics ()
| Destructor.
void | init (IrrlichtDevice *dev)
void | doLog (bool doLog, bool doEcho, bool path)
void | update ()
void | update (f32 timestep_ms)
CMaterialManager * | getMaterialManager ()
void | debug (bool enable)
void | close ()
IPhysicsEntity * | addEntity (SPhysicsPrimitive *primitive)
IPhysicsEntity * | addEntity (IPhysicsBaseEntity *first,...)
IPhysicsEntity * | addEntity (SPhysicsTerrain *terrain)
IPhysicsEntity * | addEntity (SPhysicsStaticMesh *staticMesh)
IPhysicsEntity * | addEntity (SPhysicsMesh *mesh)
IPhysicsEntity * | addEntity (SPhysicsSerializedEntity *mesh)
CPhysicsCamera * | addCamera (SPhysicsCamera *camera)
CPhysicsHinge * | addHingeJoint (SPhysicsHingeJoint *joint)
CPhysicsBallSocket * | addBallSocketJoint (SPhysicsBallSocketJoint *joint)
CPhysicsSlider * | addSliderJoint (SPhysicsSliderJoint *joint)
CPhysicsCorkscrew * | addCorkscrewJoint (SPhysicsCorkscrewJoint *joint)
CPhysicsUniversal * | addUniversalJoint (SPhysicsUniversalJoint *joint)
CPhysicsUpVector * | addUpVectorJoint (SPhysicsUpVector *upVector)
CPhysicsPulley * | addPulley (SPhysicsPulley *pulley)
IPhysicsCar * | addCar (SPhysicsCar *car)
IPhysicsEntity * | throwTestCube (ICameraSceneNode *cam, f32 size, f32 mass, f32 velocity)
IPhysicsEntity * | throwTestCube (CPhysicsCamera *camEntity, f32 size, f32 mass, f32 velocity)
IPhysicsEntity * | throwTestCube (CPhysicsCamera *camEntity)
IPhysicsEntity * | throwTestSphere (ICameraSceneNode *cam, f32 size, f32 mass, f32 velocity)
IPhysicsEntity * | throwTestSphere (CPhysicsCamera *camEntity, f32 size, f32 mass, f32 velocity)
IPhysicsEntity * | throwTestSphere (CPhysicsCamera *camEntity)
void | setUpdateMode (PHYSICS_UPDATE_MODE updateMode)
void | setUpdatesPerSecond (s32 updatesPerSecond)

## Private Member Functions

IPhysicsEntity * | setUpRigidBody (NewtonBody *body, NewtonCollision *collision, SPhysicsAttributes *attributes)

## Static Private Member Functions

static void _cdecl | NewtonDebugBody (const NewtonBody *body)
static void _cdecl | NewtonDebugCollision (const NewtonBody *body, int vertexCount, const float *FaceArray, int id)
static void _cdecl | getFromFile (void *serializeHandle, void *buffer, size_t size)

## Private Attributes

list< IPhysicsBaseEntity * > | m_entityList
f32 | m_timestepAccumulator
ITimer * | m_timer
f32 | m_oldTime
PHYSICS_UPDATE_MODE | m_updateMode
s32 | m_updatesPerSecond
CLog * | m_log
CMaterialManager * | m_materialManager
CPhysicsCamera * | m_camEntity
bool | m_isCam
bool | m_showDebug

## Static Private Attributes

static IrrlichtDevice * | m_device

## Detailed Description

Root class. All functionality for IPhysics is accessed through this class.

## Constructor & Destructor Documentation

CPhysics::CPhysics | ( |  | ) |

Constructor.

CPhysics::~CPhysics | ( |  | ) |

Destructor.

## Member Function Documentation

void CPhysics::init | ( | IrrlichtDevice * | dev | ) |

Initialisation function. This should be called before anything else, as it initialises Newton. The ITimer* you pass should be the one from the Irrlicht device you are using - this allows IPhysics to update automatically.

void CPhysics::doLog | ( | bool | doLog,
|  | bool | doEcho,
|  | bool | path |
| ) |  |  |

void CPhysics::update | ( |  | ) |

The update function. This should be called every frame, regardless of which update mode you are using.

void CPhysics::update | ( | f32 | timestep_ms | ) |

The update function. This update function allows you to pass your own timestep. This is only intended for effects like slow-motion, if you want to control how fast time progresses, or else if you need to control how the timestep is calculated (for example, maybe you want to average the timesteps if your framerate varies a lot). If you just want IPhysics to run 'normally', use the simpler version which takes no arguments.

CMaterialManager * CPhysics::getMaterialManager | ( |  | ) |

void CPhysics::debug | ( | bool | enable | ) |

void CPhysics::close | ( |  | ) |

Cleanup function. Call this to close down IPhysics. It is important to call this, as IPhysics does use some dynamically allocated memory, and failing to call this would leave it inilialised and it will leak.

Reimplemented from IPhysicsWorld.

IPhysicsEntity * CPhysics::addEntity | ( | SPhysicsPrimitive * | primitive | ) |

Adds a Primitve Note that it is best to use primitives wherever you can, as they are much faster than using a convex hull.

IPhysicsEntity * CPhysics::addEntity | ( | IPhysicsBaseEntity * | first,
|  |  | ... |
| ) |  |  |

IPhysicsEntity * CPhysics::addEntity | ( | SPhysicsTerrain * | terrain | ) |

Adds terrain. This function now contains a call to set the terrainSceneNode's scale to the scale provided in the struct, so you don't need to. It is important though to ensure that the terrainScale is set - if you want the terrain at the original size, you still need to set the terrainScale to (1, 1, 1). If you don't, the terrain will be invisible (as the scale will be (0, 0, 0)).

IPhysicsEntity * CPhysics::addEntity | ( | SPhysicsStaticMesh * | staticMesh | ) |

Adds a static mesh. A static mesh is any arbitrary mesh that should never move when things collide with it, and that shouldn't be affected by gravity. Use this for things like rooms and levels. This supports all three Irrlicht vertex types, so lightmapped meshes and suchlike should all work fine.

IPhysicsEntity * CPhysics::addEntity | ( | SPhysicsMesh * | mesh | ) |

Adds a user Mesh This function will create a entity of a user created mesh.

IPhysicsEntity * CPhysics::addEntity | ( | SPhysicsSerializedEntity * | mesh | ) |

CPhysicsCamera * CPhysics::addCamera | ( | SPhysicsCamera * | camera | ) |

CPhysicsHinge * CPhysics::addHingeJoint | ( | SPhysicsHingeJoint * | joint | ) |

CPhysicsBallSocket * CPhysics::addBallSocketJoint | ( | SPhysicsBallSocketJoint * | joint | ) |

CPhysicsSlider * CPhysics::addSliderJoint | ( | SPhysicsSliderJoint * | joint | ) |

CPhysicsCorkscrew * CPhysics::addCorkscrewJoint | ( | SPhysicsCorkscrewJoint * | joint | ) |

CPhysicsUniversal * CPhysics::addUniversalJoint | ( | SPhysicsUniversalJoint * | joint | ) |

CPhysicsUpVector * CPhysics::addUpVectorJoint | ( | SPhysicsUpVector * | upVector | ) |

CPhysicsPulley * CPhysics::addPulley | ( | SPhysicsPulley * | pulley | ) |

IPhysicsCar * CPhysics::addCar | ( | SPhysicsCar * | car | ) |

Adds a car. Creates a car, based on the supplied data. Note that the car implementation is currently somewhat primitive; this will be extended in future versions.

IPhysicsEntity * CPhysics::throwTestCube | ( | ICameraSceneNode * | cam,
|  | f32 | size,
|  | f32 | mass,
|  | f32 | velocity |
| ) |  |  |

Drops a test sphere. As above but allows you to specify the size and mass. The size in this case refers to the diameter, so a size of 10.0f would create a sphere with diameter 10 (radius 5).

IPhysicsEntity * CPhysics::throwTestCube | ( | CPhysicsCamera * | camEntity,
|  | f32 | size,
|  | f32 | mass,
|  | f32 | velocity |
| ) |  |  |

Drops a test cube. This is for testing and debugging - a test cube is created using the built-in Irrlicht primitive and dropped from the specified position. The ISceneManager pointer should be the one from the IrrlichtDevice that you are using. The size of the cube will be 10*10*10 and the mass will be 10.

IPhysicsEntity * CPhysics::throwTestCube | ( | CPhysicsCamera * | camEntity | ) |

IPhysicsEntity * CPhysics::throwTestSphere | ( | ICameraSceneNode * | cam,
|  | f32 | size,
|  | f32 | mass,
|  | f32 | velocity |
| ) |  |  |

Drops a test sphere. As above but allows you to specify the size and mass. The size in this case refers to the diameter, so a size of 10.0f would create a sphere with diameter 10 (radius 5).

IPhysicsEntity * CPhysics::throwTestSphere | ( | CPhysicsCamera * | camEntity,
|  | f32 | size,
|  | f32 | mass,
|  | f32 | velocity |
| ) |  |  |

Drops a test sphere. This is for testing and debugging - a test sphere is created using the built-in Irrlicht primitive and dropped from the specified position. The ISceneManager pointer should be the one from the IrrlichtDevice that you are using. The size of the sphere (in this case the diameter) will be 10 and the mass will be 10.

IPhysicsEntity * CPhysics::throwTestSphere | ( | CPhysicsCamera * | camEntity | ) |

void CPhysics::setUpdateMode | ( | PHYSICS_UPDATE_MODE | updateMode | ) |

Sets the update mode. The update mode determines how Newton is updated. The current choices are UM_FIXED_FRAME_RATE, which ensures that Newton is kept at a constant framerate (default: 60), and UM_EVERY_FRAME, which updates Newton every frame using the correct timestep for the interval since. Both modes update dependant on time, not the frame rate of your application. UM_EVERY_FRAME is a little smoother, but a little more computationally expensive.

void CPhysics::setUpdatesPerSecond | ( | s32 | updatesPerSecond | ) |

Sets the number of updates per second. This value will only be used if the update mode is set to UM_FIXED_FRAME_RATE. The default value for this is 60.

IPhysicsEntity * CPhysics::setUpRigidBody | ( | NewtonBody * | body,
|  | NewtonCollision * | collision,
|  | SPhysicsAttributes * | attributes |
| ) |  |  | `[private]`

void CPhysics::NewtonDebugBody | ( | const NewtonBody * | body | ) | `[static, private]`

void CPhysics::NewtonDebugCollision | ( | const NewtonBody * | body,
|  | int | vertexCount,
|  | const float * | FaceArray,
|  | int | id |
| ) |  |  | `[static, private]`

void CPhysics::getFromFile | ( | void * | serializeHandle,
|  | void * | buffer,
|  | size_t | size |
| ) |  |  | `[static, private]`

## Member Data Documentation

list<IPhysicsBaseEntity*> CPhysics::m_entityList`[private]`

f32 CPhysics::m_timestepAccumulator`[private]`

ITimer* CPhysics::m_timer`[private]`

f32 CPhysics::m_oldTime`[private]`

PHYSICS_UPDATE_MODE CPhysics::m_updateMode`[private]`

s32 CPhysics::m_updatesPerSecond`[private]`

CLog* CPhysics::m_log`[private]`

CMaterialManager* CPhysics::m_materialManager`[private]`

CPhysicsCamera* CPhysics::m_camEntity`[private]`

bool CPhysics::m_isCam`[private]`

bool CPhysics::m_showDebug`[private]`

IrrlichtDevice * CPhysics::m_device`[static, private]`

Static object of irrlicht device. This is needed in static callbacks.

The documentation for this class was generated from the following files:

- C:/Documents and Settings/user/Desktop/IPhysics 1.5 Irr 1.2/source/CPhysics.h
- C:/Documents and Settings/user/Desktop/IPhysics 1.5 Irr 1.2/source/CPhysics.cpp