AnimatLab  2
Test
VsMovableItem.h
1 
2 #pragma once
3 
4 #include "OsgGeometry.h"
5 
6 namespace VortexAnimatSim
7 {
8  namespace Environment
9  {
10 
12  {
13  protected:
14  AnimatBase *m_lpThisAB;
15  MovableItem *m_lpThisMI;
16  VsMovableItem *m_lpThisVsMI;
17  VsMovableItem *m_lpParentVsMI;
18 
19  osg::Matrix m_osgWorldMatrix;
20 
21  osg::ref_ptr<osg::Group> m_osgParent;
22  osg::ref_ptr<osgManipulator::Selection> m_osgMT;
23  osg::ref_ptr<osg::Geometry> m_osgGeometry;
24  osg::ref_ptr<osg::Group> m_osgRoot;
25  osg::ref_ptr<osg::Node> m_osgNode;
26  osg::ref_ptr<osg::Group> m_osgNodeGroup;
27 
28  osg::ref_ptr<osg::CullFace> m_osgCull;
29  osg::ref_ptr<osg::Texture2D> m_osgTexture;
30 
31  osg::ref_ptr<osg::StateSet> m_osgStateSet;
32  osg::ref_ptr<osg::Material> m_osgMaterial;
33 
34  osg::ref_ptr<osg::Group> m_osgSelectedGroup;
35  osg::ref_ptr<VsDragger> m_osgDragger;
36 
37  osg::Matrix m_osgLocalMatrix;
38 
41 
46  osg::ref_ptr< osg::MatrixTransform> m_osgGeometryRotationMT;
47 
48  //Some parts, like joints, have an additional offset matrix. This
49  //Final Matrix is the combination of the local and offset matrix.
50  osg::Matrix m_osgFinalMatrix;
51  bool m_bCullBackfaces;
52  osg::StateAttribute::GLMode m_eTextureMode;
53 
54  osg::ref_ptr<osg::MatrixTransform> m_osgSelVertexMT;
55  osg::ref_ptr<osg::Geode> m_osgSelVertexNode;
56 
57  virtual void SetThisPointers();
58  virtual void LocalMatrix(osg::Matrix osgLocalMT);
59  virtual void GeometryRotationMatrix(osg::Matrix osgGeometryMT);
60 
61  virtual void SetupGraphics();
62  virtual void SetupPhysics() = 0;
63  virtual void DeleteGraphics();
64  virtual void DeletePhysics() = 0;
65  virtual void CreateSelectedGraphics(std::string strName);
66  virtual void CreateDragger(std::string strName);
67  virtual void CreateSelectedVertex(std::string strName);
68  virtual void DeleteSelectedVertex();
69  virtual void AttachedPartMovedOrRotated(std::string strID);
70  virtual void UpdatePositionAndRotationFromMatrix();
71  virtual void UpdatePositionAndRotationFromMatrix(osg::Matrix osgMT);
72 
73  virtual void CreateGraphicsGeometry();
74  virtual void CreatePhysicsGeometry();
75  virtual void CreateGeometry();
76  virtual void ResizePhysicsGeometry();
77 
78  virtual void UpdateWorldMatrix();
79 
80  virtual void ShowSelectedVertex();
81  virtual void HideSelectedVertex();
82 
83  public:
84  VsMovableItem();
85  virtual ~VsMovableItem();
86 
87  virtual VsSimulator *GetVsSimulator();
88  virtual VsMovableItem *VsParent();
89  virtual osg::Group *ParentOSG() = 0;
90  virtual osg::Group *RootGroup() {return m_osgRoot.get();};
91  virtual osg::Group *NodeGroup() {return m_osgNodeGroup.get();};
92  virtual osg::Matrix LocalMatrix() {return m_osgLocalMatrix;};
93  virtual osg::Matrix FinalMatrix() {return m_osgFinalMatrix;};
94 
95  virtual void Physics_SetParent(MovableItem *lpParent)
96  {
97  m_lpParentVsMI = dynamic_cast<VsMovableItem *>(lpParent);
98  };
99  virtual void Physics_SetChild(MovableItem *lpParent) {};
100 
101 
102  //virtual CStdFPoint GetOSGWorldCoords(osg::MatrixTransform *osgMT);
103  virtual CStdFPoint GetOSGWorldCoords();
104  virtual osg::Matrix GetOSGWorldMatrix(bool bUpdate = false);
105  //virtual osg::Matrix GetOSGWorldMatrix(osg::MatrixTransform *osgMT);
106 
107  virtual void EndGripDrag();
108 
109  virtual std::string Physics_ID();
110  virtual void Physics_UpdateMatrix();
111  virtual void Physics_ResetGraphicsAndPhysics();
112  virtual void Physics_PositionChanged();
113  virtual void Physics_RotationChanged();
114  virtual void Physics_UpdateAbsolutePosition();
115  virtual void Physics_Selected(bool bValue, bool bSelectMultiple);
116  virtual float Physics_GetBoundingRadius();
117  virtual BoundingBox Physics_GetBoundingBox();
118  virtual void Physics_SetColor() {};
119  virtual void Physics_TextureChanged() {};
120  virtual void Physics_CollectData();
121  virtual void Physics_CollectExtraData() {};
122  virtual void Physics_ResetSimulation();
123  virtual void Physics_AfterResetSimulation() {};
124  virtual float *Physics_GetDataPointer(const std::string &strDataType);
125  virtual void Physics_OrientNewPart(float fltXPos, float fltYPos, float fltZPos, float fltXNorm, float fltYNorm, float fltZNorm);
126  virtual void Physics_SelectedVertex(float fltXPos, float fltYPos, float fltZPos) {};
127  virtual bool Physics_CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos);
128  virtual void Physics_LoadLocalTransformMatrix(CStdXml &oXml);
129  virtual void Physics_SaveLocalTransformMatrix(CStdXml &oXml);
130  virtual std::string Physics_GetLocalTransformMatrixString();
131  virtual void Physics_ResizeDragHandler(float fltRadius);
132 
133  virtual void SetTexture(std::string strTexture);
134  virtual void SetCulling();
135  virtual void SetColor(CStdColor &vAmbient, CStdColor &vDiffuse, CStdColor &vSpecular, float fltShininess);
136  virtual void SetAlpha();
137  virtual void SetMaterialAlpha(osg::Material *osgMat, osg::StateSet *ss, float fltAlpha);
138  virtual void SetVisible(bool bVisible);
139  virtual void SetVisible(osg::Node *osgNode, bool bVisible);
140  //virtual osg::Vec3 FindPointOnSurface(osg::Vec3 vDirection);
141 
142  //virtual void Initialize() = 0;
143  virtual void CreateItem();
144 
145  virtual osg::Matrix GetWorldMatrix();
146  virtual osg::Matrix GetParentWorldMatrix();
147 
148  virtual osg::MatrixTransform* GetMatrixTransform();
149  virtual osg::MatrixTransform* GetCameraMatrixTransform();
150 
151  virtual void BuildLocalMatrix();
152  virtual void BuildLocalMatrix(CStdFPoint localPos, CStdFPoint localRot, std::string strName);
153  virtual void WorldToBodyCoords(VxReal3 vWorldPos, StdVector3 &vLocalPos);
154 
155  };
156 
157  } // Environment
158 } //VortexAnimatSim
159 
160 
float m_fltNullReport
This is used to report back 0 from GetDataPointer for items that are not supported in vortex...
Definition: VsMovableItem.h:40
osg::ref_ptr< osg::MatrixTransform > m_osgGeometryRotationMT
Definition: VsMovableItem.h:46
Classes for implementing the cm-labs vortex physics engine for AnimatLab.