physics_lt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // This interface implements physics functionality.
  2. #ifndef __PHYSICS_LT_H__
  3. #define __PHYSICS_LT_H__
  4. // Sets the dims as large as it can by testing to see what's around the object.
  5. // The object will get touch notifications if it hits anything while resizing.
  6. #define SETDIMS_PUSHOBJECTS (1<<0)
  7. // Teleport the object to its destination.
  8. #define MOVEOBJECT_TELEPORT (1<<0)
  9. class MoveInfo
  10. {
  11. public:
  12. HOBJECT m_hObject;
  13. float m_dt;
  14. DVector m_Offset;
  15. };
  16. class PhysicsLT
  17. {
  18. public:
  19. // Get/Set friction coefficient.
  20. virtual DRESULT GetFrictionCoefficient(HOBJECT hObj, float &coeff);
  21. virtual DRESULT SetFrictionCoefficient(HOBJECT hObj, float coeff);
  22. // Get/set force ignore limit.
  23. virtual DRESULT GetForceIgnoreLimit(HOBJECT hObj, float &limit);
  24. virtual DRESULT SetForceIgnoreLimit(HOBJECT hObj, float limit);
  25. // Get/Set acceleration and velocity
  26. virtual DRESULT GetVelocity(HOBJECT hObj, DVector *pVel);
  27. virtual DRESULT SetVelocity(HOBJECT hObj, DVector *pVel)=0;
  28. virtual DRESULT GetAcceleration(HOBJECT hObj, DVector *pAccel);
  29. virtual DRESULT SetAcceleration(HOBJECT hObj, DVector *pAccel)=0;
  30. // Get/Set an object's mass (default is 30).
  31. virtual DRESULT GetObjectMass(HOBJECT hObj, float &mass);
  32. virtual DRESULT SetObjectMass(HOBJECT hObj, float mass);
  33. // Get the object's current dimensions.
  34. virtual DRESULT GetObjectDims(HOBJECT hObj, DVector *pNewDims);
  35. // Changes the object's dimensions without pushing against objects and world.
  36. // Flags is a combination of SETDIMS_ flags above.
  37. virtual DRESULT SetObjectDims(HOBJECT hObj, DVector *pNewDims, DDWORD flags)=0;
  38. // This function moves an object, colliding/pushing/crushing objects
  39. // in its way (if it's solid..) Flags is a combination of MOVEOBJECT_ flags.
  40. virtual DRESULT MoveObject(HOBJECT hObj, DVector *pPos, DDWORD flags)=0;
  41. // Find out what the object is standing on.
  42. virtual DRESULT GetStandingOn(HOBJECT hObj, CollisionInfo *pInfo);
  43. // Get the world object.
  44. virtual DRESULT GetWorldObject(HOBJECT *hObj)=0;
  45. // Get/set global force. This is an acceleration applied to all objects
  46. // when they move. Default is (0,-2000,0) which simulates gravity.
  47. virtual DRESULT GetGlobalForce(DVector &vec)=0;
  48. virtual DRESULT SetGlobalForce(DVector &vec)=0;
  49. protected:
  50. ClientServerType m_ClientServerType; // Tells if this is on the client or server.
  51. };
  52. // Client-specific physics stuff.
  53. class CPhysicsLT : public PhysicsLT
  54. {
  55. public:
  56. // Updates the object's movement using its velocity, acceleration, and the
  57. // time delta passed in (usually the frame time). Fills in m_Offset with the
  58. // position delta you should apply.
  59. virtual DRESULT UpdateMovement(MoveInfo *pInfo)=0;
  60. // Move the specified object but only test for collisions/pushing on
  61. // the objects specified. It'll carry things standing on it.
  62. virtual DRESULT MovePushObjects(HOBJECT hToMove, DVector &newPos,
  63. HOBJECT *hPushObjects, DDWORD nPushObjects)=0;
  64. // Rotate the specified object but only test for collisions/pushing on
  65. // the objects specified. It'll carry things standing on it.
  66. // This only works on world models.
  67. virtual DRESULT RotatePushObjects(HOBJECT hToMove, DRotation &newRot,
  68. HOBJECT *hPushObjects, DDWORD nPushObjects)=0;
  69. };
  70. #endif