AnimatLab  2
Test
OsgJoint.h
1 // OsgJoint.h: interface for the OsgJoint class.
2 //
4 
5 #pragma once
6 
7 namespace OsgAnimatSim
8 {
9  namespace Environment
10  {
11 
26  class ANIMAT_OSG_PORT OsgJoint : public OsgBody
27  {
28  protected:
29 
30 #pragma region DefaultBallGraphicsItems
31 
32  //Graphics objects for the default joint drawing code
34  osg::ref_ptr<osg::Geometry> m_osgDefaultBall;
35 
37  osg::ref_ptr<osg::MatrixTransform> m_osgDefaultBallMT;
38 
40  osg::ref_ptr<osg::Material> m_osgDefaultBallMat;
41 
43  osg::ref_ptr<osg::StateSet> m_osgDefaultBallSS;
44 
46  osg::ref_ptr<osg::MatrixTransform> m_osgJointMT;
47 
50 
51 #pragma endregion
52 
53  Joint *m_lpThisJoint;
54  OsgBody *m_lpVsParent;
55  OsgBody *m_lpVsChild;
56 
57  virtual void SetThisPointers();
58 
59  virtual void ResetDraggerOnResize();
60  virtual void DeleteJointGraphics();
61  virtual void CreateJointGraphics();
62  virtual osg::Vec3d NormalizeAxis(CStdFPoint vLocalRot);
63  virtual void UpdatePositionAndRotationFromMatrix();
64 
65  public:
66  OsgJoint();
67  virtual ~OsgJoint();
68 
69  virtual osg::MatrixTransform *ParentOSG();
70  virtual osg::MatrixTransform *ChildOSG();
71  virtual osg::Matrix GetChildWorldMatrix();
72  virtual osg::Matrix GetChildPhysicsWorldMatrix();
73  virtual osg::Matrix GetChildComMatrix(bool bInvert = false);
74 
75  virtual void SetAlpha();
76 
77  virtual void SetupGraphics();
78  virtual void DeleteGraphics();
79  virtual void SetupPhysics();
80 
81  virtual void StartGripDrag();
82  virtual void EndGripDrag();
83 
84  virtual void Initialize();
85  virtual bool Physics_SetData(const std::string &strDataType, const std::string &strValue);
86  virtual void Physics_QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
87 
88  //Methods not used by joints.
89  virtual void Physics_ResetGraphicsAndPhysics();
90  virtual bool Physics_IsGeometryDefined() {return true;};
91  virtual void Physics_Resize();
92  virtual void Physics_ResetSimulation();
93  virtual void Physics_SetParent(MovableItem *lpParent);
94  virtual void Physics_SetChild(MovableItem *lpChild);
95  virtual void Physics_UpdateMatrix();
96  virtual void Physics_PositionChanged();
97  virtual void Physics_RotationChanged();
98  virtual void BuildLocalMatrix();
99  virtual void BuildLocalMatrix(CStdFPoint localPos, CStdFPoint vLocalOffset, CStdFPoint localRot, std::string strName);
100  virtual void Physics_EnableCollision(RigidBody *lpBody) {};
101  virtual void Physics_DisableCollision(RigidBody *lpBody) {};
102  virtual void Physics_AddBodyForceAtLocalPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits) {};
103  virtual void Physics_AddBodyForceAtWorldPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits) {};
104  virtual void Physics_AddBodyTorque(float fltTx, float fltTy, float fltTz, bool bScaleUnits) {};
105  virtual CStdFPoint Physics_GetVelocityAtPoint(float x, float y, float z) {CStdFPoint v; return v;};
106  virtual bool Physics_CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos);
107  };
108 
109  } // Environment
110 } //OsgAnimatSim
osg::ref_ptr< osg::Geometry > m_osgDefaultBall
The osg default ball geometry.
Definition: OsgJoint.h:34
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
Vortex base body class.
Definition: OsgBody.h:26
osg::ref_ptr< osg::StateSet > m_osgDefaultBallSS
The osg default ball state set.
Definition: OsgJoint.h:43
CStdFPoint m_vJointGraphicsRotOffset
Rotational offset needed to make the joint graphics match the physics.
Definition: OsgJoint.h:49
osg::ref_ptr< osg::MatrixTransform > m_osgJointMT
The osg joint matrix transform.
Definition: OsgJoint.h:46
A common class for all joint data specific to vortex.
Definition: OsgJoint.h:26
osg::ref_ptr< osg::Material > m_osgDefaultBallMat
The osg default ball material.
Definition: OsgJoint.h:40
osg::ref_ptr< osg::MatrixTransform > m_osgDefaultBallMT
The osg default ball matrix transform.
Definition: OsgJoint.h:37