Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00043 #ifndef _orxPHYSICS_H_
00044 #define _orxPHYSICS_H_
00045
00046
00047 #include "orxInclude.h"
00048 #include "plugin/orxPluginCore.h"
00049 #include "math/orxAABox.h"
00050
00051
00054 #define orxBODY_DEF_KU32_FLAG_NONE 0x00000000
00056 #define orxBODY_DEF_KU32_FLAG_2D 0x00000001
00057 #define orxBODY_DEF_KU32_FLAG_DYNAMIC 0x00000002
00058 #define orxBODY_DEF_KU32_FLAG_HIGH_SPEED 0x00000004
00059 #define orxBODY_DEF_KU32_FLAG_FIXED_ROTATION 0x00000008
00060 #define orxBODY_DEF_KU32_FLAG_CAN_SLIDE 0x00000010
00061 #define orxBODY_DEF_KU32_FLAG_CAN_MOVE 0x00000020
00062 #define orxBODY_DEF_KU32_FLAG_ALLOW_SLEEP 0x00000040
00064 #define orxBODY_DEF_KU32_MASK_ALL 0xFFFFFFFF
00068 #define orxBODY_PART_DEF_KU32_FLAG_NONE 0x00000000
00070 #define orxBODY_PART_DEF_KU32_FLAG_SPHERE 0x00000001
00071 #define orxBODY_PART_DEF_KU32_FLAG_BOX 0x00000002
00072 #define orxBODY_PART_DEF_KU32_FLAG_MESH 0x00000004
00074 #define orxBODY_PART_DEF_KU32_MASK_TYPE 0x00000007
00076 #define orxBODY_PART_DEF_KU32_FLAG_SOLID 0x10000000
00078 #define orxBODY_PART_DEF_KU32_MASK_ALL 0xFFFFFFFF
00082 #define orxBODY_JOINT_DEF_KU32_FLAG_NONE 0x00000000
00084 #define orxBODY_JOINT_DEF_KU32_FLAG_REVOLUTE 0x00000001
00085 #define orxBODY_JOINT_DEF_KU32_FLAG_PRISMATIC 0x00000002
00086 #define orxBODY_JOINT_DEF_KU32_FLAG_SPRING 0x00000004
00087 #define orxBODY_JOINT_DEF_KU32_FLAG_ROPE 0x00000008
00088 #define orxBODY_JOINT_DEF_KU32_FLAG_PULLEY 0x00000010
00089 #define orxBODY_JOINT_DEF_KU32_FLAG_SUSPENSION 0x00000020
00090 #define orxBODY_JOINT_DEF_KU32_FLAG_WELD 0x00000040
00091 #define orxBODY_JOINT_DEF_KU32_FLAG_FRICTION 0x00000080
00092 #define orxBODY_JOINT_DEF_KU32_FLAG_GEAR 0x00000100
00094 #define orxBODY_JOINT_DEF_KU32_MASK_TYPE 0x000000FF
00096 #define orxBODY_JOINT_DEF_KU32_FLAG_COLLIDE 0x10000000
00097 #define orxBODY_JOINT_DEF_KU32_FLAG_ROTATION_LIMIT 0x20000000
00098 #define orxBODY_JOINT_DEF_KU32_FLAG_MOTOR 0x40000000
00099 #define orxBODY_JOINT_DEF_KU32_FLAG_TRANSLATION_LIMIT 0x80000000
00101 #define orxBODY_JOINT_DEF_KU32_MASK_ALL 0xFFFFFFFF
00106 #define orxBODY_PART_DEF_KU32_MESH_VERTEX_NUMBER 8
00107
00108
00111 typedef struct __orxBODY_DEF_t
00112 {
00113 orxVECTOR vPosition;
00114 orxFLOAT fRotation;
00115 orxFLOAT fInertia;
00116 orxFLOAT fMass;
00117 orxFLOAT fLinearDamping;
00118 orxFLOAT fAngularDamping;
00119 orxU32 u32Flags;
00121 } orxBODY_DEF;
00122
00125 typedef struct __orxBODY_PART_DEF_t
00126 {
00127 orxVECTOR vScale;
00128 orxFLOAT fFriction;
00129 orxFLOAT fRestitution;
00130 orxFLOAT fDensity;
00131 orxU16 u16SelfFlags;
00132 orxU16 u16CheckMask;
00133 orxU32 u32Flags;
00135 union
00136 {
00137 struct
00138 {
00139 orxVECTOR vCenter;
00140 orxFLOAT fRadius;
00141 } stSphere;
00143 struct
00144 {
00145 orxAABOX stBox;
00146 } stAABox;
00148 struct
00149 {
00150 orxU32 u32VertexCounter;
00151 orxVECTOR avVertices[orxBODY_PART_DEF_KU32_MESH_VERTEX_NUMBER];
00153 } stMesh;
00154
00155 };
00157 } orxBODY_PART_DEF;
00158
00161 typedef struct __orxBODY_JOINT_DEF_t
00162 {
00163 orxVECTOR vSrcScale;
00164 orxVECTOR vDstScale;
00165 orxVECTOR vSrcAnchor;
00166 orxVECTOR vDstAnchor;
00167 orxU32 u32Flags;
00169 union
00170 {
00171 struct
00172 {
00173 orxFLOAT fDefaultRotation;
00174 orxFLOAT fMinRotation;
00175 orxFLOAT fMaxRotation;
00176 orxFLOAT fMotorSpeed;
00177 orxFLOAT fMaxMotorTorque;
00179 } stRevolute;
00181 struct
00182 {
00183 orxFLOAT fDefaultRotation;
00184 orxVECTOR vTranslationAxis;
00185 orxFLOAT fMinTranslation;
00186 orxFLOAT fMaxTranslation;
00187 orxFLOAT fMotorSpeed;
00188 orxFLOAT fMaxMotorForce;
00190 } stPrismatic;
00192 struct
00193 {
00194 orxFLOAT fLength;
00195 orxFLOAT fFrequency;
00196 orxFLOAT fDamping;
00198 } stSpring;
00200 struct
00201 {
00202 orxFLOAT fLength;
00204 } stRope;
00206 struct
00207 {
00208 orxFLOAT fLengthRatio;
00209 orxVECTOR vSrcGroundAnchor;
00210 orxVECTOR vDstGroundAnchor;
00211 orxFLOAT fSrcLength;
00212 orxFLOAT fMaxSrcLength;
00213 orxFLOAT fDstLength;
00214 orxFLOAT fMaxDstLength;
00216 } stPulley;
00218 struct
00219 {
00220 orxVECTOR vTranslationAxis;
00221 orxFLOAT fMinTranslation;
00222 orxFLOAT fMaxTranslation;
00223 orxFLOAT fMotorSpeed;
00224 orxFLOAT fMaxMotorForce;
00226 } stSuspension;
00228 struct
00229 {
00230 orxFLOAT fDefaultRotation;
00232 } stWeld;
00234 struct
00235 {
00236 orxFLOAT fMaxForce;
00237 orxFLOAT fMaxTorque;
00239 } stFriction;
00241 struct
00242 {
00243 const orxSTRING zSrcJointName;
00244 const orxSTRING zDstJointName;
00245 orxFLOAT fJointRatio;
00247 } stGear;
00249 };
00251 } orxBODY_JOINT_DEF;
00252
00253
00256 typedef enum __orxPHYSICS_EVENT_t
00257 {
00258 orxPHYSICS_EVENT_CONTACT_ADD = 0,
00259 orxPHYSICS_EVENT_CONTACT_REMOVE,
00260
00261 orxPHYSICS_EVENT_NUMBER,
00262
00263 orxPHYSICS_EVENT_NONE = orxENUM_NONE
00264
00265 } orxPHYSICS_EVENT;
00266
00269 typedef struct __orxPHYSICS_EVENT_PAYLOAD_t
00270 {
00271 orxVECTOR vPosition;
00272 orxVECTOR vNormal;
00273 const orxSTRING zSenderPartName;
00274 const orxSTRING zRecipientPartName;
00276 } orxPHYSICS_EVENT_PAYLOAD;
00277
00280 typedef struct __orxPHYSICS_BODY_t orxPHYSICS_BODY;
00281
00284 typedef struct __orxPHYSICS_BODY_PART_t orxPHYSICS_BODY_PART;
00285
00288 typedef struct __orxPHYSICS_BODY_JOINT_t orxPHYSICS_BODY_JOINT;
00289
00290
00293 #define orxPHYSICS_KZ_CONFIG_SECTION "Physics"
00294 #define orxPHYSICS_KZ_CONFIG_GRAVITY "Gravity"
00295 #define orxPHYSICS_KZ_CONFIG_ALLOW_SLEEP "AllowSleep"
00296 #define orxPHYSICS_KZ_CONFIG_ITERATIONS "IterationsPerStep"
00297 #define orxPHYSICS_KZ_CONFIG_FREQUENCY "SimulationFrequency"
00298 #define orxPHYSICS_KZ_CONFIG_RATIO "DimensionRatio"
00299 #define orxPHYSICS_KZ_CONFIG_FIXED_DT "FixedDT"
00300
00301
00302
00303
00304
00305
00308 extern orxDLLAPI void orxFASTCALL orxPhysics_Setup();
00309
00310
00311
00312
00313
00314
00318 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_Init();
00319
00322 extern orxDLLAPI void orxFASTCALL orxPhysics_Exit();
00323
00324
00329 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetGravity(const orxVECTOR *_pvGravity);
00330
00335 extern orxDLLAPI orxVECTOR *orxFASTCALL orxPhysics_GetGravity(orxVECTOR *_pvGravity);
00336
00337
00343 extern orxDLLAPI orxPHYSICS_BODY *orxFASTCALL orxPhysics_CreateBody(const orxHANDLE _hUserData, const orxBODY_DEF *_pstBodyDef);
00344
00348 extern orxDLLAPI void orxFASTCALL orxPhysics_DeleteBody(orxPHYSICS_BODY *_pstBody);
00349
00356 extern orxDLLAPI orxPHYSICS_BODY_PART *orxFASTCALL orxPhysics_CreateBodyPart(orxPHYSICS_BODY *_pstBody, const orxHANDLE _hUserData, const orxBODY_PART_DEF *_pstBodyPartDef);
00357
00361 extern orxDLLAPI void orxFASTCALL orxPhysics_DeleteBodyPart(orxPHYSICS_BODY_PART *_pstBodyPart);
00362
00363
00371 extern orxDLLAPI orxPHYSICS_BODY_JOINT *orxFASTCALL orxPhysics_CreateBodyJoint(orxPHYSICS_BODY *_pstSrcBody, orxPHYSICS_BODY *_pstDstBody, const orxHANDLE _hUserData, const orxBODY_JOINT_DEF *_pstBodyJointDef);
00372
00376 extern orxDLLAPI void orxFASTCALL orxPhysics_DeleteBodyJoint(orxPHYSICS_BODY_JOINT *_pstBodyJoint);
00377
00378
00384 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetPosition(orxPHYSICS_BODY *_pstBody, const orxVECTOR *_pvPosition);
00385
00391 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetRotation(orxPHYSICS_BODY *_pstBody, orxFLOAT _fRotation);
00392
00398 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetSpeed(orxPHYSICS_BODY *_pstBody, const orxVECTOR *_pvSpeed);
00399
00405 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetAngularVelocity(orxPHYSICS_BODY *_pstBody, orxFLOAT _fVelocity);
00406
00412 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetCustomGravity(orxPHYSICS_BODY *_pstBody, const orxVECTOR *_pvCustomGravity);
00413
00419 extern orxDLLAPI orxVECTOR *orxFASTCALL orxPhysics_GetPosition(const orxPHYSICS_BODY *_pstBody, orxVECTOR *_pvPosition);
00420
00425 extern orxDLLAPI orxFLOAT orxFASTCALL orxPhysics_GetRotation(const orxPHYSICS_BODY *_pstBody);
00426
00432 extern orxDLLAPI orxVECTOR *orxFASTCALL orxPhysics_GetSpeed(const orxPHYSICS_BODY *_pstBody, orxVECTOR *_pvSpeed);
00433
00438 extern orxDLLAPI orxFLOAT orxFASTCALL orxPhysics_GetAngularVelocity(const orxPHYSICS_BODY *_pstBody);
00439
00445 extern orxDLLAPI orxVECTOR *orxFASTCALL orxPhysics_GetCustomGravity(const orxPHYSICS_BODY *_pstBody, orxVECTOR *_pvCustomGravity);
00446
00451 extern orxDLLAPI orxFLOAT orxFASTCALL orxPhysics_GetMass(const orxPHYSICS_BODY *_pstBody);
00452
00458 extern orxDLLAPI orxVECTOR *orxFASTCALL orxPhysics_GetMassCenter(const orxPHYSICS_BODY *_pstBody, orxVECTOR *_pvMassCenter);
00459
00460
00466 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetLinearDamping(orxPHYSICS_BODY *_pstBody, orxFLOAT _fDamping);
00467
00473 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetAngularDamping(orxPHYSICS_BODY *_pstBody, orxFLOAT _fDamping);
00474
00479 extern orxDLLAPI orxFLOAT orxFASTCALL orxPhysics_GetLinearDamping(const orxPHYSICS_BODY *_pstBody);
00480
00485 extern orxDLLAPI orxFLOAT orxFASTCALL orxPhysics_GetAngularDamping(const orxPHYSICS_BODY *_pstBody);
00486
00487
00493 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_ApplyTorque(orxPHYSICS_BODY *_pstBody, orxFLOAT _fTorque);
00494
00501 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_ApplyForce(orxPHYSICS_BODY *_pstBody, const orxVECTOR *_pvForce, const orxVECTOR *_pvPoint);
00502
00509 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_ApplyImpulse(orxPHYSICS_BODY *_pstBody, const orxVECTOR *_pvImpulse, const orxVECTOR *_pvPoint);
00510
00511
00517 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetSelfFlags(orxPHYSICS_BODY_PART *_pstBodyPart, orxU16 _u16SelfFlags);
00518
00524 extern orxDLLAPI orxSTATUS orxFASTCALL orxPhysics_SetCheckMask(orxPHYSICS_BODY_PART *_pstBodyPart, orxU16 _u16CheckMask);
00525
00530 extern orxDLLAPI orxU16 orxFASTCALL orxPhysics_GetSelfFlags(const orxPHYSICS_BODY_PART *_pstBodyPart);
00531
00536 extern orxDLLAPI orxU16 orxFASTCALL orxPhysics_GetCheckMask(const orxPHYSICS_BODY_PART *_pstBodyPart);
00537
00538
00549 extern orxDLLAPI orxHANDLE orxFASTCALL orxPhysics_Raycast(const orxVECTOR *_pvStart, const orxVECTOR *_pvEnd, orxU16 _u16SelfFlags, orxU16 _u16CheckMask, orxBOOL _bEarlyExit, orxVECTOR *_pvContact, orxVECTOR *_pvNormal);
00550
00551
00555 extern orxDLLAPI void orxFASTCALL orxPhysics_EnableSimulation(orxBOOL _bEnable);
00556
00557 #endif
00558