//--------------------------------------------------------------------------------- // Overidding TA::DynamicObject::Update exmaple. //--------------------------------------------------------------------------------- #include "TA/Physics/DynamicObject.h" //--------------------------------------------------------------------------------- // Class SuperDynamicObject inherits from TA::DynamicObject //--------------------------------------------------------------------------------- class SuperDynamicObject : public TA::DynamicObject { public: // Initialisation / finalisation //. //. //. // Update function void Update(float fDt); }; //--------------------------------------------------------------------------------- // Example overriden the update function. //--------------------------------------------------------------------------------- void SuperDynamicObject::Update(float fDt) { // Note, the prefix TA::DynamicObject:: is not necessary when calling the // functions bellow. It is just being done so that the help generator used to // create this documentation can recognise them. TA::Vec3 v3Force(10.0f, 0.0f, 0.0f); // Make sure that force and torque have been cleared. TA::DynamicObject::AssertForceAndTorqueCleared(); // Do gravity TA::DynamicObject::AccumulateGravity(); // Apply a force to the dynamic object TA::DynamicObject::AccumulateForceAndTorque( v3Force, // Force. GetCenterOfMass()); // Position to apply the force // Apply the forces to linear and angular velocity TA::DynamicObject::ApplyForceAndTorqueToVelocities(fDt); // Clear force and torque TA::DynamicObject::ClearForceAndTorque(); // Note: // The above could be more simply be acheived with the line // ApplyImpulse(k_v3Gravity * fDt, GetCenterOfMass()) // The intention, however, was do demonstrate the force and torque functions. // Update date the next frame of the dynamic object, ready for collision testing. TA::DynamicObject::ApplyVelocityToNextFrame(fDt); // ApplyNextFrame will be called to by Update automatically after the // collision response has been done. }