1
edit
Changes
→RigidBody
=== RigidBody ===
<pre>#include "iRigidBody.h"</pre>
A RigidBody provides access to a physics object's state in the world at any given point in time. Each RigidBody instance holds its physics properties in an RBDynamics struct. In order to access a RigidBody instance's properties, the method <code>getDynamics()</code> is called on the instance. This method returns a reference to an RBDynamics struct. Let's look at the interface:
<pre>
class iRigidBody {
public:
// initialization functions
virtual iRigidBody* clone() const = 0;
virtual void attach(iFrame* o) = 0;
virtual void attachListener(iCollisionListener* l) = 0;
virtual void detachListener(const iCollisionListener* l)= 0;
virtual void restore(int now) = 0;
// execution functions
virtual std::vector<iCollisionListener*>& getListeners()= 0;
virtual iFrame* getFrame () = 0;
virtual RBDynamics& getDynamics() = 0;
virtual const RBDynamics& getDynamics() const = 0;
virtual void setDynamics(const RBDynamics& d) = 0;
// termination functions
virtual void reset(int now) = 0;
virtual void suspend() const = 0;
virtual void release() const = 0;
virtual void Delete() const = 0;
};
extern "C"
iRigidBody* CreateRigidBody(iFrame* o);
</pre>
Aside from the usual suspects, a few functions are of particular importance:
<pre>
virtual void attach(iFrame* o) = 0;
virtual void attachListener(iCollisionListener* l) = 0;
virtual RBDynamics& getDynamics() = 0;
virtual void Delete() const = 0;
</pre>
; iRigidBody* CreateRigidBody(iFrame* o) : Creates a RigidBody and associates it with the active PhysicsScene coordinator. This function accepts an <code>iFrame* o</code> parameter. This parameter can be NULL if desired but should usually be the address of a valid iFrame.
The passed iFrame will be bound to this RigidBody. Every frame, PhysicsScene will update the frame's homogenous transformation matrix (T) to follow the location and rotation of the RigidBody. This is done at the end of the physics update step.
; virtual void attach(iFrame* o) :
== Integrating Framework Into Existing Projects ==