2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2014 Erwin Coumans http://bulletphysics.org
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:
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.
16 #ifndef BT_COLLISION_WORLD_IMPORTER_H
17 #define BT_COLLISION_WORLD_IMPORTER_H
19 #include "LinearMath/btTransform.h"
20 #include "LinearMath/btVector3.h"
21 #include "LinearMath/btAlignedObjectArray.h"
22 #include "LinearMath/btHashMap.h"
24 class btCollisionShape;
25 class btCollisionObject;
26 struct btBulletSerializedArrays;
28 struct ConstraintInput;
29 class btCollisionWorld;
30 struct btCollisionShapeData;
31 class btTriangleIndexVertexArray;
32 class btStridingMeshInterface;
33 struct btStridingMeshInterfaceData;
34 class btGImpactMeshShape;
36 struct btTriangleInfoMap;
37 class btBvhTriangleMeshShape;
38 class btPoint2PointConstraint;
39 class btHingeConstraint;
40 class btConeTwistConstraint;
41 class btGeneric6DofConstraint;
42 class btGeneric6DofSpringConstraint;
43 class btSliderConstraint;
44 class btGearConstraint;
45 struct btContactSolverInfo;
47 class btCollisionWorldImporter
50 btCollisionWorld* m_collisionWorld;
54 btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
55 btAlignedObjectArray<btCollisionObject*> m_allocatedRigidBodies;
57 btAlignedObjectArray<btOptimizedBvh*> m_allocatedBvhs;
58 btAlignedObjectArray<btTriangleInfoMap*> m_allocatedTriangleInfoMaps;
59 btAlignedObjectArray<btTriangleIndexVertexArray*> m_allocatedTriangleIndexArrays;
60 btAlignedObjectArray<btStridingMeshInterfaceData*> m_allocatedbtStridingMeshInterfaceDatas;
61 btAlignedObjectArray<btCollisionObject*> m_allocatedCollisionObjects;
63 btAlignedObjectArray<char*> m_allocatedNames;
65 btAlignedObjectArray<int*> m_indexArrays;
66 btAlignedObjectArray<short int*> m_shortIndexArrays;
67 btAlignedObjectArray<unsigned char*> m_charIndexArrays;
69 btAlignedObjectArray<btVector3FloatData*> m_floatVertexArrays;
70 btAlignedObjectArray<btVector3DoubleData*> m_doubleVertexArrays;
72 btHashMap<btHashPtr, btOptimizedBvh*> m_bvhMap;
73 btHashMap<btHashPtr, btTriangleInfoMap*> m_timMap;
75 btHashMap<btHashString, btCollisionShape*> m_nameShapeMap;
76 btHashMap<btHashString, btCollisionObject*> m_nameColObjMap;
78 btHashMap<btHashPtr, const char*> m_objectNameMap;
80 btHashMap<btHashPtr, btCollisionShape*> m_shapeMap;
81 btHashMap<btHashPtr, btCollisionObject*> m_bodyMap;
85 char* duplicateName(const char* name);
87 btCollisionShape* convertCollisionShape(btCollisionShapeData* shapeData);
90 btCollisionWorldImporter(btCollisionWorld* world);
92 virtual ~btCollisionWorldImporter();
94 bool convertAllObjects(btBulletSerializedArrays* arrays);
96 ///delete all memory collision shapes, rigid bodies, constraints etc. allocated during the load.
97 ///make sure you don't use the dynamics world containing objects after you call this method
98 virtual void deleteAllData();
100 void setVerboseMode(int verboseMode)
102 m_verboseMode = verboseMode;
105 int getVerboseMode() const
107 return m_verboseMode;
111 int getNumCollisionShapes() const;
112 btCollisionShape* getCollisionShapeByIndex(int index);
113 int getNumRigidBodies() const;
114 btCollisionObject* getRigidBodyByIndex(int index) const;
116 int getNumBvhs() const;
117 btOptimizedBvh* getBvhByIndex(int index) const;
118 int getNumTriangleInfoMaps() const;
119 btTriangleInfoMap* getTriangleInfoMapByIndex(int index) const;
121 // queris involving named objects
122 btCollisionShape* getCollisionShapeByName(const char* name);
123 btCollisionObject* getCollisionObjectByName(const char* name);
125 const char* getNameForPointer(const void* ptr) const;
127 ///those virtuals are called by load and can be overridden by the user
131 virtual btCollisionObject* createCollisionObject(const btTransform& startTransform, btCollisionShape* shape, const char* bodyName);
135 virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal, btScalar planeConstant);
136 virtual btCollisionShape* createBoxShape(const btVector3& halfExtents);
137 virtual btCollisionShape* createSphereShape(btScalar radius);
138 virtual btCollisionShape* createCapsuleShapeX(btScalar radius, btScalar height);
139 virtual btCollisionShape* createCapsuleShapeY(btScalar radius, btScalar height);
140 virtual btCollisionShape* createCapsuleShapeZ(btScalar radius, btScalar height);
142 virtual btCollisionShape* createCylinderShapeX(btScalar radius, btScalar height);
143 virtual btCollisionShape* createCylinderShapeY(btScalar radius, btScalar height);
144 virtual btCollisionShape* createCylinderShapeZ(btScalar radius, btScalar height);
145 virtual btCollisionShape* createConeShapeX(btScalar radius, btScalar height);
146 virtual btCollisionShape* createConeShapeY(btScalar radius, btScalar height);
147 virtual btCollisionShape* createConeShapeZ(btScalar radius, btScalar height);
148 virtual class btTriangleIndexVertexArray* createTriangleMeshContainer();
149 virtual btBvhTriangleMeshShape* createBvhTriangleMeshShape(btStridingMeshInterface* trimesh, btOptimizedBvh* bvh);
150 virtual btCollisionShape* createConvexTriangleMeshShape(btStridingMeshInterface* trimesh);
151 #ifdef SUPPORT_GIMPACT_SHAPE_IMPORT
152 virtual btGImpactMeshShape* createGimpactShape(btStridingMeshInterface* trimesh);
153 #endif //SUPPORT_GIMPACT_SHAPE_IMPORT
154 virtual btStridingMeshInterfaceData* createStridingMeshInterfaceData(btStridingMeshInterfaceData* interfaceData);
156 virtual class btConvexHullShape* createConvexHullShape();
157 virtual class btCompoundShape* createCompoundShape();
158 virtual class btScaledBvhTriangleMeshShape* createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape, const btVector3& localScalingbtBvhTriangleMeshShape);
160 virtual class btMultiSphereShape* createMultiSphereShape(const btVector3* positions, const btScalar* radi, int numSpheres);
162 virtual btTriangleIndexVertexArray* createMeshInterface(btStridingMeshInterfaceData& meshData);
164 ///acceleration and connectivity structures
165 virtual btOptimizedBvh* createOptimizedBvh();
166 virtual btTriangleInfoMap* createTriangleInfoMap();
169 #endif //BT_WORLD_IMPORTER_H