virtual void RigidBodyControllerCallback(neRigidBodyController * controller) {};
virtual void JointControllerCallback(neJointController * controller) {};
These two classes, along with neRigidBodyController and neJointController, provide the application an interface to periodically control neRigidBody and neJoint.
The following steps illustrate how to use neRigidBodyControllerCallback.
1) The application derives its own neRigidBodyControllerCallback class, with its own implementation of the RigidBodyControllerCallback method
class MyRigidBodyControllerCallback : public
neRigidBodyControllerCallback
{
public:
virtual void
RigidBodyControllerCallback(neRigidBodyController
* controller)
{
// controller code goes here.
controller->SetControllerForce(...);
};
};
2) The application creates a neRigidBody object, and adds the controller callback to it by calling
MyRigidBodyControllerCallback callbackInstance;
rb->AddController(&callbackInstance, 0); // period of 0 meaning once per timestep.
3) Periodically (in this case, once per simulation time step), the simulator object will call the callbackInstance::RigidBodyControllerCallback function.
4) To apply force and torque to the rigid body during the callback, use the parameter neRigidBodyController * controller.