00001
00002
00003
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TA_PHYSICSJOINT_H
00015 #define TA_PHYSICSJOINT_H
00016
00017 #ifndef TA_MATRIX_H
00018 #include "../Common/Matrix.h"
00019 #endif // TA_MATRIX_H
00020
00021 #ifndef TA_FLAGS_H
00022 #include "../Common/Flags.h"
00023 #endif // TA_FLAGS_H
00024
00025 #ifndef TA_EULERANLGE_H
00026 #include "../Common/EulerAngles.h"
00027 #endif // TA_EULERANLGE_H
00028
00029 #ifndef TA_PHYSICSCOMMON_H
00030 #include "PhysicsCommon.h"
00031 #endif // TA_PHYSICSCOMMON_H
00032
00033 TA_OBFUSCATION_SKIP_PASS_2
00034
00035 namespace TA
00036 {
00037
00038 class DynamicObject;
00039
00040 class TAPHYSICS_CLASS PhysicsJoint
00041 {
00042 public:
00043 TA_OBFUSCATION_RESERVED_ON
00044
00045 enum Type
00046 {
00047 TYPE_BALL_AND_SOCKET = 0,
00048 TYPE_LIMITED_BALL_AND_SOCKET = 1,
00049 TYPE_SQUARE_SOCKET = 2,
00050 TYPE_EULER_ANGLE_CONSTRAINT = 31,
00051 TYPE_LINEAR_SLIDER = 4,
00052 TYPE_ROTATION_CONSTRAINT = 5,
00053 TYPE_VECTOR_CONSTRAINT = 6,
00054 };
00055 PhysicsJoint();
00056 ~PhysicsJoint();
00057
00059
00060 void InitialiseEulerConstraint(
00061 const Vec3& v3Position,
00062 const Mat33& m33JointOrientation,
00063 const EulerAngles& minAngles,
00064 const EulerAngles& maxAngles);
00065 void InitialiseHinge(
00066 const Vec3& v3Position,
00067 const Vec3& v3HingeAxis,
00068 float fMinAngle,
00069 float fMaxAngle);
00070 void InitialiseBallAndSocket(
00071 const Vec3& v3Position,
00072 const Vec3& v3LimitCenterDirection,
00073 float fMaxAngle);
00074 void InitialiseLimitedBallAndSocket(
00075 const Vec3& v3Position,
00076 const Mat33& m33JointOrientation,
00077 float fMaxAngleY,
00078 float fMaxAngleXZ);
00079 void InitialiseSquareSocket(
00080 const Vec3& v3Position,
00081 const Mat33& m33JointOrientation,
00082 float fMinX,
00083 float fMaxX,
00084 float fMinY,
00085 float fMaxY,
00086 float fMinZ,
00087 float fMaxZ);
00088 void InitialiseSlider(
00089 const Vec3& v3PosOnA,
00090 const Vec3& v3StartPosOnB,
00091 const Vec3& v3EndPosPosOnB);
00092 void InitialiseRotationConstraint(
00093 const Mat33& m33JointOrientation,
00094 const EulerAngles& minAngles,
00095 const EulerAngles& maxAngles);
00096 void InitialiseVectorConstraint(
00097 const Vec3& v3LimitCenterDirection,
00098 float fMaxAngle);
00100
00101
00103
00104 void InitialiseEulerConstraintEx(
00105 const Vec3& v3LocalPosOnA,
00106 const Vec3& v3LocalPosOnB,
00107 const Mat33& m33JointOrientation,
00108 const Mat33& m33DefaultRotationA,
00109 const Mat33& m33DefaultRotationB,
00110 const EulerAngles& minAngles,
00111 const EulerAngles& maxAngles);
00112 void InitialiseHingeEx(
00113 const Vec3& v3LocalPosOnA,
00114 const Vec3& v3LocalPosOnB,
00115 const Vec3& v3HingeAxis,
00116 const Vec3& v3HingeCenterDirection,
00117 const Mat33& m33DefaultRotationA,
00118 const Mat33& m33DefaultRotationB,
00119 float fMinAngle,
00120 float fMaxAngle);
00121 void InitialiseBallAndSocketEx(
00122 const Vec3& v3LocalPosOnA,
00123 const Vec3& v3LocalPosOnB,
00124 const Vec3& v3LocalLimitCenterDirectionOnA,
00125 const Vec3& v3LocalLimitCenterDirectionOnB,
00126 float fMaxAngle);
00127 void InitialiseLimitedBallAndSocketEx(
00128 const Vec3& v3LocalPosOnA,
00129 const Vec3& v3LocalPosOnB,
00130 const Mat33& m33JointOrientation,
00131 const Mat33& m33DefaultRotationA,
00132 const Mat33& m33DefaultRotationB,
00133 float fMaxAngleY,
00134 float fMaxAngleXZ);
00135 void InitialiseSquareSocketEx(
00136 const Vec3& v3LocalPosOnA,
00137 const Vec3& v3LocalPosOnB,
00138 const Mat33& m33JointOrientation,
00139 const Mat33& m33DefaultRotationA,
00140 const Mat33& m33DefaultRotationB,
00141 float fMinX,
00142 float fMaxX,
00143 float fMinY,
00144 float fMaxY,
00145 float fMinZ,
00146 float fMaxZ);
00147 void InitialiseSliderEx(
00148 const Vec3& v3LocalPosOnA,
00149 const Vec3& v3LocalStartPosOnB,
00150 const Vec3& v3LocalEndPosPosOnB);
00151 void InitialiseRotationConstraintEx(
00152 const Mat33& m33JointOrientation,
00153 const Mat33& m33DefaultRotationA,
00154 const Mat33& m33DefaultRotationB,
00155 const EulerAngles& minAngles,
00156 const EulerAngles& maxAngles);
00157 void InitialiseVectorConstraintEx(
00158 const Vec3& v3LocalLimitCenterDirectionOnA,
00159 const Vec3& v3LocalLimitCenterDirectionOnB,
00160 float fMaxAngle);
00162
00163
00165
00166
00167
00168 void Reset(
00169 const Vec3& v3PosOnA,
00170 const Vec3& v3PosOnB,
00171 const Mat33& defaultRotationB,
00172 const EulerAngles& minAngles,
00173 const EulerAngles& maxAngles);
00174
00175
00176
00177 void ResetAsTypeHinge(
00178 const Vec3& v3PosOnA,
00179 const Vec3& v3PosOnB,
00180 const Vec3& v3LocalHingeAxis,
00181 const Vec3& v3LocalHingeNormal,
00182 float fMinAngle,
00183 float fMaxAngle);
00184
00185 void ResetAsTypeSocket(
00186 const Vec3& v3PosOnA,
00187 const Vec3& v3PosOnB,
00188 const Vec3& v3LimitNormalOnA,
00189 const Vec3& v3LimitNormalOnB,
00190 float fMaxAngle);
00191
00192
00193
00194 void ResetAsTypeLimitedSocket(
00195 const Vec3& v3PosOnA,
00196 const Vec3& v3PosOnB,
00197 const Mat33& defaultRotationB,
00198 float fMaxAngleY,
00199 float fMaxAngleXZ);
00200
00201
00202
00203 void ResetAsTypeSquareSocket(
00204 const Vec3& v3PosOnA,
00205 const Vec3& v3PosOnB,
00206 const Mat33& defaultRotationB,
00207 float fMinX,
00208 float fMaxX,
00209 float fMinY,
00210 float fMaxY,
00211 float fMinZ,
00212 float fMaxZ);
00213
00214
00215
00216 void ResetAsTypeSlider(
00217 const Vec3& v3PosOnA,
00218 const Vec3& v3StartPosOnB,
00219 const Vec3& v3EndPosPosOnB);
00220
00221
00222
00223 void ResetAsTypeRotationConstraint(
00224 const Mat33& defaultRotationB,
00225 const EulerAngles& minAngles,
00226 const EulerAngles& maxAngles);
00227
00228
00229
00230 void ResetAsTypeVectorConstraint(
00231 const Vec3& v3LimitNormalOnA,
00232 const Vec3& v3LimitNormalOnB,
00233 float fMaxAngle);
00235
00236
00238
00239 bool IsObjectASolid() const;
00240 void SetObjectASolid(bool bValue);
00241 bool IsObjectBSolid() const;
00242 void SetObjectBSolid(bool bValue);
00243 bool IsCollisionDisabledBetweenObjects() const;
00244 void SetCollisionDisabledBetweenObjects(bool bValue);
00246
00248
00249 float GetBreakForce() const;
00250 void SetBreakForce(float fBreakForce);
00251 void SetBreakable(bool bValue);
00252 bool IsBreakable() const;
00253 void SetBroken(bool bValue);
00254 bool IsBroken() const;
00256
00258
00259 void* GetUserData() const;
00260 void SetUserData(void* pUserData);
00262
00264
00265 Type GetType() const;
00266 DynamicObject* GetObjectA();
00267 DynamicObject* GetObjectB();
00268 const Vec3& GetPosOnObjectA() const;
00269 const Vec3& GetPosOnObjectB() const;
00270 const Vec3& GetLimitNormalOnObjectA() const;
00271 const Vec3& GetLimitNormalOnObjectB() const;
00272 const Vec3& GetCenterDirectionOnObjectA() const;
00273 const Vec3& GetCenterDirectionOnObjectB() const;
00274 float GetMaxAngle() const;
00275 const Mat33& GetJointOrientationA();
00276 const Mat33& GetJointOrientationB();
00277 const EulerAngles& GetMinAngles();
00278 const EulerAngles& GetMaxAngles();
00279 const Vec3& GetSliderPos0() const;
00280 const Vec3& GetSliderPos1() const;
00282
00283
00284 TA_OBFUSCATION_RESERVED_OFF
00285 #ifdef TA_PHYSICS_INTERNAL
00286 bool IsMarked() const { return GetFlag(m_nFlags, FLAG_MARKED); }
00287 void SetMarked(bool bValue) { SetFlag(m_nFlags, FLAG_MARKED, bValue); }
00288 bool IsPropagateForward() const { return GetFlag(m_nFlags, FLAG_PROPAGATE_FORWARD); }
00289 void SetPropagateForward(bool bValue) { SetFlag(m_nFlags, FLAG_PROPAGATE_FORWARD, bValue); }
00290 const EulerAngles& GetPreviousOrientation() const { return m_previousOrientation; }
00291 void SetPreviousOrientation(const EulerAngles& orientation) { m_previousOrientation = orientation; }
00292 float CircularSquareConstrainVector(Vec3& v3ConstrainedVector, Vec3* pv3Normal);
00293 void Initialise(DynamicObject* pDynamicObjectA, DynamicObject* pDynamicObjectB);
00294 void Finalise();
00295 void SetLastUpdateFrame(u32 nValue) { m_nLastUpdateFrame = nValue; }
00296 u32 GetLastUpdateFrame() const { return m_nLastUpdateFrame; }
00297 #endif // TA_PHYSICS_INTERNAL
00298
00299 private:
00300 enum
00301 {
00302 FLAG_OBJECTA_SOLID = 0x1,
00303 FLAG_OBJECTB_SOLID = 0x2,
00304 FLAG_DISABLE_COLLISION_BETWEEN_OBJECTS = 0x4,
00305 FLAG_MARKED = 0x8,
00306 FLAG_PROPAGATE_FORWARD = 0x10,
00307 FLAG_BREAKABLE = 0x20,
00308 FLAG_BROKEN = 0x40,
00309 };
00310 PhysicsJoint(PhysicsJoint&);
00311
00312 Vec3 m_v3PosOnA;
00313 Vec3 m_v3PosOnB;
00314 Vec3 m_v3LimitNormalOnA;
00315 Vec3 m_v3LimitNormalOnB;
00316 Mat33 m_m33JointOrientationA;
00317 Mat33 m_m33JointOrientationB;
00318 EulerAngles m_minAngles;
00319 EulerAngles m_maxAngles;
00320 EulerAngles m_previousOrientation;
00321 u16 m_eType;
00322 u16 m_nFlags;
00323 DynamicObject* m_pDynamicObjectA;
00324 DynamicObject* m_pDynamicObjectB;
00325 float m_fMaxAngle;
00326 float m_fBreakForce;
00327 int m_nLastUpdateFrame;
00328 void* m_pUserData;
00329 };
00330
00331 }
00332
00333 #include "PhysicsJoint.inl"
00334
00335 #endif // TA_PHYSICSJOINT_H
© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.