VR-Forces Development_Version 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) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 
16 #include <btBulletCollisionCommon.h>
17 #include <btBulletDynamicsCommon.h>
18 #include <memory>
20 #include <vlutil/vlSmartPointers.h>
21 #include <vlutil/vlFilename.h>
22 #include <geometry/surface.h>
23 
25 #include <osg/Matrix>
26 #include <osg/NodeVisitor>
27 #include <vrvOsg/DtOsgRenderer.h>
29 
31 #include <vlutil/vlSmartPointers.h>
32 
34 #include <memory>
35 #include "vlutil/vlFilename.h"
36 
37 class btTriangleMesh;
38 class Coordinate_System;
39 
40 
41 
42 namespace osg
43 {
44  class Node;
45  class LOD;
46 }
47 
49 //This should move to surface.h
51 
52 
53 
54 namespace makVrf {
56  {
57 
58  public:
59 
62 
65 
68 
71 
73  virtual bool init(const DtFilename filename, bool displayWarning = false);
74 
76  virtual bool get(std::istream& stream);
77 
79  virtual bool processToken(std::istream& stream, DtString& token);
80 
82  virtual bool characteristicsFromString(const char* str,
83  unsigned int& characteristics, int& position, bool& mappedSubstring);
84 
85  virtual void printResults(const char* str, unsigned int characteristics, const char* additionalInformation = 0);
86 
87  protected:
88  typedef boost::unordered_map <DtString, std::pair<DtString, DtSurface::DtCharacteristics> > DtSurfaceStringToCharacteristics;
89  typedef DtSurfaceStringToCharacteristics::const_iterator DtSurfStrToCharsConstIter;
90  typedef DtSurfaceStringToCharacteristics::iterator DtSurfStrToCharsIter;
91 
93  static const DtString theMatchString;
95 
96  private:
97 
103  std::set<std::string> myPrintedMessages;
104  };
105 
106 }
107 
108 //class makVrv::DtOsgRenderer::RootList;
109 
110 
113 {
114 public:
115  DtTriangleMeshWithSoil (bool use32bitIndices=true, bool use4componentVertices=true);
116  virtual ~DtTriangleMeshWithSoil();
117 
118  bool valid(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2) const;
119  bool valid(const btVector3& vertex) const;
120  bool valid(const btScalar& val) const;
121 
122  bool checkAddTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
123  bool removeDuplicateVertices = false);
124 
125  void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
126  bool removeDuplicateVertices = false);
127 
128  void addTriangleWithSurface(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,
129  const DtSurface& surface, bool removeDuplicateVertices=false);
130 
131  DtSurface triangleSurface(unsigned int triangleIndex) const;
132 
133  const btVector3& max() const;
134  const btVector3& min() const;
135 
136  bool isAabbValid() const;
137 
138 protected:
139  void updateBounds(const btVector3& val);
140 
143  void initializeSurfaceArray();
144 
147  void syncSurfaceArray();
148 
154  btAlignedObjectArray<DtSurface> mySurfaceTypes;
155  btVector3 myMin;
156  btVector3 myMax;
157 };
158 
160 {
161 public:
162  virtual ~DtBvhBuilder();
163 
166  virtual bool buildBvh() = 0;
167 };
168 
169 typedef std::list<btCollisionObject*> DtCollisionObjectList;
170 typedef std::vector<std::pair<DtTriangleMeshWithSoil*, osg::Matrix> > DtMeshTransformPairList;
171 
174 {
181 };
182 
187 {
189  : osgRenderer(r), sceneRoot(sr) {};
192 };
193 
197  DtCollisionObjectList* collObjects,
198  const DtDrawMode& drawMode,
199  osg::Node* node,
200  const osg::Matrix& baseTransform,
201  const DtFilename& surfaceCharacterFilename = "",
203  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>(),
204  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
205 
207  DtCollisionObjectList* collObjects,
208  const DtDrawMode& drawMode,
209  osg::Node* node,
210  const osg::Matrix& baseTransform,
211  const DtSurface& surface,
212  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN,
214 
218  DtCollisionObjectList* collObjects,
219  const DtDrawMode& drawMode,
220  DtVantageRootNode node,
221  const osg::Matrix& baseTransform,
222  const DtFilename& surfaceCharacterFilename = "",
224  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>(),
225  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
226 
228 
229 void getBasisAndOrigin(
230  osg::Matrix& matrix, btMatrix3x3& basisA, btVector3& origin, bool& scaled);
231 
235 template<typename T_Node>
237  T_Node node,
238  DtCollisionObjectList* collObjects,
239  const DtDrawMode& drawMode,
240  const osg::Matrix* worldMatrix = NULL,
241  const DtFilename& surfaceCharacterFilename = "",
243  const std::vector<std::string>& ignoreSurfacesMatching = std::vector<std::string>(),
244  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
245 {
246  osg::Matrix baseMatrix;
247  if (worldMatrix)
248  {
249  baseMatrix = *worldMatrix;
250  }
251 
252  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode,
253  node, baseMatrix, surfaceCharacterFilename, flags,
254  ignoreSurfacesMatching, traverseMode);
255 
256  return numTriangles;
257 }
258 
260 template<typename T_Node>
262  T_Node node,
263  DtCollisionObjectList* collObjects,
264  const DtDrawMode& drawMode,
265  const DtFilename& surfaceCharacterFilename,
266  const std::vector<std::string>& ignoreSurfacesMatching,
267  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN,
269 {
270  return createCollisionObjects(
271  node, collObjects, drawMode, NULL,
272  surfaceCharacterFilename, flags, ignoreSurfacesMatching, traverseMode);
273 }
274 
278 template<typename T_Node>
280  T_Node node,
281  DtCollisionObjectList* collObjects,
282  const DtDrawMode& drawMode,
283  const DtSurface& surface,
284  const osg::Matrix* worldMatrix = NULL,
285  osg::NodeVisitor::TraversalMode traverseMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN,
287 {
288  osg::Matrix baseMatrix;
289  if (worldMatrix)
290  {
291  baseMatrix = *worldMatrix;
292  }
293 
294  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode, node, baseMatrix, surface, traverseMode, flags);
295 
296  return numTriangles;
297 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)