rename ObsoleteDemos back to Demos

fix some relative path issues for loading assets
This commit is contained in:
Erwin Coumans
2014-05-12 16:12:01 -07:00
parent 23a2a4f4f9
commit dc491936a2
312 changed files with 3933 additions and 322 deletions

View File

@@ -44,10 +44,10 @@ IF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
# STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
# SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
# STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
# SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
@@ -188,13 +188,13 @@ IF (USE_GLUT)
ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
IF (CMAKE_CL_64)
message("Win64 using static freeglut in ObsoleteDemos/Glut/glut64.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut64.lib glu32.lib gdi32.lib winmm.lib user32.lib)
message("Win64 using static freeglut in Demos/Glut/glut64.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Demos/Glut/glut64.lib glu32.lib gdi32.lib winmm.lib user32.lib)
ELSE(CMAKE_CL_64)
message("Win32 using static freeglut in ObsoleteDemos/Glut/glut32.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut32.lib glu32.lib gdi32.lib winmm.lib user32.lib)
message("Win32 using static freeglut in Demos/Glut/glut32.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Demos/Glut/glut32.lib glu32.lib gdi32.lib winmm.lib user32.lib)
ENDIF (CMAKE_CL_64)
SET(GLUT_INCLUDE_DIR ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut )
SET(GLUT_INCLUDE_DIR ${BULLET_PHYSICS_SOURCE_DIR}/Demos/Glut )
ELSE()
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
@@ -219,8 +219,8 @@ IF (USE_GLUT)
ENDIF(USE_GLUT)
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos)
SUBDIRS(ObsoleteDemos)
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos)
SUBDIRS(Demos)
ENDIF()
ENDIF(BUILD_OBSOLETE_DEMOS)
@@ -232,6 +232,10 @@ IF(BUILD_BULLET3_DEMOS)
ENDIF()
ENDIF(BUILD_BULLET3_DEMOS)
OPTION(BUILD_EXTRAS "Set when you want to build the extras" ON)
IF(BUILD_EXTRAS)
SUBDIRS(Extras)
ENDIF(BUILD_EXTRAS)
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
@@ -266,9 +270,9 @@ IF(INSTALL_LIBS)
ENDIF(INSTALL_LIBS)
#INSTALL of other files requires CMake 2.6
#IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
# OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
#ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" ON)

View File

@@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
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.
@@ -60,7 +60,7 @@ public:
{
///perhaps we can do something special with entities (isEntity)
///like adding a collision Triggering (as example)
if (vertices.size() > 0)
{
float mass = 0.f;
@@ -69,7 +69,7 @@ public:
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,0,-10.f));
//this create an internal copy of the vertices
btCollisionShape* shape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
m_demoApp->m_collisionShapes.push_back(shape);
@@ -134,7 +134,7 @@ BspDemo::~BspDemo()
void BspDemo::initPhysics()
{
const char* bspfilename = "BspDemo.bsp";
initPhysics(bspfilename);
}
@@ -144,7 +144,7 @@ void BspDemo::initPhysics(const char* bspfilename)
{
setTexturing(true);
setShadows(false);
m_cameraUp = btVector3(0,0,1);
m_forwardAxis = 1;
@@ -170,31 +170,23 @@ void BspDemo::initPhysics(const char* bspfilename)
#ifdef QUAKE_BSP_IMPORTING
void* memoryBuffer = 0;
FILE* file = fopen(bspfilename,"r");
if (!file)
{
//try again other path,
//sight... visual studio leaves the current working directory in the projectfiles folder
//instead of executable folder. who wants this default behaviour?!?
bspfilename = "../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//try again other path, cmake needs 4 levels deep back...
bspfilename = "../../../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//try again other path,
//sight... visual studio leaves the current working directory in the projectfiles folder
//instead of executable folder. who wants this default behaviour?!?
bspfilename = "BspDemo.bsp";
file = fopen(bspfilename,"r");
}
const char* filename = "BspDemo.bsp";
const char* prefix[]={"./","../","../../","../../../","../../../../", "BspDemo/", "Demos/BspDemo/",
"../Demos/BspDemo/","../../Demos/BspDemo/"};
int numPrefixes = sizeof(prefix)/sizeof(const char*);
char relativeFileName[1024];
FILE* file=0;
for (int i=0;i<numPrefixes;i++)
{
sprintf(relativeFileName,"%s%s",prefix[i],filename);
file = fopen(relativeFileName,"r");
if (file)
break;
}
if (file)
{
@@ -229,9 +221,9 @@ void BspDemo::initPhysics(const char* bspfilename)
void BspDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
m_dynamicsWorld->stepSimulation(dt);
//optional but useful: debug drawing
@@ -248,7 +240,7 @@ void BspDemo::clientMoveAndDisplay()
void BspDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
@@ -295,7 +287,7 @@ char* makeExeToBspFilename(const char* lpCmdLine)
// If we hit a null or a quote, stop copying. This will get just the first filename.
if(i && (in[0] == '.') && (in[1] == 'e') && (in[2] == 'x') && (in[3] == 'e'))
break;
// If we hit a null or a quote, stop copying. This will get just the first filename.
if(*in == '\0' || *in == '\"')
break;
@@ -316,6 +308,6 @@ char* makeExeToBspFilename(const char* lpCmdLine)
*(out++) = 's';
*(out++) = 'p';
*(out++) = 0;
return cleaned_filename;
}

View File

@@ -35,7 +35,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppBspPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/BspDemo/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BspDemo/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
@@ -43,4 +43,4 @@ IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@@ -4,8 +4,8 @@ Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
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.
@@ -38,16 +38,36 @@ void BulletXmlImportDemo::initPhysics()
setTexturing(true);
setShadows(true);
setupEmptyDynamicsWorld();
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
btBulletXmlWorldImporter* importer = new btBulletXmlWorldImporter(m_dynamicsWorld);
importer->loadFile("bullet_basic.xml");
static const char* filename = "bullet_basic.xml";
const char* prefix[]={"./","../","../../","../../../","../../../../", "BulletXmlImportDemo/", "Demos/BulletXmlImportDemo/",
"../Demos/BulletXmlImportDemo/","../../Demos/BulletXmlImportDemo/"};
int numPrefixes = sizeof(prefix)/sizeof(const char*);
char relativeFileName[1024];
bool fileFound = false;
for (int i=0;i<numPrefixes;i++)
{
sprintf(relativeFileName,"%s%s",prefix[i],filename);
FILE* f = fopen(relativeFileName,"r");
if (f)
{
fclose(f);
fileFound = true;
break;
}
}
importer->loadFile(relativeFileName);
// importer->loadFile("bulletser.xml");
// importer->loadFile("bullet_constraints.xml");
@@ -55,21 +75,21 @@ void BulletXmlImportDemo::initPhysics()
void BulletXmlImportDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//simple dynamics world doesn't handle fixed-time-stepping
float ms = getDeltaTimeMicroseconds();
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
m_dynamicsWorld->debugDrawWorld();
}
renderme();
renderme();
glFlush();
@@ -81,8 +101,8 @@ void BulletXmlImportDemo::clientMoveAndDisplay()
void BulletXmlImportDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
@@ -105,7 +125,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher);
m_broadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
@@ -113,7 +133,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
//btGImpactCollisionAlgorithm::registerAlgorithm((btCollisionDispatcher*)m_dynamicsWorld->getDispatcher());
}
@@ -123,7 +143,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
BulletXmlImportDemo::~BulletXmlImportDemo()
{
m_fileLoader->deleteAllData();
delete m_fileLoader;
delete m_fileLoader;
exitPhysics();
}
@@ -163,16 +183,16 @@ void BulletXmlImportDemo::exitPhysics()
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@@ -5,9 +5,9 @@ SUBDIRS( HelloWorld )
IF (USE_GLUT)
IF (GLUT_FOUND)
IF(BUILD_CPU_DEMOS)
# IF(BUILD_EXTRAS)
# SUBDIRS( BulletXmlImportDemo ConcaveDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo )
# ENDIF()
IF(BUILD_EXTRAS)
SUBDIRS( BulletXmlImportDemo ConcaveDemo ConvexDecompositionDemo SerializeDemo )
ENDIF()
SET(SharedDemoSubdirs
OpenGL
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer

View File

@@ -46,7 +46,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppCharacterDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/BspDemo/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BspDemo/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)

