VR-Forces 4.1.1 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>
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  protected:
84 
86  virtual DtSurface* createSurface();
87 
88  protected:
89  typedef boost::unordered_map <DtString, DtSurface::DtCharacteristics> DtSurfaceStringToCharacteristics;
90  typedef DtSurfaceStringToCharacteristics::const_iterator DtSurfStrToCharsConstIter;
91  typedef DtSurfaceStringToCharacteristics::iterator DtSurfStrToCharsIter;
92 
94  static const DtString theMatchString;
96 
97  private:
98 
105  std::set<std::string> myPrintedWarnings;
106 
107  };
108 
109 
110 }
111 
112 //class makVrv::DtOsgRenderer::RootList;
113 
114 
117 {
118 public:
119  DtTriangleMeshWithSoil (bool use32bitIndices=true,bool use4componentVertices=true) :
120  btTriangleMesh(use32bitIndices, use4componentVertices),
121  myUseSurfaceArray(false) {}
122  virtual ~DtTriangleMeshWithSoil();
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 protected:
132  void initializeSurfaceArray();
133 
136  void syncSurfaceArray();
137 
143  btAlignedObjectArray<DtSurface> mySurfaceTypes;
144 };
145 
146 typedef std::list<btCollisionObject*> DtCollisionObjectList;
147 typedef std::vector<std::pair<DtTriangleMeshWithSoil*, osg::Matrix> > DtMeshTransformPairList;
148 
153 {
155  : osgRenderer(r), sceneRoot(sr) {};
158 };
159 
162 int convertOsgNodeToTriangeMesh(DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, osg::Node* node,
163  const osg::Matrix& baseTransform,
164  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false,
165  bool checkGeodesForSurfaces = false);
166 
169 int convertOsgNodeToTriangeMesh(DtCollisionObjectList* collObjects, const DtDrawMode& drawMode, DtVantageRootNode node,
170  const osg::Matrix& baseTransform,
171  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false,
172  bool checkGeodesForSurfaces = false);
173 
175 
176 void getBasisAndOrigin(osg::Matrix& matrix,
177  btMatrix3x3& basisA, btVector3& origin, bool& scaled);
178 
182 template<typename T_Node>
184  T_Node node,
185  DtCollisionObjectList* collObjects, const DtDrawMode& drawMode,
186  osg::Matrix* worldMatrix = NULL,
187  const DtFilename& surfaceCharacterFilename = "", bool treatPagedLODAsLOD = false, bool checkGeodesForSurfaces = false)
188 {
189  osg::Matrix baseMatrix;
190  if (worldMatrix)
191  {
192  baseMatrix = *worldMatrix;
193  }
194 
195  int numTriangles = convertOsgNodeToTriangeMesh(collObjects, drawMode,
196  node, baseMatrix, surfaceCharacterFilename, treatPagedLODAsLOD, checkGeodesForSurfaces);
197 
198  return numTriangles;
199 }

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)