AnimatLab  2
Test
VsJoint.h
1 // VsJoint.h: interface for the VsJoint class.
2 //
4 
5 #if !defined(AFX_VSJOINT_H__93EDBBFE_2FA0_467C_970F_1775454FE94E__INCLUDED_)
6 #define AFX_VSJOINT_H__93EDBBFE_2FA0_467C_970F_1775454FE94E__INCLUDED_
7 
8 #if _MSC_VER > 1000
9 #pragma once
10 #endif
11 
12 namespace VortexAnimatSim
13 {
14  namespace Environment
15  {
16  class VsRigidBody;
17 
32  class VORTEX_PORT VsJoint : public VsBody
33  {
34  protected:
35  Vx::VxConstraint *m_vxJoint;
36  Vx::VxConstraint::CoordinateID m_iCoordID;
37 
38  //This is the offset from the child to the parent. We must add the osg graphics to the parent osg node
39  //because if we do not then the joint will move when the child moves, and that is not correct. However,
40  //the joint is really attached relative to the child. So I am adding this extra matrix transform that is
41  //the same as the child body to make up for the fact that we have to attach to the parent osg node.
42  osg::Matrix m_osgChildOffsetMatrix;
43  osg::ref_ptr< osg::MatrixTransform> m_osgChildOffsetMT;
44 
45 #pragma region DefaultBallGraphicsItems
46 
47  //Graphics objects for the default joint drawing code
49  osg::ref_ptr<osg::Geometry> m_osgDefaultBall;
50 
52  osg::ref_ptr<osg::MatrixTransform> m_osgDefaultBallMT;
53 
55  osg::ref_ptr<osg::Material> m_osgDefaultBallMat;
56 
58  osg::ref_ptr<osg::StateSet> m_osgDefaultBallSS;
59 
61  osg::ref_ptr<osg::MatrixTransform> m_osgJointMT;
62 
63 #pragma endregion
64 
65  Joint *m_lpThisJoint;
66  VsRigidBody *m_lpVsParent;
67  VsRigidBody *m_lpVsChild;
68 
69  virtual void SetThisPointers();
70  void UpdatePosition();
71 
72  virtual void ResetDraggerOnResize();
73  virtual void DeleteJointGraphics();
74  virtual void CreateJointGraphics();
75  virtual void SetupGraphics();
76  virtual void DeleteGraphics();
77  virtual void SetupPhysics();
78  virtual VxVector3 NormalizeAxis(CStdFPoint vLocalRot);
79  virtual void UpdatePositionAndRotationFromMatrix();
80 
81  virtual void LocalMatrix(osg::Matrix osgLocalMT);
82  virtual void ChildOffsetMatrix(osg::Matrix osgMT);
83  virtual float GetCurrentVxJointPos();
84 
85  public:
86  VsJoint();
87  virtual ~VsJoint();
88 
89  virtual osg::Group *ParentOSG();
90  virtual osg::Group *ChildOSG();
91 
92  virtual void SetAlpha();
93 
94  virtual void Initialize();
95  virtual void SetBody();
96  virtual void Physics_ResetSimulation();
97  virtual void Physics_CollectData();
98  virtual bool Physics_SetData(const std::string &strDataType, const std::string &strValue);
99  virtual void Physics_QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
100  virtual void Physics_Resize();
101 
102  virtual Vx::VxConstraint* Constraint() {return m_vxJoint;};
103  virtual Vx::VxConstraint::CoordinateID CoordinateID() {return m_iCoordID;};
104 
105  //Methods not used by joints.
106  virtual void Physics_SetParent(MovableItem *lpParent);
107  virtual void Physics_SetChild(MovableItem *lpChild);
108  virtual void Physics_UpdateMatrix();
109  virtual void Physics_PositionChanged();
110  virtual void Physics_RotationChanged();
111  virtual void BuildLocalMatrix();
112  virtual void BuildLocalMatrix(CStdFPoint localPos, CStdFPoint localRot, std::string strName);
113  virtual void Physics_EnableCollision(RigidBody *lpBody) {};
114  virtual void Physics_DisableCollision(RigidBody *lpBody) {};
115  virtual void Physics_AddBodyForceAtLocalPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits) {};
116  virtual void Physics_AddBodyForceAtWorldPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits) {};
117  virtual void Physics_AddBodyTorque(float fltTx, float fltTy, float fltTz, bool bScaleUnits) {};
118  virtual CStdFPoint Physics_GetVelocityAtPoint(float x, float y, float z) {CStdFPoint v; return v;};
119  virtual float Physics_GetMass() {return 0;};
120  virtual float Physics_GetDensity() {return 0;};
121  virtual bool Physics_CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos);
122 
123  };
124 
125  } // Environment
126 } //VortexAnimatSim
127 
128 #endif // !defined(AFX_VSJOINT_H__93EDBBFE_2FA0_467C_970F_1775454FE94E__INCLUDED_)
osg::ref_ptr< osg::StateSet > m_osgDefaultBallSS
The osg default ball state set.
Definition: VsJoint.h:58
osg::ref_ptr< osg::Geometry > m_osgDefaultBall
The osg default ball geometry.
Definition: VsJoint.h:49
osg::ref_ptr< osg::MatrixTransform > m_osgDefaultBallMT
The osg default ball matrix transform.
Definition: VsJoint.h:52
A common class for all rigid body data specific to vortex.
Definition: VsRigidBody.h:55
A common class for all joint data specific to vortex.
Definition: VsJoint.h:32
osg::ref_ptr< osg::Material > m_osgDefaultBallMat
The osg default ball material.
Definition: VsJoint.h:55
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
osg::ref_ptr< osg::MatrixTransform > m_osgJointMT
The osg joint matrix transform.
Definition: VsJoint.h:61
Vortex base body class.
Definition: VsBody.h:19