VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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>
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  virtual void printResults(const char* str, unsigned int characteristics, const char* additionalInformation = 0);
84 
85  protected:
86  typedef boost::unordered_map <DtString, DtSurface::DtCharacteristics> DtSurfaceStringToCharacteristics;
87  typedef DtSurfaceStringToCharacteristics::const_iterator DtSurfStrToCharsConstIter;
88  typedef DtSurfaceStringToCharacteristics::iterator DtSurfStrToCharsIter;
89 
91  static const DtString theMatchString;
92 
93  private:
94 
100  std::set<std::string> myPrintedMessages;
101  };
102 
103 }
104 
105 //class makVrv::DtOsgRenderer::RootList;
106 
107 
110 {
111 public:
112  DtTriangleMeshWithSoil (bool use32bitIndices=true, bool use4componentVertices=true);
113  virtual ~DtTriangleMeshWithSoil();
114 
115  bool valid(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2) const;
116  bool valid(const btVector3& vertex) const;
117  bool valid(const btScalar& val) const;
118 
119  bool checkAddTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
120  bool removeDuplicateVertices = false);
121 
122  void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
123  bool removeDuplicateVertices = false);
124 
125  void addTriangleWithSurface(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
126  const DtSurface& surface, bool removeDuplicateVertices=false);
127 
128  DtSurface triangleSurface(unsigned int triangleIndex) const;
129 
130  const btVector3& max() const;
131  const btVector3& min() const;
132 
133  bool isAabbValid() const;
134 
135 protected:
136  void updateBounds(const btVector3& val);
137 
140  void initializeSurfaceArray();
141 
144  void syncSurfaceArray();
145 
151  btAlignedObjectArray<DtSurface> mySurfaceTypes;
152  btVector3 myMin;
153  btVector3 myMax;
154 };
155 
157 {
158 public:
159  virtual ~DtBvhBuilder();
160 
163  virtual bool buildBvh() = 0;
164 };
165 
166 typedef std::list<btCollisionObject*> DtCollisionObjectList;
167 typedef std::vector<std::pair<DtTriangleMeshWithSoil*, osg::Matrix> > DtMeshTransformPairList;
168 
173 {
175  : osgRenderer(r), sceneRoot(sr) {};
178 };
179 
183  DtCollisionObjectList* collObjects,
184  const DtDrawMode& drawMode,
185  osg::Node* node,
186  const osg::Matrix& baseTransform,
187  const DtFilename& surfaceCharacterFilename = "",
188  bool treatPagedLODAsLOD = false,
189  bool checkGeodesForSurfaces = false,
190  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>());
191 
193  DtCollisionObjectList* collObjects,
194  const DtDrawMode& drawMode,
195  osg::Node* node,
196  const osg::Matrix& baseTransform,
197  const DtSurface& surface);
198 
202  DtCollisionObjectList* collObjects,
203  const DtDrawMode& drawMode,
204  DtVantageRootNode node,
205  const osg::Matrix& baseTransform,
206  const DtFilename& surfaceCharacterFilename = "",
207  bool treatPagedLODAsLOD = false,
208  bool checkGeodesForSurfaces = false,
209  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>());
210 
211 Coordinate_System* createVrfCoordinateSystem( const makVrv::DtCoordinateSystem& coodSysIn );
212 
213 void getBasisAndOrigin(
214  osg::Matrix& matrix, btMatrix3x3& basisA, btVector3& origin, bool& scaled);
215 
219 template<typename T_Node>
221  T_Node node,
222  DtCollisionObjectList* collObjects,
223  const DtDrawMode& drawMode,
224  const osg::Matrix* worldMatrix = NULL,
225  const DtFilename& surfaceCharacterFilename = "",
226  bool treatPagedLODAsLOD = false,
227  bool checkGeodesForSurfaces = false,
228  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>())
229 {
230  osg::Matrix baseMatrix;
231  if (worldMatrix)
232  {
233  baseMatrix = *worldMatrix;
234  }
235 
236  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode,
237  node, baseMatrix, surfaceCharacterFilename, treatPagedLODAsLOD, checkGeodesForSurfaces,
238  ignoreSurfacesMatching);
239 
240  return numTriangles;
241 }
242 
244 template<typename T_Node>
246  T_Node node,
247  DtCollisionObjectList* collObjects,
248  const DtDrawMode& drawMode,
249  const DtFilename& surfaceCharacterFilename,
250  const std::vector<std::string>& ignoreSurfacesMatching)
251 {
252  return createCollisionObjects(
253  node, collObjects, drawMode, NULL,
254  surfaceCharacterFilename, false, false, ignoreSurfacesMatching);
255 }
256 
260 template<typename T_Node>
262  T_Node node,
263  DtCollisionObjectList* collObjects,
264  const DtDrawMode& drawMode,
265  const DtSurface& surface,
266  const osg::Matrix* worldMatrix = NULL)
267 {
268  osg::Matrix baseMatrix;
269  if (worldMatrix)
270  {
271  baseMatrix = *worldMatrix;
272  }
273 
274  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode, node, baseMatrix, surface);
275 
276  return numTriangles;
277 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)