00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00019 #ifndef CYCLONE_BODY_H
00020 #define CYCLONE_BODY_H
00021
00022 #include "core.h"
00023
00024 namespace cyclone {
00025
00027
00031
00044
00045
00046 class RigidBody
00047 {
00049 public:
00051
00053
00054
00056
00057 protected:
00091
00092
00100 real inverseMass;
00102
00104
00118 Matrix3 inverseInertiaTensor;
00120
00126 real linearDamping;
00127
00129
00134 real angularDamping;
00136
00138
00142 Vector3 position;
00143
00148 Quaternion orientation;
00149
00154 Vector3 velocity;
00155
00160 Vector3 rotation;
00162
00173
00181 Matrix3 inverseInertiaTensorWorld;
00182
00184
00188 real motion;
00189
00195 bool isAwake;
00196
00202 bool canSleep;
00204
00206
00211
00216
00217 Matrix4 transformMatrix;
00219
00234
00239 Vector3 forceAccum;
00240
00245 Vector3 torqueAccum;
00246
00252 Vector3 acceleration;
00253
00258 Vector3 lastFrameAcceleration;
00259
00262 public:
00271
00288
00290
00297 void calculateDerivedData();
00299
00306 void integrate(real duration);
00307
00324
00337 void setMass(const real mass);
00338
00344 real getMass() const;
00345
00358 void setInverseMass(const real inverseMass);
00359
00365 real getInverseMass() const;
00366
00370 bool hasFiniteMass() const;
00371
00384 void setInertiaTensor(const Matrix3 &inertiaTensor);
00385
00394 void getInertiaTensor(Matrix3 *inertiaTensor) const;
00395
00403 Matrix3 getInertiaTensor() const;
00404
00413 void getInertiaTensorWorld(Matrix3 *inertiaTensor) const;
00414
00421 Matrix3 getInertiaTensorWorld() const;
00422
00435 void setInverseInertiaTensor(const Matrix3 &inverseInertiaTensor);
00436
00446 void getInverseInertiaTensor(Matrix3 *inverseInertiaTensor) const;
00447
00456 Matrix3 getInverseInertiaTensor() const;
00457
00466 void getInverseInertiaTensorWorld(Matrix3 *inverseInertiaTensor) const;
00467
00476 Matrix3 getInverseInertiaTensorWorld() const;
00477
00490 void setDamping(const real linearDamping, const real angularDamping);
00491
00500 void setLinearDamping(const real linearDamping);
00501
00507 real getLinearDamping() const;
00508
00517 void setAngularDamping(const real angularDamping);
00518
00524 real getAngularDamping() const;
00525
00531 void setPosition(const Vector3 &position);
00532
00545 void setPosition(const real x, const real y, const real z);
00546
00553 void getPosition(Vector3 *position) const;
00554
00560 Vector3 getPosition() const;
00561
00572 void setOrientation(const Quaternion &orientation);
00573
00594 void setOrientation(const real r, const real i,
00595 const real j, const real k);
00596
00604 void getOrientation(Quaternion *orientation) const;
00605
00611 Quaternion getOrientation() const;
00612
00622 void getOrientation(Matrix3 *matrix) const;
00623
00633 void getOrientation(real matrix[9]) const;
00634
00644 void getTransform(Matrix4 *transform) const;
00645
00656 void getTransform(real matrix[16]) const;
00657
00670 void getGLTransform(float matrix[16]) const;
00671
00681 Matrix4 getTransform() const;
00682
00691 Vector3 getPointInLocalSpace(const Vector3 &point) const;
00692
00701 Vector3 getPointInWorldSpace(const Vector3 &point) const;
00702
00715 Vector3 getDirectionInLocalSpace(const Vector3 &direction) const;
00716
00729 Vector3 getDirectionInWorldSpace(const Vector3 &direction) const;
00730
00737 void setVelocity(const Vector3 &velocity);
00738
00752 void setVelocity(const real x, const real y, const real z);
00753
00760 void getVelocity(Vector3 *velocity) const;
00761
00768 Vector3 getVelocity() const;
00769
00773 void addVelocity(const Vector3 &deltaVelocity);
00774
00781 void setRotation(const Vector3 &rotation);
00782
00796 void setRotation(const real x, const real y, const real z);
00797
00804 void getRotation(Vector3 *rotation) const;
00805
00812 Vector3 getRotation() const;
00813
00817 void addRotation(const Vector3 &deltaRotation);
00818
00825 bool getAwake() const
00826 {
00827 return isAwake;
00828 }
00829
00838 void setAwake(const bool awake=true);
00839
00844 bool getCanSleep() const
00845 {
00846 return canSleep;
00847 }
00848
00857 void setCanSleep(const bool canSleep=true);
00858
00873
00885 void getLastFrameAcceleration(Vector3 *linearAcceleration) const;
00886
00896 Vector3 getLastFrameAcceleration() const;
00897
00908
00913 void clearAccumulators();
00914
00916
00922 void addForce(const Vector3 &force);
00924
00937 void addForceAtPoint(const Vector3 &force, const Vector3 &point);
00938
00951 void addForceAtBodyPoint(const Vector3 &force, const Vector3 &point);
00952
00959 void addTorque(const Vector3 &torque);
00960
00966 void setAcceleration(const Vector3 &acceleration);
00967
00980 void setAcceleration(const real x, const real y, const real z);
00981
00988 void getAcceleration(Vector3 *acceleration) const;
00989
00996 Vector3 getAcceleration() const;
00997
00999
01000
01002 };
01004
01005 }
01006
01007 #endif // CYCLONE_BODY_H