2 Copyright (C) 2009 Sony Computer Entertainment Inc.
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
17 #ifndef BT_RB_DYN_BODY_H__
18 #define BT_RB_DYN_BODY_H__
20 #include "vectormath/vmInclude.h"
21 using namespace Vectormath::Aos
;
23 #include "TrbStateVec.h"
39 float getMass() const {return fMass
;};
40 float getElasticity() const {return fElasticity
;}
41 float getFriction() const {return fFriction
;}
42 CollObject
* getCollObject() const {return fCollObject
;}
43 const Matrix3
&getBodyInertia() const {return fIBody
;}
44 const Matrix3
&getBodyInertiaInv() const {return fIBodyInv
;}
45 float getMassInv() const {return fMassInv
;}
48 void setMass(float mass
) {fMass
=mass
;fMassInv
=mass
>0.0f
?1.0f
/mass
:0.0f
;}
49 void setBodyInertia(const Matrix3 bodyInertia
) {fIBody
= bodyInertia
;fIBodyInv
= inverse(bodyInertia
);}
50 void setElasticity(float elasticity
) {fElasticity
= elasticity
;}
51 void setFriction(float friction
) {fFriction
= friction
;}
52 void setCollObject(CollObject
*collObj
) {fCollObject
= collObj
;}
54 void setBodyInertiaInv(const Matrix3 bodyInertiaInv
)
56 fIBody
= inverse(bodyInertiaInv
);
57 fIBodyInv
= bodyInertiaInv
;
59 void setMassInv(float invMass
) {
60 fMass
= invMass
>0.0f
? 1.0f
/invMass
:0.0f
;
66 // Rigid Body constants
67 float fMass
; // Rigid Body mass
68 float fMassInv
; // Inverse of mass
69 Matrix3 fIBody
; // Inertia matrix in body's coords
70 Matrix3 fIBodyInv
; // Inertia matrix inverse in body's coords
71 float fElasticity
; // Coefficient of restitution
72 float fFriction
; // Coefficient of friction
75 CollObject
* fCollObject
; // Collision object corresponding the RB
76 } __attribute__ ((aligned(16)));
78 #endif //BT_RB_DYN_BODY_H__