VR-Forces 4.2 Class Documentation
osgToBullet.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 
16 #include <btBulletCollisionCommon.h>
17 #include <memory>
18 #include <vrvUtil/DtCoordinateSystem.h>
19 #include <vlutil/vlSmartPointers.h>
20 #include <vlutil/vlFilename.h>
21 #include <geometry/surface.h>
22 
24 #include <osg/Matrix>
25 #include <vrvOsg/DtOsgRenderer.h>
26 #include <vrvUtil/DtCoordinateSystem.h>
27 
29 #include <vlutil/vlSmartPointers.h>
30 
32 #include <memory>
33 #include "vlutil/vlFilename.h"
34 
35 class btTriangleMesh;
36 class Coordinate_System;
37 
38 
39 
40 namespace osg
41 {
42  class Node;
43  class LOD;
44 }
45 
47 //This should move to surface.h
49 
50 
51 
52 namespace makVrf {
54  {
55 
56  public:
57 
60 
63 
66 
69 
71  virtual bool init(const DtFilename filename, bool displayWarning = false);
72 
74  virtual bool get(std::istream& stream);
75 
77  virtual bool processToken(std::istream& stream, DtString& token);
78 
80  virtual bool characteristicsFromString(const char* str,
81  unsigned int& characteristics, int& position);
82 
83  protected:
84  typedef boost::unordered_map <DtString, DtSurface::DtCharacteristics> DtSurfaceStringToCharacteristics;
85  typedef DtSurfaceStringToCharacteristics::const_iterator DtSurfStrToCharsConstIter;
86  typedef DtSurfaceStringToCharacteristics::iterator DtSurfStrToCharsIter;
87 
89  static const DtString theMatchString;
90 
91  private:
92 
99  std::set<std::string> myPrintedWarnings;
100  };
101 
102 }
103 
104 //class makVrv::DtOsgRenderer::RootList;
105 
106 
109 {
110 public:
111  DtTriangleMeshWithSoil (bool use32bitIndices=true, bool use4componentVertices=true);
112  virtual ~DtTriangleMeshWithSoil();
113 
114  bool valid(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2) const;
115  bool valid(const btVector3& vertex) const;
116  bool valid(const btScalar& val) const;
117 
118  bool checkAddTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
119  bool removeDuplicateVertices = false);
120 
121  void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
122  bool removeDuplicateVertices = false);
123 
124  void addTriangleWithSurface(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
125  const DtSurface& surface, bool removeDuplicateVertices=false);
126 
127  DtSurface triangleSurface(unsigned int triangleIndex) const;
128 
129  const btVector3& max() const;
130  const btVector3& min() const;
131 
132  bool isAabbValid() const;
133 
134 protected:
135  void updateBounds(const btVector3& val);
136 
139  void initializeSurfaceArray();
140 
143  void syncSurfaceArray();
144 
150  btAlignedObjectArray<DtSurface> mySurfaceTypes;
151  btVector3 myMin;
152  btVector3 myMax;
153 };
154 
156 {
157 public:
158  virtual ~DtBvhBuilder();
159 
162  virtual bool buildBvh() = 0;
163 };
164 
165 typedef std::list<btCollisionObject*> DtCollisionObjectList;
166 typedef std::vector<std::pair<DtTriangleMeshWithSoil*, osg::Matrix> > DtMeshTransformPairList;
167 
172 {
173  DtVantageRootNode(makVrv::DtOsgRenderer* r, makVrv::DtOsgRenderer::SceneRoot sr)
174  : osgRenderer(r), sceneRoot(sr) {};
175  makVrv::DtOsgRenderer* osgRenderer;
176  makVrv::DtOsgRenderer::SceneRoot sceneRoot;
177 };
178 
181 int convertOsgNodeToTriangeMesh(DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, osg::Node* node,
182  const osg::Matrix& baseTransform,
183  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false,
184  bool checkGeodesForSurfaces = false,
185  std::vector<std::string> ignoreSurfacesMatching = std::vector<std::string>());
186 
187 int convertOsgNodeToTriangeMesh(DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, osg::Node* node,
188  const osg::Matrix& baseTransform, const DtSurface& surface);
189 
192 int convertOsgNodeToTriangeMesh(DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, DtVantageRootNode node,
193  const osg::Matrix& baseTransform,
194  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false,
195  bool checkGeodesForSurfaces = false,
196  std::vector<std::string> ignoreSurfacesMatching = std::vector<std::string>());
197 
198 Coordinate_System* createVrfCoordinateSystem( const makVrv::DtCoordinateSystem& coodSysIn );
199 
200 void getBasisAndOrigin(osg::Matrix& matrix,
201  btMatrix3x3& basisA, btVector3& origin, bool& scaled);
202 
206 template<typename T_Node>
208  T_Node node,
209  DtCollisionObjectList* collObjects, const DtDrawMode& drawMode,
210  osg::Matrix* worldMatrix = NULL,
211  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false, bool checkGeodesForSurfaces = false,
212  std::vector<std::string> ignoreSurfacesMatching = std::vector<std::string>())
213 {
214  osg::Matrix baseMatrix;
215  if (worldMatrix)
216  {
217  baseMatrix = *worldMatrix;
218  }
219 
220  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode,
221  node, baseMatrix, surfaceCharacterFilename, treatPagedLODAsLOD, checkGeodesForSurfaces,
222  ignoreSurfacesMatching);
223 
224  return numTriangles;
225 }
226 
230 template<typename T_Node>
232  T_Node node,
233  DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, const DtSurface& surface,
234  osg::Matrix* worldMatrix = NULL)
235 {
236  osg::Matrix baseMatrix;
237  if (worldMatrix)
238  {
239  baseMatrix = *worldMatrix;
240  }
241 
242  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode, node, baseMatrix, surface);
243 
244  return numTriangles;
245 }

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)