View File

@@ -69,11 +69,11 @@ void CharacterDemo::initPhysics()
m_constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);
m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
#ifdef DYNAMIC_CHARACTER_CONTROLLER
m_character = new DynamicCharacterController ();
#else
btTransform startTransform;
startTransform.setIdentity ();
//startTransform.setOrigin (btVector3(0.0, 4.0, 0.0));
@@ -101,35 +101,30 @@ void CharacterDemo::initPhysics()
btTransform tr;
tr.setIdentity();
const char* bspfilename = "BspDemo.bsp";
const char* filename = "BspDemo.bsp";
const char* prefix[]={"./","../","../../","../../../","../../../../", "BspDemo/", "Demos/BspDemo/",
"../Demos/BspDemo/","../../Demos/BspDemo/"};
int numPrefixes = sizeof(prefix)/sizeof(const char*);
char relativeFileName[1024];
FILE* file=0;
for (int i=0;i<numPrefixes;i++)
{
sprintf(relativeFileName,"%s%s",prefix[i],filename);
file = fopen(relativeFileName,"r");
if (file)
break;
}
void* memoryBuffer = 0;
FILE* file = fopen(bspfilename,"r");
if (!file)
{
//cmake generated visual studio projects need 4 levels back
bspfilename = "../../../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//visual studio leaves the current working directory in the projectfiles folder
bspfilename = "../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//visual studio leaves the current working directory in the projectfiles folder
bspfilename = "BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (file)
{
BspLoader bspLoader;
int size=0;
if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */
printf("Error: cannot get filesize from %s\n", bspfilename);
printf("Error: cannot get filesize from %s\n", filename);
} else
{
//how to detect file size?
@@ -183,7 +178,7 @@ void CharacterDemo::debugDrawContacts()
manifoldArray.clear();
const btBroadphasePair& pair = pairArray[i];
btBroadphasePair* collisionPair = m_overlappingPairCache->getOverlappingPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
if (!collisionPair)
continue;
@@ -217,7 +212,7 @@ void CharacterDemo::clientMoveAndDisplay()
/* Character stuff &*/
if (m_character)
{
}
debugDrawContacts();
@@ -265,7 +260,7 @@ void CharacterDemo::clientMoveAndDisplay()
walkDirection += forwardDir;
if (gBackward)
walkDirection -= forwardDir;
walkDirection -= forwardDir;
m_character->setWalkDirection(walkDirection*walkSpeed);
@@ -344,7 +339,7 @@ void CharacterDemo::clientResetScene()
m_character->reset (m_dynamicsWorld);
///WTF
m_character->warp (btVector3(10.210001,-2.0306311,16.576973));
}
void CharacterDemo::specialKeyboardUp(int key, int x, int y)
@@ -444,7 +439,7 @@ void CharacterDemo::updateCamera()
m_cameraTargetPosition = characterWorldTrans.getOrigin();
m_cameraPosition = m_cameraTargetPosition + up * 10.0 + backward * 12.0;
//use the convex sweep test to find a safe position for the camera (not blocked by static geometry)
btSphereShape cameraSphere(0.2f);
btTransform cameraFrom,cameraTo;
@@ -452,10 +447,10 @@ void CharacterDemo::updateCamera()
cameraFrom.setOrigin(characterWorldTrans.getOrigin());
cameraTo.setIdentity();
cameraTo.setOrigin(m_cameraPosition);
btCollisionWorld::ClosestConvexResultCallback cb( characterWorldTrans.getOrigin(), cameraTo.getOrigin() );
cb.m_collisionFilterMask = btBroadphaseProxy::StaticFilter;
m_dynamicsWorld->convexSweepTest(&cameraSphere,cameraFrom,cameraTo,cb);
if (cb.hasHit())
{

View File

@@ -1,3 +1,4 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
@@ -53,7 +54,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
TARGET AppConvexDecompositionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFile.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/file.obj ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/ConvexDecompositionDemo/file.obj ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)

View File

@@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
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.
@@ -178,23 +178,22 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
ConvexDecomposition::WavefrontObj wo;
tcount = wo.loadObj(filename);
tcount = 0;
const char* prefix[]={"./","../","../../","../../../","../../../../", "ConvexDecompositionDemo/", "Demos/ConvexDecompositionDemo/",
"../Demos/ConvexDecompositionDemo/","../../Demos/ConvexDecompositionDemo/"};
int numPrefixes = sizeof(prefix)/sizeof(const char*);
char relativeFileName[1024];
for (int i=0;i<numPrefixes;i++)
{
sprintf(relativeFileName,"%s%s",prefix[i],filename);
tcount = wo.loadObj(relativeFileName);
if (tcount)
break;
}
if (!tcount)
{
//when running this app from visual studio, the default starting folder is different, so make a second attempt...
tcount = wo.loadObj("../../file.obj");
}
if (!tcount)
{
//cmake generated msvc files need 4 levels deep back... so make a 3rd attempt...
tcount = wo.loadObj("../../../../file.obj");
}
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-4.5,0));
@@ -206,7 +205,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
{
ConvexDecompositionDemo* m_convexDemo;
public:
btAlignedObjectArray<btConvexHullShape*> m_convexShapes;
@@ -220,7 +219,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
{
}
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
{
@@ -256,7 +255,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btVector3 vertex(result.mHullVertices[i*3],result.mHullVertices[i*3+1],result.mHullVertices[i*3+2]);
vertex *= localScaling;
centroid += vertex;
}
}
@@ -273,8 +272,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
vertices.push_back(vertex);
}
}
if ( 1 )
{
@@ -292,7 +291,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
vertex0 -= centroid;
vertex1 -= centroid;
vertex2 -= centroid;
@@ -303,20 +302,20 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
index0+=mBaseCount;
index1+=mBaseCount;
index2+=mBaseCount;
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
}
}
// float mass = 1.f;
//this is a tools issue: due to collision margin, convex objects overlap, compensate for it here:
//#define SHRINK_OBJECT_INWARDS 1
#ifdef SHRINK_OBJECT_INWARDS
float collisionMargin = 0.01f;
btAlignedObjectArray<btVector3> planeEquations;
btGeometryUtil::getPlaneEquationsFromVertices(vertices,planeEquations);
@@ -330,13 +329,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btAlignedObjectArray<btVector3> shiftedVertices;
btGeometryUtil::getVerticesFromPlaneEquations(shiftedPlaneEquations,shiftedVertices);
btConvexHullShape* convexShape = new btConvexHullShape(&(shiftedVertices[0].getX()),shiftedVertices.size());
#else //SHRINK_OBJECT_INWARDS
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
#endif
#endif
if (sEnableSAT)
convexShape->initializePolyhedralFeatures();
convexShape->setMargin(0.01f);
@@ -361,7 +360,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
m_trimeshes.push_back(trimesh);
btVector3 localScaling(6.f,6.f,6.f);
int i;
for ( i=0;i<wo.mTriCount;i++)
{
@@ -372,7 +371,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btVector3 vertex0(wo.mVertices[index0*3], wo.mVertices[index0*3+1],wo.mVertices[index0*3+2]);
btVector3 vertex1(wo.mVertices[index1*3], wo.mVertices[index1*3+1],wo.mVertices[index1*3+2]);
btVector3 vertex2(wo.mVertices[index2*3], wo.mVertices[index2*3+1],wo.mVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
@@ -380,13 +379,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
trimesh->addTriangle(vertex0,vertex1,vertex2);
}
btConvexShape* tmpConvexShape = new btConvexTriangleMeshShape(trimesh);
printf("old numTriangles= %d\n",wo.mTriCount);
printf("old numIndices = %d\n",wo.mTriCount*3);
printf("old numVertices = %d\n",wo.mVertexCount);
printf("reducing vertices by creating a convex hull\n");
//create a hull approximation
@@ -394,18 +393,18 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btScalar margin = tmpConvexShape->getMargin();
hull->buildHull(margin);
tmpConvexShape->setUserPointer(hull);
printf("new numTriangles = %d\n", hull->numTriangles ());
printf("new numIndices = %d\n", hull->numIndices ());
printf("new numVertices = %d\n", hull->numVertices ());
btConvexHullShape* convexShape = new btConvexHullShape();
bool updateLocalAabb = false;
for (i=0;i<hull->numVertices();i++)
{
convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb);
convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb);
}
convexShape->recalcLocalAabb();
@@ -419,13 +418,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
m_collisionShapes.push_back(convexShape);
float mass = 1.f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,2,14));
localCreateRigidBody(mass, startTransform,convexShape);
bool useQuantization = true;
btCollisionShape* concaveShape = new btBvhTriangleMeshShape(trimesh,useQuantization);
startTransform.setOrigin(convexDecompositionObjectOffset);
@@ -434,7 +433,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
m_collisionShapes.push_back (concaveShape);
}
if (tcount)
{
@@ -445,11 +444,11 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
char outputFileName[512];
strcpy(outputFileName,filename);
char *dot = strstr(outputFileName,".");
if ( dot )
if ( dot )
*dot = 0;
strcat(outputFileName,"_convex.obj");
FILE* outputFile = fopen(outputFileName,"wb");
unsigned int depth = 5;
float cpercent = 5;
float ppercent = 15;
@@ -479,7 +478,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
std::vector< HACD::Vec3<HACD::Real> > points;
std::vector< HACD::Vec3<long> > triangles;
for(int i=0; i<wo.mVertexCount; i++ )
for(int i=0; i<wo.mVertexCount; i++ )
{
int index = i*3;
HACD::Vec3<HACD::Real> vertex(wo.mVertices[index], wo.mVertices[index+1],wo.mVertices[index+2]);
@@ -509,17 +508,17 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
bool invert = false;
bool addExtraDistPoints = false;
bool addNeighboursDistPoints = false;
bool addFacesPoints = false;
bool addFacesPoints = false;
myHACD.SetNClusters(nClusters); // minimum number of clusters
myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull
myHACD.SetConcavity(concavity); // maximum concavity
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
myHACD.SetAddFacesPoints(addFacesPoints);
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
myHACD.SetAddFacesPoints(addFacesPoints);
myHACD.Compute();
nClusters = myHACD.GetNClusters();
nClusters = myHACD.GetNClusters();
myHACD.Save("output.wrl", false);
@@ -529,7 +528,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
// ConvexBuilder cb(desc.mCallback);
// cb.process(desc);
//now create some bodies
if (1)
{
btCompoundShape* compound = new btCompoundShape();
@@ -546,7 +545,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
float* vertices = new float[nPoints*3];
unsigned int* triangles = new unsigned int[nTriangles*3];
HACD::Vec3<HACD::Real> * pointsCH = new HACD::Vec3<HACD::Real>[nPoints];
HACD::Vec3<long> * trianglesCH = new HACD::Vec3<long>[nTriangles];
myHACD.GetCH(c, pointsCH, trianglesCH);
@@ -585,7 +584,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
}
/* for (int i=0;i<convexDecomposition.m_convexShapes.size();i++)
{
btVector3 centroid = convexDecomposition.m_convexCentroids[i];
trans.setOrigin(centroid);
btConvexHullShape* convexShape = convexDecomposition.m_convexShapes[i];
@@ -613,7 +612,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
#endif
}
if (outputFile)
fclose(outputFile);
@@ -623,13 +622,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
#ifdef TEST_SERIALIZATION
//test serializing this
//test serializing this
int maxSerializeBufferSize = 1024*1024*5;
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
m_dynamicsWorld->serialize(serializer);
FILE* f2 = fopen("testFile.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2);
fclose(f2);
@@ -651,17 +650,17 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
//fileLoader->loadFile("testFile64Double.bullet");
//fileLoader->loadFile("testFile64Single.bullet");
//fileLoader->loadFile("testFile32Single.bullet");
#endif //TEST_SERIALIZATION
}
void ConvexDecompositionDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
@@ -681,7 +680,7 @@ void ConvexDecompositionDemo::clientMoveAndDisplay()
void ConvexDecompositionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (m_dynamicsWorld)
@@ -749,7 +748,7 @@ void ConvexDecompositionDemo::exitPhysics()
delete m_collisionConfiguration;
}
@@ -768,7 +767,7 @@ void ConvexDecompositionDemo::keyboardCallback(unsigned char key, int x, int y)
{
printf("SAT enabled after the next restart of the demo\n");
} else
{
{
printf("SAT disabled after the next restart of the demo\n");
}
} else
@@ -776,4 +775,4 @@ void ConvexDecompositionDemo::keyboardCallback(unsigned char key, int x, int y)
PlatformDemoApplication::keyboardCallback(key,x,y);
}
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More