Bullet Collision Detection & Physics Library: btCollisionWorldImporter.h Source File

Bullet Collision Detection & Physics Library

btCollisionWorldImporter.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2014 Erwin Coumans http://bulletphysics.org
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16
17 #ifndef BT_COLLISION_WORLD_IMPORTER_H
18 #define BT_COLLISION_WORLD_IMPORTER_H
19
20 #include "LinearMath/btTransform.h"
21 #include "LinearMath/btVector3.h"
22 #include "LinearMath/btAlignedObjectArray.h"
23 #include "LinearMath/btHashMap.h"
24
25 class btCollisionShape;
26 class btCollisionObject;
27 struct btBulletSerializedArrays;
28
29
30 struct ConstraintInput;
31 class btCollisionWorld;
32 struct btCollisionShapeData;
33 class btTriangleIndexVertexArray;
34 class btStridingMeshInterface;
35 struct btStridingMeshInterfaceData;
36 class btGImpactMeshShape;
37 class btOptimizedBvh;
38 struct btTriangleInfoMap;
39 class btBvhTriangleMeshShape;
40 class btPoint2PointConstraint;
41 class btHingeConstraint;
42 class btConeTwistConstraint;
43 class btGeneric6DofConstraint;
44 class btGeneric6DofSpringConstraint;
45 class btSliderConstraint;
46 class btGearConstraint;
47 struct btContactSolverInfo;
48
49
50
51
52 class btCollisionWorldImporter
53 {
54 protected:
55 btCollisionWorld* m_collisionWorld;
56
57 int m_verboseMode;
58
59 btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
60 btAlignedObjectArray<btCollisionObject*> m_allocatedRigidBodies;
61
62 btAlignedObjectArray<btOptimizedBvh*> m_allocatedBvhs;
63 btAlignedObjectArray<btTriangleInfoMap*> m_allocatedTriangleInfoMaps;
64 btAlignedObjectArray<btTriangleIndexVertexArray*> m_allocatedTriangleIndexArrays;
65 btAlignedObjectArray<btStridingMeshInterfaceData*> m_allocatedbtStridingMeshInterfaceDatas;
66 btAlignedObjectArray<btCollisionObject*> m_allocatedCollisionObjects;
67
68
69 btAlignedObjectArray<char*> m_allocatedNames;
70
71 btAlignedObjectArray<int*> m_indexArrays;
72 btAlignedObjectArray<short int*> m_shortIndexArrays;
73 btAlignedObjectArray<unsigned char*> m_charIndexArrays;
74
75 btAlignedObjectArray<btVector3FloatData*> m_floatVertexArrays;
76 btAlignedObjectArray<btVector3DoubleData*> m_doubleVertexArrays;
77
78
79 btHashMap<btHashPtr,btOptimizedBvh*> m_bvhMap;
80 btHashMap<btHashPtr,btTriangleInfoMap*> m_timMap;
81
82 btHashMap<btHashString,btCollisionShape*> m_nameShapeMap;
83 btHashMap<btHashString,btCollisionObject*> m_nameColObjMap;
84
85 btHashMap<btHashPtr,const char*> m_objectNameMap;
86
87 btHashMap<btHashPtr,btCollisionShape*> m_shapeMap;
88 btHashMap<btHashPtr,btCollisionObject*> m_bodyMap;
89
90
91 //methods
92
93
94
95 char* duplicateName(const char* name);
96
97 btCollisionShape* convertCollisionShape( btCollisionShapeData* shapeData );
98
99
100 public:
101
102 btCollisionWorldImporter(btCollisionWorld* world);
103
104 virtual ~btCollisionWorldImporter();
105
106 bool convertAllObjects( btBulletSerializedArrays* arrays);
107
110 virtual void deleteAllData();
111
112 void setVerboseMode(int verboseMode)
113 {
114 m_verboseMode = verboseMode;
115 }
116
117 int getVerboseMode() const
118 {
119 return m_verboseMode;
120 }
121
122 // query for data
123 int getNumCollisionShapes() const;
124 btCollisionShape* getCollisionShapeByIndex(int index);
125 int getNumRigidBodies() const;
126 btCollisionObject* getRigidBodyByIndex(int index) const;
127 int getNumConstraints() const;
128
129 int getNumBvhs() const;
130 btOptimizedBvh* getBvhByIndex(int index) const;
131 int getNumTriangleInfoMaps() const;
132 btTriangleInfoMap* getTriangleInfoMapByIndex(int index) const;
133
134 // queris involving named objects
135 btCollisionShape* getCollisionShapeByName(const char* name);
136 btCollisionObject* getCollisionObjectByName(const char* name);
137
138
139 const char* getNameForPointer(const void* ptr) const;
140
142
143
144
145 //bodies
146
147 virtual btCollisionObject* createCollisionObject( const btTransform& startTransform, btCollisionShape* shape,const char* bodyName);
148
150
151 virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
152 virtual btCollisionShape* createBoxShape(const btVector3& halfExtents);
153 virtual btCollisionShape* createSphereShape(btScalar radius);
154 virtual btCollisionShape* createCapsuleShapeX(btScalar radius, btScalar height);
155 virtual btCollisionShape* createCapsuleShapeY(btScalar radius, btScalar height);
156 virtual btCollisionShape* createCapsuleShapeZ(btScalar radius, btScalar height);
157
158 virtual btCollisionShape* createCylinderShapeX(btScalar radius,btScalar height);
159 virtual btCollisionShape* createCylinderShapeY(btScalar radius,btScalar height);
160 virtual btCollisionShape* createCylinderShapeZ(btScalar radius,btScalar height);
161 virtual btCollisionShape* createConeShapeX(btScalar radius,btScalar height);
162 virtual btCollisionShape* createConeShapeY(btScalar radius,btScalar height);
163 virtual btCollisionShape* createConeShapeZ(btScalar radius,btScalar height);
164 virtual class btTriangleIndexVertexArray* createTriangleMeshContainer();
165 virtual btBvhTriangleMeshShape* createBvhTriangleMeshShape(btStridingMeshInterface* trimesh, btOptimizedBvh* bvh);
166 virtual btCollisionShape* createConvexTriangleMeshShape(btStridingMeshInterface* trimesh);
167 #ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
168 virtual btGImpactMeshShape* createGimpactShape(btStridingMeshInterface* trimesh);
169 #endif //SUPPORT_GIMPACT_SHAPE_IMPORT
170 virtual btStridingMeshInterfaceData* createStridingMeshInterfaceData(btStridingMeshInterfaceData* interfaceData);
171
172 virtual class btConvexHullShape* createConvexHullShape();
173 virtual class btCompoundShape* createCompoundShape();
174 virtual class btScaledBvhTriangleMeshShape* createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape,const btVector3& localScalingbtBvhTriangleMeshShape);
175
176 virtual class btMultiSphereShape* createMultiSphereShape(const btVector3* positions,const btScalar* radi,int numSpheres);
177
178 virtual btTriangleIndexVertexArray* createMeshInterface(btStridingMeshInterfaceData& meshData);
179
181 virtual btOptimizedBvh* createOptimizedBvh();
182 virtual btTriangleInfoMap* createTriangleInfoMap();
183
184
185
186
187 };
188
189
190 #endif //BT_WORLD_IMPORTER_H
btCollisionWorldImporter::getNumRigidBodies
int getNumRigidBodies() const
Definition: btCollisionWorldImporter.cpp:1117
btCollisionWorldImporter::m_allocatedTriangleIndexArrays
btAlignedObjectArray< btTriangleIndexVertexArray * > m_allocatedTriangleIndexArrays
Definition: btCollisionWorldImporter.h:64
btPoint2PointConstraint
point to point constraint between two rigidbodies each with a pivotpoint that descibes the &#39;ballsocke...
Definition: btPoint2PointConstraint.h:54
btCollisionWorldImporter::m_allocatedCollisionShapes
btAlignedObjectArray< btCollisionShape * > m_allocatedCollisionShapes
Definition: btCollisionWorldImporter.h:59
btCollisionWorldImporter::createOptimizedBvh
virtual btOptimizedBvh * createOptimizedBvh()
acceleration and connectivity structures
Definition: btCollisionWorldImporter.cpp:1011
btCollisionWorldImporter::getNumBvhs
int getNumBvhs() const
Definition: btCollisionWorldImporter.cpp:1128
btCollisionWorldImporter::m_timMap
btHashMap< btHashPtr, btTriangleInfoMap * > m_timMap
Definition: btCollisionWorldImporter.h:80
btCollisionWorldImporter::m_indexArrays
btAlignedObjectArray< int * > m_indexArrays
Definition: btCollisionWorldImporter.h:71
btCollisionWorldImporter::createCollisionObject
virtual btCollisionObject * createCollisionObject(const btTransform &startTransform, btCollisionShape *shape, const char *bodyName)
those virtuals are called by load and can be overridden by the user
Definition: btCollisionWorldImporter.cpp:901
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:53
btVector3.h
btCollisionWorldImporter::createMeshInterface
virtual btTriangleIndexVertexArray * createMeshInterface(btStridingMeshInterfaceData &meshData)
Definition: btCollisionWorldImporter.cpp:652
btCollisionWorldImporter::createCylinderShapeZ
virtual btCollisionShape * createCylinderShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:976
btCollisionWorldImporter::m_doubleVertexArrays
btAlignedObjectArray< btVector3DoubleData * > m_doubleVertexArrays
Definition: btCollisionWorldImporter.h:76
btCollisionWorldImporter::createCylinderShapeX
virtual btCollisionShape * createCylinderShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:962
btCollisionWorldImporter::duplicateName
char * duplicateName(const char *name)
Definition: btCollisionWorldImporter.cpp:628
btCollisionWorldImporter::createTriangleInfoMap
virtual btTriangleInfoMap * createTriangleInfoMap()
Definition: btCollisionWorldImporter.cpp:1019
btGearConstraint
The btGeatConstraint will couple the angular velocity for two bodies around given local axis and rati...
Definition: btGearConstraint.h:36
btMultiSphereShape
The btMultiSphereShape represents the convex hull of a collection of spheres.
Definition: btMultiSphereShape.h:28
btGeneric6DofConstraint
btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis locatio...
Definition: btGeneric6DofConstraint.h:279
btCollisionWorldImporter::createSphereShape
virtual btCollisionShape * createSphereShape(btScalar radius)
Definition: btCollisionWorldImporter.cpp:933
btCollisionWorldImporter::m_allocatedbtStridingMeshInterfaceDatas
btAlignedObjectArray< btStridingMeshInterfaceData * > m_allocatedbtStridingMeshInterfaceDatas
Definition: btCollisionWorldImporter.h:65
btCollisionWorldImporter::getNumTriangleInfoMaps
int getNumTriangleInfoMaps() const
Definition: btCollisionWorldImporter.cpp:1137
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:27
btCollisionWorldImporter::m_collisionWorld
btCollisionWorld * m_collisionWorld
Definition: btCollisionWorldImporter.h:55
btCollisionWorldImporter::createCapsuleShapeX
virtual btCollisionShape * createCapsuleShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:941
btTransform.h
btCollisionWorldImporter::createConvexHullShape
virtual class btConvexHullShape * createConvexHullShape()
Definition: btCollisionWorldImporter.cpp:1055
btGImpactMeshShape
This class manages a mesh supplied by the btStridingMeshInterface interface.
Definition: btGImpactShape.h:910
btCollisionWorldImporter::createPlaneShape
virtual btCollisionShape * createPlaneShape(const btVector3 &planeNormal, btScalar planeConstant)
shapes
Definition: btCollisionWorldImporter.cpp:921
btHingeConstraint
hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in lo...
Definition: btHingeConstraint.h:51
btCollisionWorldImporter::m_nameColObjMap
btHashMap< btHashString, btCollisionObject * > m_nameColObjMap
Definition: btCollisionWorldImporter.h:83
btCollisionWorldImporter::createBvhTriangleMeshShape
virtual btBvhTriangleMeshShape * createBvhTriangleMeshShape(btStridingMeshInterface *trimesh, btOptimizedBvh *bvh)
Definition: btCollisionWorldImporter.cpp:1026
btCollisionWorldImporter::m_bodyMap
btHashMap< btHashPtr, btCollisionObject * > m_bodyMap
Definition: btCollisionWorldImporter.h:88
btHashMap
The btHashMap template class implements a generic and lightweight hashmap.
Definition: btHashMap.h:220
btCollisionWorldImporter::m_allocatedNames
btAlignedObjectArray< char * > m_allocatedNames
Definition: btCollisionWorldImporter.h:69
btCollisionWorldImporter::getNumCollisionShapes
int getNumCollisionShapes() const
Definition: btCollisionWorldImporter.cpp:1087
btCollisionWorldImporter::m_charIndexArrays
btAlignedObjectArray< unsigned char * > m_charIndexArrays
Definition: btCollisionWorldImporter.h:73
btCollisionWorldImporter::getNameForPointer
const char * getNameForPointer(const void *ptr) const
Definition: btCollisionWorldImporter.cpp:1108
btCollisionWorldImporter::getRigidBodyByIndex
btCollisionObject * getRigidBodyByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1122
btCollisionWorldImporter::setVerboseMode
void setVerboseMode(int verboseMode)
Definition: btCollisionWorldImporter.h:112
btBvhTriangleMeshShape
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
Definition: btBvhTriangleMeshShape.h:34
btStridingMeshInterfaceData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btStridingMeshInterface.h:146
btCollisionWorldImporter::createCompoundShape
virtual class btCompoundShape * createCompoundShape()
Definition: btCollisionWorldImporter.cpp:1062
btTriangleIndexVertexArray
The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing t...
Definition: btTriangleIndexVertexArray.h:68
btCollisionWorldImporter::createCapsuleShapeZ
virtual btCollisionShape * createCapsuleShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:955
btCollisionWorldImporter::getBvhByIndex
btOptimizedBvh * getBvhByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1132
btCollisionWorldImporter::createScaledTrangleMeshShape
virtual class btScaledBvhTriangleMeshShape * createScaledTrangleMeshShape(btBvhTriangleMeshShape *meshShape, const btVector3 &localScalingbtBvhTriangleMeshShape)
Definition: btCollisionWorldImporter.cpp:1070
btCollisionWorldImporter
Definition: btCollisionWorldImporter.h:52
btCollisionWorldImporter::convertCollisionShape
btCollisionShape * convertCollisionShape(btCollisionShapeData *shapeData)
Definition: btCollisionWorldImporter.cpp:260
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btCollisionWorldImporter::m_floatVertexArrays
btAlignedObjectArray< btVector3FloatData * > m_floatVertexArrays
Definition: btCollisionWorldImporter.h:75
btOptimizedBvh
The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes, through the btStridingMeshInterface.
Definition: btOptimizedBvh.h:27
btCollisionWorldImporter::m_allocatedRigidBodies
btAlignedObjectArray< btCollisionObject * > m_allocatedRigidBodies
Definition: btCollisionWorldImporter.h:60
btCollisionWorldImporter::m_shapeMap
btHashMap< btHashPtr, btCollisionShape * > m_shapeMap
Definition: btCollisionWorldImporter.h:87
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btCollisionWorldImporter::m_nameShapeMap
btHashMap< btHashString, btCollisionShape * > m_nameShapeMap
Definition: btCollisionWorldImporter.h:82
btCollisionWorldImporter::m_allocatedCollisionObjects
btAlignedObjectArray< btCollisionObject * > m_allocatedCollisionObjects
Definition: btCollisionWorldImporter.h:66
btCollisionWorldImporter::m_objectNameMap
btHashMap< btHashPtr, const char * > m_objectNameMap
Definition: btCollisionWorldImporter.h:85
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btConeTwistConstraint
btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc) ...
Definition: btConeTwistConstraint.h:62
btContactSolverInfo
Definition: btContactSolverInfo.h:65
btStridingMeshInterface
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
Definition: btStridingMeshInterface.h:30
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btCollisionWorldImporter::getCollisionShapeByIndex
btCollisionShape * getCollisionShapeByIndex(int index)
Definition: btCollisionWorldImporter.cpp:1092
btCollisionWorldImporter::createConeShapeY
virtual btCollisionShape * createConeShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:990
btCollisionWorldImporter::createStridingMeshInterfaceData
virtual btStridingMeshInterfaceData * createStridingMeshInterfaceData(btStridingMeshInterfaceData *interfaceData)
Definition: btCollisionWorldImporter.cpp:770
btCollisionWorldImporter::m_verboseMode
int m_verboseMode
Definition: btCollisionWorldImporter.h:57
btCollisionWorldImporter::m_allocatedTriangleInfoMaps
btAlignedObjectArray< btTriangleInfoMap * > m_allocatedTriangleInfoMaps
Definition: btCollisionWorldImporter.h:63
btCollisionWorldImporter::convertAllObjects
bool convertAllObjects(btBulletSerializedArrays *arrays)
Definition: btCollisionWorldImporter.cpp:39
btCollisionWorldImporter::createMultiSphereShape
virtual class btMultiSphereShape * createMultiSphereShape(const btVector3 *positions, const btScalar *radi, int numSpheres)
Definition: btCollisionWorldImporter.cpp:1077
btCollisionWorldImporter::createBoxShape
virtual btCollisionShape * createBoxShape(const btVector3 &halfExtents)
Definition: btCollisionWorldImporter.cpp:927
btCollisionWorldImporter::createCylinderShapeY
virtual btCollisionShape * createCylinderShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:969
btCollisionWorldImporter::createTriangleMeshContainer
virtual class btTriangleIndexVertexArray * createTriangleMeshContainer()
Definition: btCollisionWorldImporter.cpp:1004
btCollisionWorldImporter::createConeShapeZ
virtual btCollisionShape * createConeShapeZ(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:997
btScaledBvhTriangleMeshShape
The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMesh...
Definition: btScaledBvhTriangleMeshShape.h:24
btCollisionWorldImporter::deleteAllData
virtual void deleteAllData()
delete all memory collision shapes, rigid bodies, constraints etc.
Definition: btCollisionWorldImporter.cpp:151
btAlignedObjectArray.h
btSliderConstraint
Definition: btSliderConstraint.h:71
btCollisionWorldImporter::m_bvhMap
btHashMap< btHashPtr, btOptimizedBvh * > m_bvhMap
Definition: btCollisionWorldImporter.h:79
btConvexHullShape
The btConvexHullShape implements an implicit convex hull of an array of vertices. ...
Definition: btConvexHullShape.h:26
btCollisionWorldImporter::getVerboseMode
int getVerboseMode() const
Definition: btCollisionWorldImporter.h:117
btCollisionWorldImporter::createConeShapeX
virtual btCollisionShape * createConeShapeX(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:983
btTriangleInfoMap
The btTriangleInfoMap stores edge angle information for some triangles. You can compute this informat...
Definition: btTriangleInfoMap.h:58
btBulletSerializedArrays
Definition: btSerializer.h:142
btCompoundShape
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
Definition: btCompoundShape.h:54
btCollisionWorldImporter::~btCollisionWorldImporter
virtual ~btCollisionWorldImporter()
Definition: btCollisionWorldImporter.cpp:31
btCollisionWorldImporter::m_shortIndexArrays
btAlignedObjectArray< short int * > m_shortIndexArrays
Definition: btCollisionWorldImporter.h:72
btCollisionWorldImporter::createCapsuleShapeY
virtual btCollisionShape * createCapsuleShapeY(btScalar radius, btScalar height)
Definition: btCollisionWorldImporter.cpp:948
btCollisionWorldImporter::getCollisionObjectByName
btCollisionObject * getCollisionObjectByName(const char *name)
Definition: btCollisionWorldImporter.cpp:891
btHashMap.h
btCollisionWorldImporter::getTriangleInfoMapByIndex
btTriangleInfoMap * getTriangleInfoMapByIndex(int index) const
Definition: btCollisionWorldImporter.cpp:1142
btGeneric6DofSpringConstraint
Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF...
Definition: btGeneric6DofSpringConstraint.h:44
btCollisionShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btCollisionShape.h:155
btCollisionWorldImporter::getCollisionShapeByName
btCollisionShape * getCollisionShapeByName(const char *name)
Definition: btCollisionWorldImporter.cpp:1097
btCollisionWorldImporter::getNumConstraints
int getNumConstraints() const
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:279
btCollisionWorldImporter::createConvexTriangleMeshShape
virtual btCollisionShape * createConvexTriangleMeshShape(btStridingMeshInterface *trimesh)
Definition: btCollisionWorldImporter.cpp:1041
btCollisionWorldImporter::btCollisionWorldImporter
btCollisionWorldImporter(btCollisionWorld *world)
Definition: btCollisionWorldImporter.cpp:24
btCollisionWorldImporter::m_allocatedBvhs
btAlignedObjectArray< btOptimizedBvh * > m_allocatedBvhs
Definition: btCollisionWorldImporter.h:62