rename ObsoleteDemos back to Demos
fix some relative path issues for loading assets
This commit is contained in:
@@ -44,10 +44,10 @@ IF(MSVC)
|
|||||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
|
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
|
||||||
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
||||||
|
|
||||||
# STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
|
||||||
# SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
|
SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
|
||||||
# STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
|
STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
|
||||||
# SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
|
SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
|
||||||
|
|
||||||
|
|
||||||
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
|
||||||
@@ -188,13 +188,13 @@ IF (USE_GLUT)
|
|||||||
ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
|
ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
|
||||||
|
|
||||||
IF (CMAKE_CL_64)
|
IF (CMAKE_CL_64)
|
||||||
message("Win64 using static freeglut in ObsoleteDemos/Glut/glut64.lib")
|
message("Win64 using static freeglut in Demos/Glut/glut64.lib")
|
||||||
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut64.lib glu32.lib gdi32.lib winmm.lib user32.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)
|
ELSE(CMAKE_CL_64)
|
||||||
message("Win32 using static freeglut in ObsoleteDemos/Glut/glut32.lib")
|
message("Win32 using static freeglut in Demos/Glut/glut32.lib")
|
||||||
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut32.lib glu32.lib gdi32.lib winmm.lib user32.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)
|
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()
|
ELSE()
|
||||||
FIND_PACKAGE(GLUT)
|
FIND_PACKAGE(GLUT)
|
||||||
IF (GLUT_FOUND)
|
IF (GLUT_FOUND)
|
||||||
@@ -219,8 +219,8 @@ IF (USE_GLUT)
|
|||||||
ENDIF(USE_GLUT)
|
ENDIF(USE_GLUT)
|
||||||
|
|
||||||
|
|
||||||
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos)
|
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos)
|
||||||
SUBDIRS(ObsoleteDemos)
|
SUBDIRS(Demos)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF(BUILD_OBSOLETE_DEMOS)
|
ENDIF(BUILD_OBSOLETE_DEMOS)
|
||||||
|
|
||||||
@@ -232,6 +232,10 @@ IF(BUILD_BULLET3_DEMOS)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF(BUILD_BULLET3_DEMOS)
|
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
|
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
|
||||||
@@ -266,9 +270,9 @@ IF(INSTALL_LIBS)
|
|||||||
ENDIF(INSTALL_LIBS)
|
ENDIF(INSTALL_LIBS)
|
||||||
|
|
||||||
#INSTALL of other files requires CMake 2.6
|
#INSTALL of other files requires CMake 2.6
|
||||||
#IF (${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)
|
OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
|
||||||
#ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
||||||
|
|
||||||
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" ON)
|
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" ON)
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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)
|
///perhaps we can do something special with entities (isEntity)
|
||||||
///like adding a collision Triggering (as example)
|
///like adding a collision Triggering (as example)
|
||||||
|
|
||||||
if (vertices.size() > 0)
|
if (vertices.size() > 0)
|
||||||
{
|
{
|
||||||
float mass = 0.f;
|
float mass = 0.f;
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
startTransform.setOrigin(btVector3(0,0,-10.f));
|
startTransform.setOrigin(btVector3(0,0,-10.f));
|
||||||
//this create an internal copy of the vertices
|
//this create an internal copy of the vertices
|
||||||
|
|
||||||
btCollisionShape* shape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
btCollisionShape* shape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
||||||
m_demoApp->m_collisionShapes.push_back(shape);
|
m_demoApp->m_collisionShapes.push_back(shape);
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ BspDemo::~BspDemo()
|
|||||||
void BspDemo::initPhysics()
|
void BspDemo::initPhysics()
|
||||||
{
|
{
|
||||||
const char* bspfilename = "BspDemo.bsp";
|
const char* bspfilename = "BspDemo.bsp";
|
||||||
|
|
||||||
initPhysics(bspfilename);
|
initPhysics(bspfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ void BspDemo::initPhysics(const char* bspfilename)
|
|||||||
{
|
{
|
||||||
setTexturing(true);
|
setTexturing(true);
|
||||||
setShadows(false);
|
setShadows(false);
|
||||||
|
|
||||||
m_cameraUp = btVector3(0,0,1);
|
m_cameraUp = btVector3(0,0,1);
|
||||||
m_forwardAxis = 1;
|
m_forwardAxis = 1;
|
||||||
|
|
||||||
@@ -170,31 +170,23 @@ void BspDemo::initPhysics(const char* bspfilename)
|
|||||||
#ifdef QUAKE_BSP_IMPORTING
|
#ifdef QUAKE_BSP_IMPORTING
|
||||||
|
|
||||||
void* memoryBuffer = 0;
|
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...
|
const char* filename = "BspDemo.bsp";
|
||||||
bspfilename = "../../../../BspDemo.bsp";
|
|
||||||
file = fopen(bspfilename,"r");
|
const char* prefix[]={"./","../","../../","../../../","../../../../", "BspDemo/", "Demos/BspDemo/",
|
||||||
}
|
"../Demos/BspDemo/","../../Demos/BspDemo/"};
|
||||||
if (!file)
|
int numPrefixes = sizeof(prefix)/sizeof(const char*);
|
||||||
{
|
char relativeFileName[1024];
|
||||||
//try again other path,
|
FILE* file=0;
|
||||||
//sight... visual studio leaves the current working directory in the projectfiles folder
|
|
||||||
//instead of executable folder. who wants this default behaviour?!?
|
for (int i=0;i<numPrefixes;i++)
|
||||||
bspfilename = "BspDemo.bsp";
|
{
|
||||||
file = fopen(bspfilename,"r");
|
sprintf(relativeFileName,"%s%s",prefix[i],filename);
|
||||||
}
|
file = fopen(relativeFileName,"r");
|
||||||
|
if (file)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
@@ -229,9 +221,9 @@ void BspDemo::initPhysics(const char* bspfilename)
|
|||||||
|
|
||||||
void BspDemo::clientMoveAndDisplay()
|
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;
|
float dt = getDeltaTimeMicroseconds() * 0.000001f;
|
||||||
|
|
||||||
m_dynamicsWorld->stepSimulation(dt);
|
m_dynamicsWorld->stepSimulation(dt);
|
||||||
|
|
||||||
//optional but useful: debug drawing
|
//optional but useful: debug drawing
|
||||||
@@ -248,7 +240,7 @@ void BspDemo::clientMoveAndDisplay()
|
|||||||
|
|
||||||
void BspDemo::displayCallback(void) {
|
void BspDemo::displayCallback(void) {
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
renderme();
|
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 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'))
|
if(i && (in[0] == '.') && (in[1] == 'e') && (in[2] == 'x') && (in[3] == 'e'))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// If we hit a null or a quote, stop copying. This will get just the first filename.
|
// If we hit a null or a quote, stop copying. This will get just the first filename.
|
||||||
if(*in == '\0' || *in == '\"')
|
if(*in == '\0' || *in == '\"')
|
||||||
break;
|
break;
|
||||||
@@ -316,6 +308,6 @@ char* makeExeToBspFilename(const char* lpCmdLine)
|
|||||||
*(out++) = 's';
|
*(out++) = 's';
|
||||||
*(out++) = 'p';
|
*(out++) = 'p';
|
||||||
*(out++) = 0;
|
*(out++) = 0;
|
||||||
|
|
||||||
return cleaned_filename;
|
return cleaned_filename;
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
|||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
TARGET AppBspPhysicsDemo
|
TARGET AppBspPhysicsDemo
|
||||||
POST_BUILD
|
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)
|
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 DEBUG_POSTFIX "_Debug")
|
||||||
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
|
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
|
||||||
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
|
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
|
||||||
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||||
@@ -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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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);
|
setTexturing(true);
|
||||||
setShadows(true);
|
setShadows(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setupEmptyDynamicsWorld();
|
setupEmptyDynamicsWorld();
|
||||||
|
|
||||||
|
|
||||||
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
|
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
|
||||||
|
|
||||||
|
|
||||||
btBulletXmlWorldImporter* importer = new btBulletXmlWorldImporter(m_dynamicsWorld);
|
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("bulletser.xml");
|
||||||
// importer->loadFile("bullet_constraints.xml");
|
// importer->loadFile("bullet_constraints.xml");
|
||||||
|
|
||||||
@@ -55,21 +75,21 @@ void BulletXmlImportDemo::initPhysics()
|
|||||||
|
|
||||||
void BulletXmlImportDemo::clientMoveAndDisplay()
|
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
|
//simple dynamics world doesn't handle fixed-time-stepping
|
||||||
float ms = getDeltaTimeMicroseconds();
|
float ms = getDeltaTimeMicroseconds();
|
||||||
|
|
||||||
///step the simulation
|
///step the simulation
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||||
m_dynamicsWorld->debugDrawWorld();
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
@@ -81,8 +101,8 @@ void BulletXmlImportDemo::clientMoveAndDisplay()
|
|||||||
|
|
||||||
void BulletXmlImportDemo::displayCallback(void) {
|
void BulletXmlImportDemo::displayCallback(void) {
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
@@ -105,7 +125,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
|
|||||||
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher);
|
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher);
|
||||||
|
|
||||||
m_broadphase = new btDbvtBroadphase();
|
m_broadphase = new btDbvtBroadphase();
|
||||||
|
|
||||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||||
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
||||||
m_solver = sol;
|
m_solver = sol;
|
||||||
@@ -113,7 +133,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
|
|||||||
|
|
||||||
//btGImpactCollisionAlgorithm::registerAlgorithm((btCollisionDispatcher*)m_dynamicsWorld->getDispatcher());
|
//btGImpactCollisionAlgorithm::registerAlgorithm((btCollisionDispatcher*)m_dynamicsWorld->getDispatcher());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +143,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
|
|||||||
BulletXmlImportDemo::~BulletXmlImportDemo()
|
BulletXmlImportDemo::~BulletXmlImportDemo()
|
||||||
{
|
{
|
||||||
m_fileLoader->deleteAllData();
|
m_fileLoader->deleteAllData();
|
||||||
delete m_fileLoader;
|
delete m_fileLoader;
|
||||||
exitPhysics();
|
exitPhysics();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,16 +183,16 @@ void BulletXmlImportDemo::exitPhysics()
|
|||||||
m_collisionShapes.clear();
|
m_collisionShapes.clear();
|
||||||
|
|
||||||
delete m_dynamicsWorld;
|
delete m_dynamicsWorld;
|
||||||
|
|
||||||
delete m_solver;
|
delete m_solver;
|
||||||
|
|
||||||
delete m_broadphase;
|
delete m_broadphase;
|
||||||
|
|
||||||
delete m_dispatcher;
|
delete m_dispatcher;
|
||||||
|
|
||||||
delete m_collisionConfiguration;
|
delete m_collisionConfiguration;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5,9 +5,9 @@ SUBDIRS( HelloWorld )
|
|||||||
IF (USE_GLUT)
|
IF (USE_GLUT)
|
||||||
IF (GLUT_FOUND)
|
IF (GLUT_FOUND)
|
||||||
IF(BUILD_CPU_DEMOS)
|
IF(BUILD_CPU_DEMOS)
|
||||||
# IF(BUILD_EXTRAS)
|
IF(BUILD_EXTRAS)
|
||||||
# SUBDIRS( BulletXmlImportDemo ConcaveDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo )
|
SUBDIRS( BulletXmlImportDemo ConcaveDemo ConvexDecompositionDemo SerializeDemo )
|
||||||
# ENDIF()
|
ENDIF()
|
||||||
SET(SharedDemoSubdirs
|
SET(SharedDemoSubdirs
|
||||||
OpenGL
|
OpenGL
|
||||||
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
|
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
|
||||||
@@ -46,7 +46,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
|||||||
ADD_CUSTOM_COMMAND(
|
ADD_CUSTOM_COMMAND(
|
||||||
TARGET AppCharacterDemo
|
TARGET AppCharacterDemo
|
||||||
POST_BUILD
|
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)
|
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||||
|
|
||||||
@@ -69,11 +69,11 @@ void CharacterDemo::initPhysics()
|
|||||||
m_constraintSolver = new btSequentialImpulseConstraintSolver();
|
m_constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);
|
||||||
m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
|
m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
|
||||||
|
|
||||||
#ifdef DYNAMIC_CHARACTER_CONTROLLER
|
#ifdef DYNAMIC_CHARACTER_CONTROLLER
|
||||||
m_character = new DynamicCharacterController ();
|
m_character = new DynamicCharacterController ();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity ();
|
startTransform.setIdentity ();
|
||||||
//startTransform.setOrigin (btVector3(0.0, 4.0, 0.0));
|
//startTransform.setOrigin (btVector3(0.0, 4.0, 0.0));
|
||||||
@@ -101,35 +101,30 @@ void CharacterDemo::initPhysics()
|
|||||||
btTransform tr;
|
btTransform tr;
|
||||||
tr.setIdentity();
|
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;
|
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)
|
if (file)
|
||||||
{
|
{
|
||||||
BspLoader bspLoader;
|
BspLoader bspLoader;
|
||||||
int size=0;
|
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 */
|
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
|
} else
|
||||||
{
|
{
|
||||||
//how to detect file size?
|
//how to detect file size?
|
||||||
@@ -183,7 +178,7 @@ void CharacterDemo::debugDrawContacts()
|
|||||||
manifoldArray.clear();
|
manifoldArray.clear();
|
||||||
|
|
||||||
const btBroadphasePair& pair = pairArray[i];
|
const btBroadphasePair& pair = pairArray[i];
|
||||||
|
|
||||||
btBroadphasePair* collisionPair = m_overlappingPairCache->getOverlappingPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
|
btBroadphasePair* collisionPair = m_overlappingPairCache->getOverlappingPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
|
||||||
if (!collisionPair)
|
if (!collisionPair)
|
||||||
continue;
|
continue;
|
||||||
@@ -217,7 +212,7 @@ void CharacterDemo::clientMoveAndDisplay()
|
|||||||
/* Character stuff &*/
|
/* Character stuff &*/
|
||||||
if (m_character)
|
if (m_character)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debugDrawContacts();
|
debugDrawContacts();
|
||||||
@@ -265,7 +260,7 @@ void CharacterDemo::clientMoveAndDisplay()
|
|||||||
walkDirection += forwardDir;
|
walkDirection += forwardDir;
|
||||||
|
|
||||||
if (gBackward)
|
if (gBackward)
|
||||||
walkDirection -= forwardDir;
|
walkDirection -= forwardDir;
|
||||||
|
|
||||||
|
|
||||||
m_character->setWalkDirection(walkDirection*walkSpeed);
|
m_character->setWalkDirection(walkDirection*walkSpeed);
|
||||||
@@ -344,7 +339,7 @@ void CharacterDemo::clientResetScene()
|
|||||||
m_character->reset (m_dynamicsWorld);
|
m_character->reset (m_dynamicsWorld);
|
||||||
///WTF
|
///WTF
|
||||||
m_character->warp (btVector3(10.210001,-2.0306311,16.576973));
|
m_character->warp (btVector3(10.210001,-2.0306311,16.576973));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterDemo::specialKeyboardUp(int key, int x, int y)
|
void CharacterDemo::specialKeyboardUp(int key, int x, int y)
|
||||||
@@ -444,7 +439,7 @@ void CharacterDemo::updateCamera()
|
|||||||
|
|
||||||
m_cameraTargetPosition = characterWorldTrans.getOrigin();
|
m_cameraTargetPosition = characterWorldTrans.getOrigin();
|
||||||
m_cameraPosition = m_cameraTargetPosition + up * 10.0 + backward * 12.0;
|
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)
|
//use the convex sweep test to find a safe position for the camera (not blocked by static geometry)
|
||||||
btSphereShape cameraSphere(0.2f);
|
btSphereShape cameraSphere(0.2f);
|
||||||
btTransform cameraFrom,cameraTo;
|
btTransform cameraFrom,cameraTo;
|
||||||
@@ -452,10 +447,10 @@ void CharacterDemo::updateCamera()
|
|||||||
cameraFrom.setOrigin(characterWorldTrans.getOrigin());
|
cameraFrom.setOrigin(characterWorldTrans.getOrigin());
|
||||||
cameraTo.setIdentity();
|
cameraTo.setIdentity();
|
||||||
cameraTo.setOrigin(m_cameraPosition);
|
cameraTo.setOrigin(m_cameraPosition);
|
||||||
|
|
||||||
btCollisionWorld::ClosestConvexResultCallback cb( characterWorldTrans.getOrigin(), cameraTo.getOrigin() );
|
btCollisionWorld::ClosestConvexResultCallback cb( characterWorldTrans.getOrigin(), cameraTo.getOrigin() );
|
||||||
cb.m_collisionFilterMask = btBroadphaseProxy::StaticFilter;
|
cb.m_collisionFilterMask = btBroadphaseProxy::StaticFilter;
|
||||||
|
|
||||||
m_dynamicsWorld->convexSweepTest(&cameraSphere,cameraFrom,cameraTo,cb);
|
m_dynamicsWorld->convexSweepTest(&cameraSphere,cameraFrom,cameraTo,cb);
|
||||||
if (cb.hasHit())
|
if (cb.hasHit())
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
|
# 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
|
TARGET AppConvexDecompositionDemo
|
||||||
POST_BUILD
|
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}/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)
|
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||||
|
|
||||||
@@ -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.
|
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.
|
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,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
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.
|
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;
|
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;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
startTransform.setOrigin(btVector3(0,-4.5,0));
|
startTransform.setOrigin(btVector3(0,-4.5,0));
|
||||||
@@ -206,7 +205,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
|
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
|
||||||
{
|
{
|
||||||
ConvexDecompositionDemo* m_convexDemo;
|
ConvexDecompositionDemo* m_convexDemo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btAlignedObjectArray<btConvexHullShape*> m_convexShapes;
|
btAlignedObjectArray<btConvexHullShape*> m_convexShapes;
|
||||||
@@ -220,7 +219,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
|
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]);
|
btVector3 vertex(result.mHullVertices[i*3],result.mHullVertices[i*3+1],result.mHullVertices[i*3+2]);
|
||||||
vertex *= localScaling;
|
vertex *= localScaling;
|
||||||
centroid += vertex;
|
centroid += vertex;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,8 +272,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
vertices.push_back(vertex);
|
vertices.push_back(vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( 1 )
|
if ( 1 )
|
||||||
{
|
{
|
||||||
@@ -292,7 +291,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
vertex0 *= localScaling;
|
vertex0 *= localScaling;
|
||||||
vertex1 *= localScaling;
|
vertex1 *= localScaling;
|
||||||
vertex2 *= localScaling;
|
vertex2 *= localScaling;
|
||||||
|
|
||||||
vertex0 -= centroid;
|
vertex0 -= centroid;
|
||||||
vertex1 -= centroid;
|
vertex1 -= centroid;
|
||||||
vertex2 -= centroid;
|
vertex2 -= centroid;
|
||||||
@@ -303,20 +302,20 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
index0+=mBaseCount;
|
index0+=mBaseCount;
|
||||||
index1+=mBaseCount;
|
index1+=mBaseCount;
|
||||||
index2+=mBaseCount;
|
index2+=mBaseCount;
|
||||||
|
|
||||||
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
|
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// float mass = 1.f;
|
// float mass = 1.f;
|
||||||
|
|
||||||
|
|
||||||
//this is a tools issue: due to collision margin, convex objects overlap, compensate for it here:
|
//this is a tools issue: due to collision margin, convex objects overlap, compensate for it here:
|
||||||
//#define SHRINK_OBJECT_INWARDS 1
|
//#define SHRINK_OBJECT_INWARDS 1
|
||||||
#ifdef SHRINK_OBJECT_INWARDS
|
#ifdef SHRINK_OBJECT_INWARDS
|
||||||
|
|
||||||
float collisionMargin = 0.01f;
|
float collisionMargin = 0.01f;
|
||||||
|
|
||||||
btAlignedObjectArray<btVector3> planeEquations;
|
btAlignedObjectArray<btVector3> planeEquations;
|
||||||
btGeometryUtil::getPlaneEquationsFromVertices(vertices,planeEquations);
|
btGeometryUtil::getPlaneEquationsFromVertices(vertices,planeEquations);
|
||||||
|
|
||||||
@@ -330,13 +329,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
btAlignedObjectArray<btVector3> shiftedVertices;
|
btAlignedObjectArray<btVector3> shiftedVertices;
|
||||||
btGeometryUtil::getVerticesFromPlaneEquations(shiftedPlaneEquations,shiftedVertices);
|
btGeometryUtil::getVerticesFromPlaneEquations(shiftedPlaneEquations,shiftedVertices);
|
||||||
|
|
||||||
|
|
||||||
btConvexHullShape* convexShape = new btConvexHullShape(&(shiftedVertices[0].getX()),shiftedVertices.size());
|
btConvexHullShape* convexShape = new btConvexHullShape(&(shiftedVertices[0].getX()),shiftedVertices.size());
|
||||||
|
|
||||||
#else //SHRINK_OBJECT_INWARDS
|
#else //SHRINK_OBJECT_INWARDS
|
||||||
|
|
||||||
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
||||||
#endif
|
#endif
|
||||||
if (sEnableSAT)
|
if (sEnableSAT)
|
||||||
convexShape->initializePolyhedralFeatures();
|
convexShape->initializePolyhedralFeatures();
|
||||||
convexShape->setMargin(0.01f);
|
convexShape->setMargin(0.01f);
|
||||||
@@ -361,7 +360,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
m_trimeshes.push_back(trimesh);
|
m_trimeshes.push_back(trimesh);
|
||||||
|
|
||||||
btVector3 localScaling(6.f,6.f,6.f);
|
btVector3 localScaling(6.f,6.f,6.f);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for ( i=0;i<wo.mTriCount;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 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 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]);
|
btVector3 vertex2(wo.mVertices[index2*3], wo.mVertices[index2*3+1],wo.mVertices[index2*3+2]);
|
||||||
|
|
||||||
vertex0 *= localScaling;
|
vertex0 *= localScaling;
|
||||||
vertex1 *= localScaling;
|
vertex1 *= localScaling;
|
||||||
vertex2 *= localScaling;
|
vertex2 *= localScaling;
|
||||||
@@ -380,13 +379,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
trimesh->addTriangle(vertex0,vertex1,vertex2);
|
trimesh->addTriangle(vertex0,vertex1,vertex2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btConvexShape* tmpConvexShape = new btConvexTriangleMeshShape(trimesh);
|
btConvexShape* tmpConvexShape = new btConvexTriangleMeshShape(trimesh);
|
||||||
|
|
||||||
printf("old numTriangles= %d\n",wo.mTriCount);
|
printf("old numTriangles= %d\n",wo.mTriCount);
|
||||||
printf("old numIndices = %d\n",wo.mTriCount*3);
|
printf("old numIndices = %d\n",wo.mTriCount*3);
|
||||||
printf("old numVertices = %d\n",wo.mVertexCount);
|
printf("old numVertices = %d\n",wo.mVertexCount);
|
||||||
|
|
||||||
printf("reducing vertices by creating a convex hull\n");
|
printf("reducing vertices by creating a convex hull\n");
|
||||||
|
|
||||||
//create a hull approximation
|
//create a hull approximation
|
||||||
@@ -394,18 +393,18 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
btScalar margin = tmpConvexShape->getMargin();
|
btScalar margin = tmpConvexShape->getMargin();
|
||||||
hull->buildHull(margin);
|
hull->buildHull(margin);
|
||||||
tmpConvexShape->setUserPointer(hull);
|
tmpConvexShape->setUserPointer(hull);
|
||||||
|
|
||||||
|
|
||||||
printf("new numTriangles = %d\n", hull->numTriangles ());
|
printf("new numTriangles = %d\n", hull->numTriangles ());
|
||||||
printf("new numIndices = %d\n", hull->numIndices ());
|
printf("new numIndices = %d\n", hull->numIndices ());
|
||||||
printf("new numVertices = %d\n", hull->numVertices ());
|
printf("new numVertices = %d\n", hull->numVertices ());
|
||||||
|
|
||||||
btConvexHullShape* convexShape = new btConvexHullShape();
|
btConvexHullShape* convexShape = new btConvexHullShape();
|
||||||
bool updateLocalAabb = false;
|
bool updateLocalAabb = false;
|
||||||
|
|
||||||
for (i=0;i<hull->numVertices();i++)
|
for (i=0;i<hull->numVertices();i++)
|
||||||
{
|
{
|
||||||
convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb);
|
convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb);
|
||||||
}
|
}
|
||||||
convexShape->recalcLocalAabb();
|
convexShape->recalcLocalAabb();
|
||||||
|
|
||||||
@@ -419,13 +418,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
m_collisionShapes.push_back(convexShape);
|
m_collisionShapes.push_back(convexShape);
|
||||||
|
|
||||||
float mass = 1.f;
|
float mass = 1.f;
|
||||||
|
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
startTransform.setOrigin(btVector3(0,2,14));
|
startTransform.setOrigin(btVector3(0,2,14));
|
||||||
|
|
||||||
localCreateRigidBody(mass, startTransform,convexShape);
|
localCreateRigidBody(mass, startTransform,convexShape);
|
||||||
|
|
||||||
bool useQuantization = true;
|
bool useQuantization = true;
|
||||||
btCollisionShape* concaveShape = new btBvhTriangleMeshShape(trimesh,useQuantization);
|
btCollisionShape* concaveShape = new btBvhTriangleMeshShape(trimesh,useQuantization);
|
||||||
startTransform.setOrigin(convexDecompositionObjectOffset);
|
startTransform.setOrigin(convexDecompositionObjectOffset);
|
||||||
@@ -434,7 +433,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
m_collisionShapes.push_back (concaveShape);
|
m_collisionShapes.push_back (concaveShape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tcount)
|
if (tcount)
|
||||||
{
|
{
|
||||||
@@ -445,11 +444,11 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
char outputFileName[512];
|
char outputFileName[512];
|
||||||
strcpy(outputFileName,filename);
|
strcpy(outputFileName,filename);
|
||||||
char *dot = strstr(outputFileName,".");
|
char *dot = strstr(outputFileName,".");
|
||||||
if ( dot )
|
if ( dot )
|
||||||
*dot = 0;
|
*dot = 0;
|
||||||
strcat(outputFileName,"_convex.obj");
|
strcat(outputFileName,"_convex.obj");
|
||||||
FILE* outputFile = fopen(outputFileName,"wb");
|
FILE* outputFile = fopen(outputFileName,"wb");
|
||||||
|
|
||||||
unsigned int depth = 5;
|
unsigned int depth = 5;
|
||||||
float cpercent = 5;
|
float cpercent = 5;
|
||||||
float ppercent = 15;
|
float ppercent = 15;
|
||||||
@@ -479,7 +478,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
std::vector< HACD::Vec3<HACD::Real> > points;
|
std::vector< HACD::Vec3<HACD::Real> > points;
|
||||||
std::vector< HACD::Vec3<long> > triangles;
|
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;
|
int index = i*3;
|
||||||
HACD::Vec3<HACD::Real> vertex(wo.mVertices[index], wo.mVertices[index+1],wo.mVertices[index+2]);
|
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 invert = false;
|
||||||
bool addExtraDistPoints = false;
|
bool addExtraDistPoints = false;
|
||||||
bool addNeighboursDistPoints = false;
|
bool addNeighboursDistPoints = false;
|
||||||
bool addFacesPoints = false;
|
bool addFacesPoints = false;
|
||||||
|
|
||||||
myHACD.SetNClusters(nClusters); // minimum number of clusters
|
myHACD.SetNClusters(nClusters); // minimum number of clusters
|
||||||
myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull
|
myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull
|
||||||
myHACD.SetConcavity(concavity); // maximum concavity
|
myHACD.SetConcavity(concavity); // maximum concavity
|
||||||
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
|
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
|
||||||
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
|
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
|
||||||
myHACD.SetAddFacesPoints(addFacesPoints);
|
myHACD.SetAddFacesPoints(addFacesPoints);
|
||||||
|
|
||||||
myHACD.Compute();
|
myHACD.Compute();
|
||||||
nClusters = myHACD.GetNClusters();
|
nClusters = myHACD.GetNClusters();
|
||||||
|
|
||||||
myHACD.Save("output.wrl", false);
|
myHACD.Save("output.wrl", false);
|
||||||
|
|
||||||
@@ -529,7 +528,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
// ConvexBuilder cb(desc.mCallback);
|
// ConvexBuilder cb(desc.mCallback);
|
||||||
// cb.process(desc);
|
// cb.process(desc);
|
||||||
//now create some bodies
|
//now create some bodies
|
||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
btCompoundShape* compound = new btCompoundShape();
|
btCompoundShape* compound = new btCompoundShape();
|
||||||
@@ -546,7 +545,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
|
|
||||||
float* vertices = new float[nPoints*3];
|
float* vertices = new float[nPoints*3];
|
||||||
unsigned int* triangles = new unsigned int[nTriangles*3];
|
unsigned int* triangles = new unsigned int[nTriangles*3];
|
||||||
|
|
||||||
HACD::Vec3<HACD::Real> * pointsCH = new HACD::Vec3<HACD::Real>[nPoints];
|
HACD::Vec3<HACD::Real> * pointsCH = new HACD::Vec3<HACD::Real>[nPoints];
|
||||||
HACD::Vec3<long> * trianglesCH = new HACD::Vec3<long>[nTriangles];
|
HACD::Vec3<long> * trianglesCH = new HACD::Vec3<long>[nTriangles];
|
||||||
myHACD.GetCH(c, pointsCH, trianglesCH);
|
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++)
|
/* for (int i=0;i<convexDecomposition.m_convexShapes.size();i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
btVector3 centroid = convexDecomposition.m_convexCentroids[i];
|
btVector3 centroid = convexDecomposition.m_convexCentroids[i];
|
||||||
trans.setOrigin(centroid);
|
trans.setOrigin(centroid);
|
||||||
btConvexHullShape* convexShape = convexDecomposition.m_convexShapes[i];
|
btConvexHullShape* convexShape = convexDecomposition.m_convexShapes[i];
|
||||||
@@ -613,7 +612,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (outputFile)
|
if (outputFile)
|
||||||
fclose(outputFile);
|
fclose(outputFile);
|
||||||
|
|
||||||
@@ -623,13 +622,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef TEST_SERIALIZATION
|
#ifdef TEST_SERIALIZATION
|
||||||
//test serializing this
|
//test serializing this
|
||||||
|
|
||||||
int maxSerializeBufferSize = 1024*1024*5;
|
int maxSerializeBufferSize = 1024*1024*5;
|
||||||
|
|
||||||
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
|
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
|
||||||
m_dynamicsWorld->serialize(serializer);
|
m_dynamicsWorld->serialize(serializer);
|
||||||
|
|
||||||
FILE* f2 = fopen("testFile.bullet","wb");
|
FILE* f2 = fopen("testFile.bullet","wb");
|
||||||
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2);
|
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2);
|
||||||
fclose(f2);
|
fclose(f2);
|
||||||
@@ -651,17 +650,17 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
//fileLoader->loadFile("testFile64Double.bullet");
|
//fileLoader->loadFile("testFile64Double.bullet");
|
||||||
//fileLoader->loadFile("testFile64Single.bullet");
|
//fileLoader->loadFile("testFile64Single.bullet");
|
||||||
//fileLoader->loadFile("testFile32Single.bullet");
|
//fileLoader->loadFile("testFile32Single.bullet");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //TEST_SERIALIZATION
|
#endif //TEST_SERIALIZATION
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvexDecompositionDemo::clientMoveAndDisplay()
|
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;
|
float dt = getDeltaTimeMicroseconds() * 0.000001f;
|
||||||
|
|
||||||
@@ -681,7 +680,7 @@ void ConvexDecompositionDemo::clientMoveAndDisplay()
|
|||||||
|
|
||||||
void ConvexDecompositionDemo::displayCallback(void) {
|
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)
|
if (m_dynamicsWorld)
|
||||||
@@ -749,7 +748,7 @@ void ConvexDecompositionDemo::exitPhysics()
|
|||||||
|
|
||||||
delete m_collisionConfiguration;
|
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");
|
printf("SAT enabled after the next restart of the demo\n");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("SAT disabled after the next restart of the demo\n");
|
printf("SAT disabled after the next restart of the demo\n");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -776,4 +775,4 @@ void ConvexDecompositionDemo::keyboardCallback(unsigned char key, int x, int y)
|
|||||||
PlatformDemoApplication::keyboardCallback(key,x,y);
|
PlatformDemoApplication::keyboardCallback(key,x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
3578
Demos/ConvexDecompositionDemo/file.obj
Normal file
3578
Demos/ConvexDecompositionDemo/file.obj
Normal file
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
Reference in New Issue
Block a user