Add BulletWorldImporter: it takes the in-memory data from BulletFileLoader and instantiates objects in a BulletDynamicsWorld.

Note that BulletFileLoader is has no dependencies on BulletDynamics/BulletCollision.
Also added a custom build step to copy asset (.bullet and .obj file) into the executable folder
Made a few 'char*' 'const char*' to avoid compiler warnings
This commit is contained in:
erwin.coumans
2010-01-25 21:58:32 +00:00
parent b68f2710cd
commit a7a6ab8835
13 changed files with 76 additions and 187 deletions

View File

@@ -14,6 +14,4 @@ bFile.cpp
bFile.h
btBulletFile.cpp
btBulletFile.h
btBulletFileLoader.cpp
btBulletFileLoader.h
)

View File

@@ -64,7 +64,7 @@ int ChunkUtils::getOffset(int flags)
// ----------------------------------------------------- //
int ChunkUtils::getNextBlock(bChunkInd *dataChunk, char *dataPtr, const int flags)
int ChunkUtils::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int flags)
{
bool swap = false;
bool varies = false;

View File

@@ -65,7 +65,7 @@ namespace bParse {
{
public:
// buffer offset util
static int getNextBlock(bChunkInd *dataChunk, char *dataPtr, const int flags);
static int getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int flags);
// file chunk offset
static int getOffset(int flags);

View File

@@ -0,0 +1,10 @@
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
)
ADD_LIBRARY(
BulletWorldImporter
btBulletWorldImporter.cpp
btBulletWorldImporter.h
)

View File

@@ -1,17 +1,17 @@
#include "btBulletFileLoader.h"
#include "btBulletWorldImporter.h"
#include "btBulletFile.h"
#include "btBulletDynamicsCommon.h"
btBulletFileLoader::btBulletFileLoader(btDynamicsWorld* world)
btBulletWorldImporter::btBulletWorldImporter(btDynamicsWorld* world)
:m_dynamicsWorld(world),
m_verboseDumpAllTypes(false)
{
}
bool btBulletFileLoader::loadFileFromMemory( char* fileName)
bool btBulletWorldImporter::loadFileFromMemory( const char* fileName)
{
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
@@ -25,7 +25,7 @@ bool btBulletFileLoader::loadFileFromMemory( char* fileName)
bool btBulletFileLoader::loadFileFromMemory( char* memoryBuffer, int len)
bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len)
{
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(memoryBuffer,len);
@@ -37,7 +37,7 @@ bool btBulletFileLoader::loadFileFromMemory( char* memoryBuffer, int len)
}
bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
{
@@ -270,7 +270,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
return false;
}
btTypedConstraint* btBulletFileLoader::createUniversalD6Constraint(class btRigidBody* body0,class btRigidBody* otherBody,
btTypedConstraint* btBulletWorldImporter::createUniversalD6Constraint(class btRigidBody* body0,class btRigidBody* otherBody,
btTransform& localAttachmentFrameRef,
btTransform& localAttachmentOther,
const btVector3& linearMinLimits,
@@ -282,7 +282,7 @@ btTypedConstraint* btBulletFileLoader::createUniversalD6Constraint(class btRig
return 0;
}
btRigidBody* btBulletFileLoader::createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform,btCollisionShape* shape)
btRigidBody* btBulletWorldImporter::createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform,btCollisionShape* shape)
{
btVector3 localInertia;
@@ -297,52 +297,52 @@ btRigidBody* btBulletFileLoader::createRigidBody(bool isDynamic, btScalar mass,
return body;
}
btCollisionShape* btBulletFileLoader::createPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
btCollisionShape* btBulletWorldImporter::createPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
{
return 0;
}
btCollisionShape* btBulletFileLoader::createBoxShape(const btVector3& halfExtents)
btCollisionShape* btBulletWorldImporter::createBoxShape(const btVector3& halfExtents)
{
return new btBoxShape(halfExtents);
}
btCollisionShape* btBulletFileLoader::createSphereShape(btScalar radius)
btCollisionShape* btBulletWorldImporter::createSphereShape(btScalar radius)
{
return new btSphereShape(radius);
}
btCollisionShape* btBulletFileLoader::createCapsuleShape(btScalar radius, btScalar height)
btCollisionShape* btBulletWorldImporter::createCapsuleShape(btScalar radius, btScalar height)
{
return new btCapsuleShape(radius,height);
}
btCollisionShape* btBulletFileLoader::createCylinderShapeY(btScalar radius,btScalar height)
btCollisionShape* btBulletWorldImporter::createCylinderShapeY(btScalar radius,btScalar height)
{
return new btCylinderShape(btVector3(radius,height,radius));
}
btTriangleMesh* btBulletFileLoader::createTriangleMeshContainer()
btTriangleMesh* btBulletWorldImporter::createTriangleMeshContainer()
{
return 0;
}
btCollisionShape* btBulletFileLoader::createBvhTriangleMeshShape(btTriangleMesh* trimesh)
btCollisionShape* btBulletWorldImporter::createBvhTriangleMeshShape(btTriangleMesh* trimesh)
{
return 0;
}
btCollisionShape* btBulletFileLoader::createConvexTriangleMeshShape(btTriangleMesh* trimesh)
btCollisionShape* btBulletWorldImporter::createConvexTriangleMeshShape(btTriangleMesh* trimesh)
{
return 0;
}
btCollisionShape* btBulletFileLoader::createGimpactShape(btTriangleMesh* trimesh)
btCollisionShape* btBulletWorldImporter::createGimpactShape(btTriangleMesh* trimesh)
{
return 0;
}
btConvexHullShape* btBulletFileLoader::createConvexHullShape()
btConvexHullShape* btBulletWorldImporter::createConvexHullShape()
{
return 0;
}
btCompoundShape* btBulletFileLoader::createCompoundShape()
btCompoundShape* btBulletWorldImporter::createCompoundShape()
{
return 0;
}

View File

@@ -14,8 +14,8 @@ subject to the following restrictions:
*/
#ifndef BULLET_FILE_LOADER_H
#define BULLET_FILE_LOADER_H
#ifndef BULLET_WORLD_IMPORTER_H
#define BULLET_WORLD_IMPORTER_H
#include "LinearMath/btTransform.h"
#include "LinearMath/btVector3.h"
@@ -36,7 +36,7 @@ namespace bParse
};
class btBulletFileLoader
class btBulletWorldImporter
{
btDynamicsWorld* m_dynamicsWorld;
@@ -44,10 +44,11 @@ class btBulletFileLoader
public:
btBulletFileLoader(btDynamicsWorld* world);
btBulletWorldImporter(btDynamicsWorld* world);
bool loadFileFromMemory(char* fileName);
bool loadFileFromMemory(const char* fileName);
///the memoryBuffer might be modified (for example if endian swaps are necessary)
bool loadFileFromMemory(char *memoryBuffer, int len);
bool loadFileFromMemory(bParse::btBulletFile* file);
@@ -93,4 +94,4 @@ public:
};
#endif //BULLET_FILE_LOADER_H
#endif //BULLET_WORLD_IMPORTER_H

View File

@@ -1,9 +1,9 @@
SUBDIRS ( BulletFileLoader )
SUBDIRS ( BulletFileLoader BulletWorldImporter )
# makesdna and HeaderGenerator are for advanced use only
# makesdna can re-generate the binary DNA representing the Bullet serialization structures
# Be very careful modifying any of this, otherwise the .bullet format becomes incompatible
#SUBDIRS ( BulletFileLoader BlenderSerialize HeaderGenerator makesdna)
#SUBDIRS ( BulletFileLoader BulletWorldImporter BlenderSerialize HeaderGenerator makesdna)