Refactoring: another huge number of changes, renamed methods to start with lower-case.
This commit is contained in:
@@ -90,7 +90,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
|
||||
bool isEntity = false;
|
||||
btVector3 entityTarget(0.f,0.f,0.f);
|
||||
AddConvexVerticesCollider(vertices,isEntity,entityTarget);
|
||||
addConvexVerticesCollider(vertices,isEntity,entityTarget);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -107,11 +107,11 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
for (i=0;i<bspLoader.m_num_entities;i++)
|
||||
{
|
||||
const BSPEntity& entity = bspLoader.m_entities[i];
|
||||
const char* cl = bspLoader.ValueForKey(&entity,"classname");
|
||||
const char* cl = bspLoader.getValueForKey(&entity,"classname");
|
||||
if ( !strcmp( cl, "trigger_push" ) ) {
|
||||
btVector3 targetLocation(0.f,0.f,0.f);
|
||||
|
||||
cl = bspLoader.ValueForKey(&entity,"target");
|
||||
cl = bspLoader.getValueForKey(&entity,"target");
|
||||
if ( strcmp( cl, "" ) ) {
|
||||
//its not empty so ...
|
||||
|
||||
@@ -119,13 +119,13 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl );
|
||||
if (targetentity)
|
||||
{
|
||||
if (bspLoader.GetVectorForKey( targetentity , "origin",&targetLocation[0]))
|
||||
if (bspLoader.getVectorForKey( targetentity , "origin",&targetLocation[0]))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cl = bspLoader.ValueForKey(&entity,"model");
|
||||
cl = bspLoader.getValueForKey(&entity,"model");
|
||||
if ( strcmp( cl, "" ) ) {
|
||||
// add the model as a brush
|
||||
if (cl[0] == '*')
|
||||
@@ -164,7 +164,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
getVerticesFromPlaneEquations(planeEquations,vertices);
|
||||
|
||||
bool isEntity=true;
|
||||
AddConvexVerticesCollider(vertices,isEntity,targetLocation);
|
||||
addConvexVerticesCollider(vertices,isEntity,targetLocation);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class BspConverter
|
||||
bool isInside(const std::vector<btVector3>& planeEquations, const btVector3& point, float margin);
|
||||
|
||||
///this callback is called for each brush that succesfully converted into vertices
|
||||
virtual void AddConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
|
||||
virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void AddConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
|
||||
virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
|
||||
{
|
||||
///perhaps we can do something special with entities (isEntity)
|
||||
///like adding a collision Triggering (as example)
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
//this create an internal copy of the vertices
|
||||
btCollisionShape* shape = new btConvexHullShape(&vertices[0],vertices.size());
|
||||
|
||||
m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape);
|
||||
m_demoApp->localCreatePhysicsObject(isDynamic, mass, startTransform,shape);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -168,7 +168,7 @@ void BspDemo::initPhysics(char* bspfilename)
|
||||
//how to detect file size?
|
||||
memoryBuffer = malloc(size+1);
|
||||
fread(memoryBuffer,1,size,file);
|
||||
bspLoader.LoadBSPFile( memoryBuffer);
|
||||
bspLoader.loadBSPFile( memoryBuffer);
|
||||
|
||||
BspToBulletConverter bsp2bullet(this);
|
||||
float bspScaling = 0.1f;
|
||||
|
||||
@@ -40,12 +40,12 @@ bool endofscript;
|
||||
bool tokenready; // only true if UnGetToken was just called
|
||||
|
||||
//
|
||||
//LoadBSPFile
|
||||
//loadBSPFile
|
||||
//
|
||||
|
||||
int extrasize = 100;
|
||||
|
||||
bool BspLoader::LoadBSPFile( void* memoryBuffer) {
|
||||
bool BspLoader::loadBSPFile( void* memoryBuffer) {
|
||||
|
||||
BSPHeader *header = (BSPHeader*) memoryBuffer;
|
||||
|
||||
@@ -53,73 +53,73 @@ bool BspLoader::LoadBSPFile( void* memoryBuffer) {
|
||||
if (header)
|
||||
{
|
||||
// swap the header
|
||||
SwapBlock( (int *)header, sizeof(*header) );
|
||||
swapBlock( (int *)header, sizeof(*header) );
|
||||
|
||||
int length = (header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader);
|
||||
m_dshaders.resize(length+extrasize);
|
||||
m_numShaders = CopyLump( header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader) );
|
||||
m_numShaders = copyLump( header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader) );
|
||||
|
||||
length = (header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel);
|
||||
m_dmodels.resize(length+extrasize);
|
||||
m_nummodels = CopyLump( header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel) );
|
||||
m_nummodels = copyLump( header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel) );
|
||||
|
||||
length = (header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane);
|
||||
m_dplanes.resize(length+extrasize);
|
||||
m_numplanes = CopyLump( header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane) );
|
||||
m_numplanes = copyLump( header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane) );
|
||||
|
||||
length = (header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf);
|
||||
m_dleafs.resize(length+extrasize);
|
||||
m_numleafs = CopyLump( header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf) );
|
||||
m_numleafs = copyLump( header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf) );
|
||||
|
||||
length = (header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode);
|
||||
m_dnodes.resize(length+extrasize);
|
||||
m_numnodes = CopyLump( header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode) );
|
||||
m_numnodes = copyLump( header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode) );
|
||||
|
||||
length = (header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0]);
|
||||
m_dleafsurfaces.resize(length+extrasize);
|
||||
m_numleafsurfaces = CopyLump( header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0]) );
|
||||
m_numleafsurfaces = copyLump( header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0]) );
|
||||
|
||||
length = (header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0]) ;
|
||||
m_dleafbrushes.resize(length+extrasize);
|
||||
m_numleafbrushes = CopyLump( header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0]) );
|
||||
m_numleafbrushes = copyLump( header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0]) );
|
||||
|
||||
length = (header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush);
|
||||
m_dbrushes.resize(length+extrasize);
|
||||
m_numbrushes = CopyLump( header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush) );
|
||||
m_numbrushes = copyLump( header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush) );
|
||||
|
||||
|
||||
length = (header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide);
|
||||
m_dbrushsides.resize(length+extrasize);
|
||||
m_numbrushsides = CopyLump( header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide) );
|
||||
m_numbrushsides = copyLump( header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide) );
|
||||
|
||||
|
||||
length = (header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface);
|
||||
m_drawSurfaces.resize(length+extrasize);
|
||||
m_numDrawSurfaces = CopyLump( header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface) );
|
||||
m_numDrawSurfaces = copyLump( header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface) );
|
||||
|
||||
|
||||
length = (header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0]);
|
||||
m_drawIndexes.resize(length+extrasize);
|
||||
m_numDrawIndexes = CopyLump( header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0]) );
|
||||
m_numDrawIndexes = copyLump( header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0]) );
|
||||
|
||||
length = (header->lumps[LUMP_VISIBILITY].filelen) / 1;
|
||||
m_visBytes.resize(length+extrasize);
|
||||
m_numVisBytes = CopyLump( header, LUMP_VISIBILITY, &m_visBytes[0], 1 );
|
||||
m_numVisBytes = copyLump( header, LUMP_VISIBILITY, &m_visBytes[0], 1 );
|
||||
|
||||
length = (header->lumps[LUMP_LIGHTMAPS].filelen) / 1;
|
||||
m_lightBytes.resize(length+extrasize);
|
||||
m_numLightBytes = CopyLump( header, LUMP_LIGHTMAPS, &m_lightBytes[0], 1 );
|
||||
m_numLightBytes = copyLump( header, LUMP_LIGHTMAPS, &m_lightBytes[0], 1 );
|
||||
|
||||
length = (header->lumps[BSPLUMP_ENTITIES].filelen) / 1;
|
||||
m_dentdata.resize(length+extrasize);
|
||||
m_entdatasize = CopyLump( header, BSPLUMP_ENTITIES, &m_dentdata[0], 1);
|
||||
m_entdatasize = copyLump( header, BSPLUMP_ENTITIES, &m_dentdata[0], 1);
|
||||
|
||||
length = (header->lumps[LUMP_LIGHTGRID].filelen) / 1;
|
||||
m_gridData.resize(length+extrasize);
|
||||
m_numGridPoints = CopyLump( header, LUMP_LIGHTGRID, &m_gridData[0], 8 );
|
||||
m_numGridPoints = copyLump( header, LUMP_LIGHTGRID, &m_gridData[0], 8 );
|
||||
|
||||
// swap everything
|
||||
SwapBSPFile();
|
||||
swapBSPFile();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -129,7 +129,7 @@ bool BspLoader::LoadBSPFile( void* memoryBuffer) {
|
||||
|
||||
|
||||
|
||||
const char* BspLoader::ValueForKey( const BSPEntity* ent, const char* key ) const {
|
||||
const char* BspLoader::getValueForKey( const BSPEntity* ent, const char* key ) const {
|
||||
|
||||
const BSPKeyValuePair* ep;
|
||||
|
||||
@@ -141,17 +141,17 @@ const char* BspLoader::ValueForKey( const BSPEntity* ent, const char* key ) con
|
||||
return "";
|
||||
}
|
||||
|
||||
float BspLoader::FloatForKey( const BSPEntity *ent, const char *key ) {
|
||||
float BspLoader::getFloatForKey( const BSPEntity *ent, const char *key ) {
|
||||
const char *k;
|
||||
|
||||
k = ValueForKey( ent, key );
|
||||
k = getValueForKey( ent, key );
|
||||
return float(atof(k));
|
||||
}
|
||||
|
||||
bool BspLoader::GetVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ) {
|
||||
bool BspLoader::getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ) {
|
||||
|
||||
const char *k;
|
||||
k = ValueForKey (ent, key);
|
||||
k = getValueForKey (ent, key);
|
||||
if (strcmp(k, ""))
|
||||
{
|
||||
sscanf (k, "%f %f %f", &vec[0], &vec[1], &vec[2]);
|
||||
@@ -165,10 +165,10 @@ bool BspLoader::GetVectorForKey( const BSPEntity *ent, const char *key, BSPVect
|
||||
|
||||
/*
|
||||
==============
|
||||
ParseFromMemory
|
||||
parseFromMemory
|
||||
==============
|
||||
*/
|
||||
void BspLoader::ParseFromMemory (char *buffer, int size)
|
||||
void BspLoader::parseFromMemory (char *buffer, int size)
|
||||
{
|
||||
script = scriptstack;
|
||||
script++;
|
||||
@@ -188,7 +188,7 @@ void BspLoader::ParseFromMemory (char *buffer, int size)
|
||||
}
|
||||
|
||||
|
||||
bool BspLoader::EndOfScript (bool crossline)
|
||||
bool BspLoader::isEndOfScript (bool crossline)
|
||||
{
|
||||
if (!crossline)
|
||||
//printf("Line %i is incomplete\n",scriptline);
|
||||
@@ -208,16 +208,16 @@ bool BspLoader::EndOfScript (bool crossline)
|
||||
script--;
|
||||
scriptline = script->line;
|
||||
//printf ("returning to %s\n", script->filename);
|
||||
return GetToken (crossline);
|
||||
return getToken (crossline);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
==============
|
||||
GetToken
|
||||
getToken
|
||||
==============
|
||||
*/
|
||||
bool BspLoader::GetToken (bool crossline)
|
||||
bool BspLoader::getToken (bool crossline)
|
||||
{
|
||||
char *token_p;
|
||||
|
||||
@@ -228,7 +228,7 @@ bool BspLoader::GetToken (bool crossline)
|
||||
}
|
||||
|
||||
if (script->script_p >= script->end_p)
|
||||
return EndOfScript (crossline);
|
||||
return isEndOfScript (crossline);
|
||||
|
||||
//
|
||||
// skip space
|
||||
@@ -237,7 +237,7 @@ skipspace:
|
||||
while (*script->script_p <= 32)
|
||||
{
|
||||
if (script->script_p >= script->end_p)
|
||||
return EndOfScript (crossline);
|
||||
return isEndOfScript (crossline);
|
||||
if (*script->script_p++ == '\n')
|
||||
{
|
||||
if (!crossline)
|
||||
@@ -249,7 +249,7 @@ skipspace:
|
||||
}
|
||||
|
||||
if (script->script_p >= script->end_p)
|
||||
return EndOfScript (crossline);
|
||||
return isEndOfScript (crossline);
|
||||
|
||||
// ; # // comments
|
||||
if (*script->script_p == ';' || *script->script_p == '#'
|
||||
@@ -261,7 +261,7 @@ skipspace:
|
||||
}
|
||||
while (*script->script_p++ != '\n')
|
||||
if (script->script_p >= script->end_p)
|
||||
return EndOfScript (crossline);
|
||||
return isEndOfScript (crossline);
|
||||
scriptline = script->line++;
|
||||
goto skipspace;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ skipspace:
|
||||
}
|
||||
script->script_p++;
|
||||
if (script->script_p >= script->end_p)
|
||||
return EndOfScript (crossline);
|
||||
return isEndOfScript (crossline);
|
||||
}
|
||||
script->script_p += 2;
|
||||
goto skipspace;
|
||||
@@ -324,9 +324,9 @@ skipspace:
|
||||
|
||||
if (!strcmp (token, "$include"))
|
||||
{
|
||||
//GetToken (false);
|
||||
//getToken (false);
|
||||
//AddScriptToStack (token);
|
||||
return false;//GetToken (crossline);
|
||||
return false;//getToken (crossline);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -340,7 +340,7 @@ char *BspLoader::copystring(const char *s)
|
||||
return b;
|
||||
}
|
||||
|
||||
void BspLoader::StripTrailing( char *e ) {
|
||||
void BspLoader::stripTrailing( char *e ) {
|
||||
char *s;
|
||||
|
||||
s = e + strlen(e)-1;
|
||||
@@ -352,10 +352,10 @@ void BspLoader::StripTrailing( char *e ) {
|
||||
}
|
||||
/*
|
||||
=================
|
||||
ParseEpair
|
||||
parseEpair
|
||||
=================
|
||||
*/
|
||||
BSPKeyValuePair *BspLoader::ParseEpair( void ) {
|
||||
BSPKeyValuePair *BspLoader::parseEpair( void ) {
|
||||
BSPKeyValuePair *e;
|
||||
|
||||
e = (struct BSPPair*) malloc( sizeof(BSPKeyValuePair));
|
||||
@@ -365,7 +365,7 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
|
||||
//printf ("ParseEpar: token too long");
|
||||
}
|
||||
e->key = copystring( token );
|
||||
GetToken( false );
|
||||
getToken( false );
|
||||
if ( strlen(token) >= BSPMAX_VALUE-1 ) {
|
||||
|
||||
//printf ("ParseEpar: token too long");
|
||||
@@ -374,8 +374,8 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
|
||||
|
||||
// strip trailing spaces that sometimes get accidentally
|
||||
// added in the editor
|
||||
StripTrailing( e->key );
|
||||
StripTrailing( e->value );
|
||||
stripTrailing( e->key );
|
||||
stripTrailing( e->value );
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -383,20 +383,20 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
|
||||
|
||||
/*
|
||||
================
|
||||
ParseEntity
|
||||
parseEntity
|
||||
================
|
||||
*/
|
||||
bool BspLoader::ParseEntity( void ) {
|
||||
bool BspLoader::parseEntity( void ) {
|
||||
BSPKeyValuePair *e;
|
||||
BSPEntity *mapent;
|
||||
|
||||
if ( !GetToken (true) ) {
|
||||
if ( !getToken (true) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( strcmp (token, "{") ) {
|
||||
|
||||
//printf ("ParseEntity: { not found");
|
||||
//printf ("parseEntity: { not found");
|
||||
}
|
||||
|
||||
BSPEntity bla;
|
||||
@@ -413,13 +413,13 @@ bool BspLoader::ParseEntity( void ) {
|
||||
m_num_entities++;
|
||||
|
||||
do {
|
||||
if ( !GetToken (true) ) {
|
||||
//printf("ParseEntity: EOF without closing brace");
|
||||
if ( !getToken (true) ) {
|
||||
//printf("parseEntity: EOF without closing brace");
|
||||
}
|
||||
if ( !strcmp (token, "}") ) {
|
||||
break;
|
||||
}
|
||||
e = (struct BSPPair*)ParseEpair ();
|
||||
e = (struct BSPPair*)parseEpair ();
|
||||
e->next = mapent->epairs;
|
||||
mapent->epairs = e;
|
||||
} while (1);
|
||||
@@ -429,18 +429,18 @@ bool BspLoader::ParseEntity( void ) {
|
||||
|
||||
/*
|
||||
================
|
||||
ParseEntities
|
||||
parseEntities
|
||||
|
||||
Parses the dentdata string into entities
|
||||
================
|
||||
*/
|
||||
void BspLoader::ParseEntities( void ) {
|
||||
void BspLoader::parseEntities( void ) {
|
||||
m_num_entities = 0;
|
||||
m_entities.clear();
|
||||
|
||||
ParseFromMemory( &m_dentdata[0], m_entdatasize );
|
||||
parseFromMemory( &m_dentdata[0], m_entdatasize );
|
||||
|
||||
while ( ParseEntity () ) {
|
||||
while ( parseEntity () ) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ int BspLoader::getMachineEndianness()
|
||||
return BSP_BIG_ENDIAN;
|
||||
}
|
||||
|
||||
short BspLoader::LittleShort (short l)
|
||||
short BspLoader::isLittleShort (short l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -471,7 +471,7 @@ short BspLoader::LittleShort (short l)
|
||||
return l;
|
||||
}
|
||||
|
||||
short BspLoader::BigShort (short l)
|
||||
short BspLoader::isBigShort (short l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -490,7 +490,7 @@ short BspLoader::BigShort (short l)
|
||||
}
|
||||
|
||||
|
||||
int BspLoader::LittleLong (int l)
|
||||
int BspLoader::isLittleLong (int l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -509,7 +509,7 @@ int BspLoader::LittleLong (int l)
|
||||
|
||||
}
|
||||
|
||||
int BspLoader::BigLong (int l)
|
||||
int BspLoader::isBigLong (int l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ int BspLoader::BigLong (int l)
|
||||
}
|
||||
|
||||
|
||||
float BspLoader::LittleFloat (float l)
|
||||
float BspLoader::isLittleFloat (float l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -548,7 +548,7 @@ float BspLoader::LittleFloat (float l)
|
||||
return l;
|
||||
}
|
||||
|
||||
float BspLoader::BigFloat (float l)
|
||||
float BspLoader::isBigFloat (float l)
|
||||
{
|
||||
if (machineEndianness() == BSP_BIG_ENDIAN)
|
||||
{
|
||||
@@ -572,31 +572,31 @@ float BspLoader::BigFloat (float l)
|
||||
|
||||
|
||||
//
|
||||
// SwapBlock
|
||||
// swapBlock
|
||||
// If all values are 32 bits, this can be used to swap everything
|
||||
//
|
||||
|
||||
void BspLoader::SwapBlock( int *block, int sizeOfBlock ) {
|
||||
void BspLoader::swapBlock( int *block, int sizeOfBlock ) {
|
||||
int i;
|
||||
|
||||
sizeOfBlock >>= 2;
|
||||
for ( i = 0 ; i < sizeOfBlock ; i++ ) {
|
||||
block[i] = LittleLong( block[i] );
|
||||
block[i] = isLittleLong( block[i] );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CopyLump
|
||||
// copyLump
|
||||
//
|
||||
|
||||
int BspLoader::CopyLump( BSPHeader *header, int lump, void *dest, int size ) {
|
||||
int BspLoader::copyLump( BSPHeader *header, int lump, void *dest, int size ) {
|
||||
int length, ofs;
|
||||
|
||||
length = header->lumps[lump].filelen;
|
||||
ofs = header->lumps[lump].fileofs;
|
||||
|
||||
//if ( length % size ) {
|
||||
// printf ("LoadBSPFile: odd lump size");
|
||||
// printf ("loadBSPFile: odd lump size");
|
||||
//}
|
||||
|
||||
memcpy( dest, (unsigned char *)header + ofs, length );
|
||||
@@ -608,52 +608,52 @@ int BspLoader::CopyLump( BSPHeader *header, int lump, void *dest, int size ) {
|
||||
|
||||
|
||||
//
|
||||
// SwapBSPFile
|
||||
// swapBSPFile
|
||||
//
|
||||
|
||||
void BspLoader::SwapBSPFile( void ) {
|
||||
void BspLoader::swapBSPFile( void ) {
|
||||
int i;
|
||||
|
||||
// models
|
||||
SwapBlock( (int *) &m_dmodels[0], m_nummodels * sizeof( m_dmodels[0] ) );
|
||||
swapBlock( (int *) &m_dmodels[0], m_nummodels * sizeof( m_dmodels[0] ) );
|
||||
|
||||
// shaders (don't swap the name)
|
||||
for ( i = 0 ; i < m_numShaders ; i++ ) {
|
||||
m_dshaders[i].contentFlags = LittleLong( m_dshaders[i].contentFlags );
|
||||
m_dshaders[i].surfaceFlags = LittleLong( m_dshaders[i].surfaceFlags );
|
||||
m_dshaders[i].contentFlags = isLittleLong( m_dshaders[i].contentFlags );
|
||||
m_dshaders[i].surfaceFlags = isLittleLong( m_dshaders[i].surfaceFlags );
|
||||
}
|
||||
|
||||
// planes
|
||||
SwapBlock( (int *)&m_dplanes[0], m_numplanes * sizeof( m_dplanes[0] ) );
|
||||
swapBlock( (int *)&m_dplanes[0], m_numplanes * sizeof( m_dplanes[0] ) );
|
||||
|
||||
// nodes
|
||||
SwapBlock( (int *)&m_dnodes[0], m_numnodes * sizeof( m_dnodes[0] ) );
|
||||
swapBlock( (int *)&m_dnodes[0], m_numnodes * sizeof( m_dnodes[0] ) );
|
||||
|
||||
// leafs
|
||||
SwapBlock( (int *)&m_dleafs[0], m_numleafs * sizeof( m_dleafs[0] ) );
|
||||
swapBlock( (int *)&m_dleafs[0], m_numleafs * sizeof( m_dleafs[0] ) );
|
||||
|
||||
// leaffaces
|
||||
SwapBlock( (int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof( m_dleafsurfaces[0] ) );
|
||||
swapBlock( (int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof( m_dleafsurfaces[0] ) );
|
||||
|
||||
// leafbrushes
|
||||
SwapBlock( (int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof( m_dleafbrushes[0] ) );
|
||||
swapBlock( (int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof( m_dleafbrushes[0] ) );
|
||||
|
||||
// brushes
|
||||
SwapBlock( (int *)&m_dbrushes[0], m_numbrushes * sizeof( m_dbrushes[0] ) );
|
||||
swapBlock( (int *)&m_dbrushes[0], m_numbrushes * sizeof( m_dbrushes[0] ) );
|
||||
|
||||
// brushsides
|
||||
SwapBlock( (int *)&m_dbrushsides[0], m_numbrushsides * sizeof( m_dbrushsides[0] ) );
|
||||
swapBlock( (int *)&m_dbrushsides[0], m_numbrushsides * sizeof( m_dbrushsides[0] ) );
|
||||
|
||||
// vis
|
||||
((int *)&m_visBytes)[0] = LittleLong( ((int *)&m_visBytes)[0] );
|
||||
((int *)&m_visBytes)[1] = LittleLong( ((int *)&m_visBytes)[1] );
|
||||
((int *)&m_visBytes)[0] = isLittleLong( ((int *)&m_visBytes)[0] );
|
||||
((int *)&m_visBytes)[1] = isLittleLong( ((int *)&m_visBytes)[1] );
|
||||
|
||||
|
||||
// drawindexes
|
||||
SwapBlock( (int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof( m_drawIndexes[0] ) );
|
||||
swapBlock( (int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof( m_drawIndexes[0] ) );
|
||||
|
||||
// drawsurfs
|
||||
SwapBlock( (int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof( m_drawSurfaces[0] ) );
|
||||
swapBlock( (int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof( m_drawSurfaces[0] ) );
|
||||
|
||||
}
|
||||
|
||||
@@ -668,17 +668,17 @@ bool BspLoader::findVectorByName(float* outvec,const char* name)
|
||||
|
||||
bool found = false;
|
||||
|
||||
ParseEntities();
|
||||
parseEntities();
|
||||
|
||||
for ( int i = 1; i < m_num_entities; i++ ) {
|
||||
cl = ValueForKey (&m_entities[i], "classname");
|
||||
cl = getValueForKey (&m_entities[i], "classname");
|
||||
if ( !strcmp( cl, "info_player_start" ) ) {
|
||||
GetVectorForKey( &m_entities[i], "origin", origin );
|
||||
getVectorForKey( &m_entities[i], "origin", origin );
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if ( !strcmp( cl, "info_player_deathmatch" ) ) {
|
||||
GetVectorForKey( &m_entities[i], "origin", origin );
|
||||
getVectorForKey( &m_entities[i], "origin", origin );
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -703,7 +703,7 @@ const BSPEntity * BspLoader::getEntityByValue( const char* name, const char* val
|
||||
|
||||
const BSPEntity& ent = m_entities[i];
|
||||
|
||||
const char* cl = ValueForKey (&m_entities[i], name);
|
||||
const char* cl = getValueForKey (&m_entities[i], name);
|
||||
if ( !strcmp( cl, value ) ) {
|
||||
entity = &ent;
|
||||
break;
|
||||
|
||||
@@ -184,15 +184,15 @@ class BspLoader
|
||||
printf("Machine is Little Endian\n");
|
||||
}
|
||||
}
|
||||
bool LoadBSPFile( void* memoryBuffer);
|
||||
bool loadBSPFile( void* memoryBuffer);
|
||||
|
||||
const char* ValueForKey( const BSPEntity *ent, const char *key ) const;
|
||||
const char* getValueForKey( const BSPEntity *ent, const char *key ) const;
|
||||
|
||||
bool GetVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec );
|
||||
bool getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec );
|
||||
|
||||
float FloatForKey( const BSPEntity *ent, const char *key );
|
||||
float getFloatForKey( const BSPEntity *ent, const char *key );
|
||||
|
||||
void ParseEntities( void );
|
||||
void parseEntities( void );
|
||||
|
||||
bool findVectorByName(float* outvec,const char* name);
|
||||
|
||||
@@ -201,35 +201,35 @@ class BspLoader
|
||||
|
||||
protected:
|
||||
|
||||
void ParseFromMemory (char *buffer, int size);
|
||||
void parseFromMemory (char *buffer, int size);
|
||||
|
||||
|
||||
|
||||
bool EndOfScript (bool crossline);
|
||||
bool isEndOfScript (bool crossline);
|
||||
|
||||
bool GetToken (bool crossline);
|
||||
bool getToken (bool crossline);
|
||||
|
||||
char *copystring(const char *s);
|
||||
|
||||
void StripTrailing( char *e );
|
||||
void stripTrailing( char *e );
|
||||
|
||||
BSPKeyValuePair * ParseEpair( void );
|
||||
BSPKeyValuePair * parseEpair( void );
|
||||
|
||||
bool ParseEntity( void );
|
||||
bool parseEntity( void );
|
||||
|
||||
short LittleShort (short l);
|
||||
int LittleLong (int l);
|
||||
float LittleFloat (float l);
|
||||
short isLittleShort (short l);
|
||||
int isLittleLong (int l);
|
||||
float isLittleFloat (float l);
|
||||
|
||||
int BigLong (int l);
|
||||
short BigShort (short l);
|
||||
float BigFloat (float l);
|
||||
int isBigLong (int l);
|
||||
short isBigShort (short l);
|
||||
float isBigFloat (float l);
|
||||
|
||||
void SwapBlock( int *block, int sizeOfBlock );
|
||||
void swapBlock( int *block, int sizeOfBlock );
|
||||
|
||||
int CopyLump( BSPHeader *header, int lump, void *dest, int size );
|
||||
int copyLump( BSPHeader *header, int lump, void *dest, int size );
|
||||
|
||||
void SwapBSPFile( void );
|
||||
void swapBSPFile( void );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ subject to the following restrictions:
|
||||
#include <stdio.h> //printf debugging
|
||||
|
||||
float deltaTime = 1.f/60.f;
|
||||
|
||||
float gCollisionMargin = 0.05f;
|
||||
#include "CcdPhysicsDemo.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
@@ -77,7 +77,8 @@ btCollisionShape* shapePtr[numShapes] =
|
||||
new btBoxShape (btVector3(50,10,50)),
|
||||
#endif
|
||||
|
||||
new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)),
|
||||
new btCylinderShape (btVector3(CUBE_HALF_EXTENTS-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin)),
|
||||
//new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)),
|
||||
new btSphereShape (CUBE_HALF_EXTENTS- 0.05f),
|
||||
|
||||
//new btConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS),
|
||||
@@ -109,7 +110,7 @@ int main(int argc,char** argv)
|
||||
|
||||
ccdDemo->setCameraDistance(26.f);
|
||||
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",ccdDemo);
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,16 +191,16 @@ void CcdPhysicsDemo::clientResetScene()
|
||||
|
||||
if ((getDebugMode() & btIDebugDraw::DBG_NoHelpText))
|
||||
{
|
||||
if (ctrl->GetRigidBody()->GetCollisionShape()->GetShapeType() != SPHERE_SHAPE_PROXYTYPE)
|
||||
if (ctrl->getRigidBody()->getCollisionShape()->getShapeType() != SPHERE_SHAPE_PROXYTYPE)
|
||||
{
|
||||
ctrl->GetRigidBody()->SetCollisionShape(shapePtr[2]);
|
||||
ctrl->getRigidBody()->SetCollisionShape(shapePtr[2]);
|
||||
} else
|
||||
{
|
||||
ctrl->GetRigidBody()->SetCollisionShape(shapePtr[1]);
|
||||
ctrl->getRigidBody()->SetCollisionShape(shapePtr[1]);
|
||||
}
|
||||
|
||||
btBroadphaseProxy* bpproxy = ctrl->GetRigidBody()->m_broadphaseHandle;
|
||||
m_physicsEnvironmentPtr->GetBroadphase()->CleanProxyFromPairs(bpproxy);
|
||||
btBroadphaseProxy* bpproxy = ctrl->getRigidBody()->m_broadphaseHandle;
|
||||
m_physicsEnvironmentPtr->getBroadphase()->cleanProxyFromPairs(bpproxy);
|
||||
}
|
||||
|
||||
//stack them
|
||||
@@ -245,7 +246,7 @@ void CcdPhysicsDemo::initPhysics()
|
||||
// btOverlappingPairCache* broadphase = new btSimpleBroadphase;
|
||||
|
||||
#ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM
|
||||
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
#endif //REGISTER_CUSTOM_COLLISION_ALGORITHM
|
||||
|
||||
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
||||
@@ -255,7 +256,7 @@ void CcdPhysicsDemo::initPhysics()
|
||||
|
||||
#ifdef USER_DEFINED_FRICTION_MODEL
|
||||
btSequentialImpulseConstraintSolver* solver = (btSequentialImpulseConstraintSolver*) m_physicsEnvironmentPtr->GetConstraintSolver();
|
||||
//solver->SetContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE);
|
||||
//solver->setContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE);
|
||||
solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE);
|
||||
solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1);
|
||||
solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,USER_CONTACT_SOLVER_TYPE1);
|
||||
@@ -288,15 +289,15 @@ void CcdPhysicsDemo::initPhysics()
|
||||
btTransform ident;
|
||||
ident.setIdentity();
|
||||
ident.setOrigin(btVector3(0,0,0));
|
||||
compoundShape->AddChildShape(ident,oldShape);//
|
||||
compoundShape->addChildShape(ident,oldShape);//
|
||||
ident.setOrigin(btVector3(0,0,2));
|
||||
compoundShape->AddChildShape(ident,new btSphereShape(0.9));//
|
||||
compoundShape->addChildShape(ident,new btSphereShape(0.9));//
|
||||
}
|
||||
|
||||
for (i=0;i<gNumObjects;i++)
|
||||
{
|
||||
btCollisionShape* shape = shapePtr[shapeIndex[i]];
|
||||
shape->SetMargin(0.05f);
|
||||
shape->setMargin(gCollisionMargin);
|
||||
|
||||
bool isDyna = i>0;
|
||||
|
||||
@@ -332,9 +333,9 @@ void CcdPhysicsDemo::initPhysics()
|
||||
if (!isDyna)
|
||||
mass = 0.f;
|
||||
|
||||
btRigidBody* body = LocalCreateRigidBody(isDyna,mass,trans,shape);
|
||||
btRigidBody* body = localCreateRigidBody(isDyna,mass,trans,shape);
|
||||
|
||||
m_dynamicsWorld->AddCollisionObject(body);
|
||||
m_dynamicsWorld->addCollisionObject(body);
|
||||
|
||||
// Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS
|
||||
body->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS;
|
||||
@@ -344,7 +345,7 @@ void CcdPhysicsDemo::initPhysics()
|
||||
|
||||
#ifdef USER_DEFINED_FRICTION_MODEL
|
||||
///Advanced use: override the friction solver
|
||||
ctrl->GetRigidBody()->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1;
|
||||
ctrl->getRigidBody()->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1;
|
||||
#endif //USER_DEFINED_FRICTION_MODEL
|
||||
|
||||
}
|
||||
|
||||
@@ -185,20 +185,20 @@ bool ColladaConverter::convert()
|
||||
printf(" X is Up Data and Hiearchies must be converted!\n" );
|
||||
printf(" Conversion to X axis Up isn't currently supported!\n" );
|
||||
printf(" COLLADA_RT defaulting to Y Up \n" );
|
||||
SetGravity(btVector3(-10,0,0));
|
||||
SetCameraInfo(btVector3(1,0,0),1);
|
||||
setGravity(btVector3(-10,0,0));
|
||||
setCameraInfo(btVector3(1,0,0),1);
|
||||
break;
|
||||
case UPAXISTYPE_Y_UP:
|
||||
printf(" Y Axis is Up for this file \n" );
|
||||
printf(" COLLADA_RT set to Y Up \n" );
|
||||
SetGravity(btVector3(0,-10,0));
|
||||
SetCameraInfo(btVector3(0,1,0),0);
|
||||
setGravity(btVector3(0,-10,0));
|
||||
setCameraInfo(btVector3(0,1,0),0);
|
||||
|
||||
break;
|
||||
case UPAXISTYPE_Z_UP:
|
||||
printf(" Z Axis is Up for this file \n" );
|
||||
printf(" All Geometry and Hiearchies must be converted!\n" );
|
||||
SetGravity(btVector3(0,0,-10));
|
||||
setGravity(btVector3(0,0,-10));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -294,7 +294,7 @@ bool ColladaConverter::convert()
|
||||
const domFloat3 grav = physicsSceneRef->getTechnique_common()->getGravity()->getValue();
|
||||
printf("gravity set to %f,%f,%f\n",grav.get(0),grav.get(1),grav.get(2));
|
||||
|
||||
SetGravity(btVector3(grav.get(0),grav.get(1),grav.get(2)));
|
||||
setGravity(btVector3(grav.get(0),grav.get(1),grav.get(2)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -481,7 +481,7 @@ bool ColladaConverter::convert()
|
||||
ConstraintInput cInput;
|
||||
cInput.m_instance_physicsModelRef = instance_physicsModelRef;
|
||||
cInput.m_model = model;
|
||||
PrepareConstraints(cInput);
|
||||
prepareConstraints(cInput);
|
||||
}
|
||||
|
||||
//also don't forget the model's 'instance_physics_models!
|
||||
@@ -496,7 +496,7 @@ bool ColladaConverter::convert()
|
||||
ConstraintInput cInput;
|
||||
cInput.m_instance_physicsModelRef = instancePhysicsModelRef;
|
||||
cInput.m_model = model;
|
||||
PrepareConstraints(cInput);
|
||||
prepareConstraints(cInput);
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ bool ColladaConverter::convert()
|
||||
}
|
||||
|
||||
|
||||
void ColladaConverter::PrepareConstraints(ConstraintInput& input)
|
||||
void ColladaConverter::prepareConstraints(ConstraintInput& input)
|
||||
{
|
||||
domInstance_physics_modelRef instance_physicsModelRef = input.m_instance_physicsModelRef;
|
||||
domPhysics_modelRef model = input.m_model;
|
||||
@@ -699,7 +699,7 @@ void ColladaConverter::PreparePhysicsObject(struct btRigidBodyInput& input, bool
|
||||
|
||||
|
||||
|
||||
CcdPhysicsController* ctrl = CreatePhysicsObject(isDynamics,mass,startTransform,colShape);
|
||||
CcdPhysicsController* ctrl = createPhysicsObject(isDynamics,mass,startTransform,colShape);
|
||||
if (ctrl)
|
||||
{
|
||||
//for bodyName lookup in constraints
|
||||
@@ -764,7 +764,7 @@ bool ColladaConverter::saveAs(const char* filename)
|
||||
}
|
||||
|
||||
{
|
||||
btQuaternion quat = m_physObjects[i]->GetRigidBody()->getCenterOfMassTransform().getRotation();
|
||||
btQuaternion quat = m_physObjects[i]->getRigidBody()->getCenterOfMassTransform().getRotation();
|
||||
btVector3 axis(quat.getX(),quat.getY(),quat.getZ());
|
||||
axis[3] = 0.f;
|
||||
//check for axis length
|
||||
@@ -1035,7 +1035,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
k+=meshPart.m_triangleIndexStride;
|
||||
verts[i].setValue(fl0,fl1,fl2);
|
||||
}
|
||||
trimesh->AddTriangle(verts[0],verts[1],verts[2]);
|
||||
trimesh->addTriangle(verts[0],verts[1],verts[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
//int m_vertexStride;//use the accessor for this
|
||||
|
||||
//};
|
||||
//tindexArray->AddIndexedMesh(meshPart);
|
||||
//tindexArray->addIndexedMesh(meshPart);
|
||||
if (rbOutput.m_isDynamics)
|
||||
{
|
||||
printf("moving concave <mesh> not supported, transformed into convex\n");
|
||||
@@ -1144,7 +1144,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
domFloat fl2 = listFloats.get(k+2);
|
||||
//printf("float %f %f %f\n",fl0,fl1,fl2);
|
||||
|
||||
convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2));
|
||||
convexHullShape->addPoint(btPoint3(fl0,fl1,fl2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1192,7 +1192,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
domFloat fl2 = listFloats.get(k+2);
|
||||
//printf("float %f %f %f\n",fl0,fl1,fl2);
|
||||
|
||||
convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2));
|
||||
convexHullShape->addPoint(btPoint3(fl0,fl1,fl2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1205,10 +1205,10 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
|
||||
}
|
||||
|
||||
if (convexHullShape->GetNumVertices())
|
||||
if (convexHullShape->getNumVertices())
|
||||
{
|
||||
rbOutput.m_colShape = convexHullShape;
|
||||
printf("created convexHullShape with %i points\n",convexHullShape->GetNumVertices());
|
||||
printf("created convexHullShape with %i points\n",convexHullShape->getNumVertices());
|
||||
} else
|
||||
{
|
||||
delete convexHullShape;
|
||||
@@ -1251,7 +1251,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
|
||||
);
|
||||
}
|
||||
|
||||
rbOutput.m_compoundShape->AddChildShape(localTransform,rbOutput.m_colShape);
|
||||
rbOutput.m_compoundShape->addChildShape(localTransform,rbOutput.m_colShape);
|
||||
rbOutput.m_colShape = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
|
||||
void PreparePhysicsObject(struct btRigidBodyInput& input, bool isDynamics, float mass,btCollisionShape* colShape);
|
||||
|
||||
void PrepareConstraints(ConstraintInput& input);
|
||||
void prepareConstraints(ConstraintInput& input);
|
||||
|
||||
void ConvertRigidBodyRef( struct btRigidBodyInput& , struct btRigidBodyOutput& output );
|
||||
|
||||
@@ -76,14 +76,14 @@ public:
|
||||
const btVector3& angularMaxLimits
|
||||
) = 0;
|
||||
|
||||
virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic,
|
||||
virtual CcdPhysicsController* createPhysicsObject(bool isDynamic,
|
||||
float mass,
|
||||
const btTransform& startTransform,
|
||||
btCollisionShape* shape) = 0;
|
||||
|
||||
virtual void SetGravity(const btVector3& gravity) = 0;
|
||||
virtual void setGravity(const btVector3& gravity) = 0;
|
||||
|
||||
virtual void SetCameraInfo(const btVector3& up, int forwardAxis) = 0;
|
||||
virtual void setCameraInfo(const btVector3& up, int forwardAxis) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class MyColladaConverter : public ColladaConverter
|
||||
const btVector3& angularMaxLimits
|
||||
)
|
||||
{
|
||||
return m_demoApp->GetPhysicsEnvironment()->createUniversalD6Constraint(
|
||||
return m_demoApp->getPhysicsEnvironment()->createUniversalD6Constraint(
|
||||
ctrlRef,ctrlOther,
|
||||
localAttachmentFrameRef,
|
||||
localAttachmentOther,
|
||||
@@ -69,21 +69,21 @@ class MyColladaConverter : public ColladaConverter
|
||||
);
|
||||
}
|
||||
|
||||
virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic,
|
||||
virtual CcdPhysicsController* createPhysicsObject(bool isDynamic,
|
||||
float mass,
|
||||
const btTransform& startTransform,
|
||||
btCollisionShape* shape)
|
||||
{
|
||||
CcdPhysicsController* ctrl = m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape);
|
||||
CcdPhysicsController* ctrl = m_demoApp->localCreatePhysicsObject(isDynamic, mass, startTransform,shape);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
|
||||
virtual void SetGravity(const btVector3& grav)
|
||||
virtual void setGravity(const btVector3& grav)
|
||||
{
|
||||
m_demoApp->GetPhysicsEnvironment()->setGravity(grav.getX(),grav.getY(),grav.getZ());
|
||||
m_demoApp->getPhysicsEnvironment()->setGravity(grav.getX(),grav.getY(),grav.getZ());
|
||||
}
|
||||
virtual void SetCameraInfo(const btVector3& camUp,int forwardAxis)
|
||||
virtual void setCameraInfo(const btVector3& camUp,int forwardAxis)
|
||||
{
|
||||
m_demoApp->setCameraUp(camUp);
|
||||
m_demoApp->setCameraForwardAxis(forwardAxis);
|
||||
|
||||
@@ -122,7 +122,7 @@ void CollisionDemo::displayCallback(void) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
//GL_ShapeDrawer::DrawCoordSystem();
|
||||
//GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
int i;
|
||||
@@ -130,14 +130,14 @@ void CollisionDemo::displayCallback(void) {
|
||||
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
|
||||
|
||||
btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f);
|
||||
convexConvex.SetCachedSeperatingAxis(seperatingAxis);
|
||||
convexConvex.setCachedSeperatingAxis(seperatingAxis);
|
||||
|
||||
btPointCollector gjkOutput;
|
||||
btGjkPairDetector::ClosestPointInput input;
|
||||
input.m_transformA = tr[0];
|
||||
input.m_transformB = tr[1];
|
||||
|
||||
convexConvex.GetClosestPoints(input ,gjkOutput,0);
|
||||
convexConvex.getClosestPoints(input ,gjkOutput,0);
|
||||
|
||||
if (gjkOutput.m_hasResult)
|
||||
{
|
||||
@@ -159,23 +159,23 @@ void CollisionDemo::displayCallback(void) {
|
||||
|
||||
tr[i].getOpenGLMatrix( m );
|
||||
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
|
||||
|
||||
}
|
||||
|
||||
simplex.SetSimplexSolver(&sGjkSimplexSolver);
|
||||
simplex.setSimplexSolver(&sGjkSimplexSolver);
|
||||
btPoint3 ybuf[4],pbuf[4],qbuf[4];
|
||||
int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf);
|
||||
simplex.Reset();
|
||||
simplex.reset();
|
||||
|
||||
for (i=0;i<numpoints;i++)
|
||||
simplex.AddVertex(ybuf[i]);
|
||||
simplex.addVertex(ybuf[i]);
|
||||
|
||||
btTransform ident;
|
||||
ident.setIdentity();
|
||||
ident.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
||||
|
||||
|
||||
btQuaternion orn;
|
||||
|
||||
@@ -92,8 +92,8 @@ void CollisionInterfaceDemo::initPhysics()
|
||||
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase);
|
||||
|
||||
collisionWorld->AddCollisionObject(&objects[0]);
|
||||
collisionWorld->AddCollisionObject(&objects[1]);
|
||||
collisionWorld->addCollisionObject(&objects[0]);
|
||||
collisionWorld->addCollisionObject(&objects[1]);
|
||||
|
||||
}
|
||||
|
||||
@@ -118,30 +118,30 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
if (collisionWorld)
|
||||
collisionWorld->PerformDiscreteCollisionDetection();
|
||||
collisionWorld->performDiscreteCollisionDetection();
|
||||
|
||||
int i;
|
||||
|
||||
///one way to draw all the contact points is iterating over contact manifolds / points:
|
||||
|
||||
int numManifolds = collisionWorld->GetDispatcher()->GetNumManifolds();
|
||||
int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
|
||||
for (i=0;i<numManifolds;i++)
|
||||
{
|
||||
btPersistentManifold* contactManifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i);
|
||||
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->GetBody0());
|
||||
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->GetBody1());
|
||||
contactManifold->RefreshContactPoints(obA->m_worldTransform,obB->m_worldTransform);
|
||||
btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
|
||||
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
|
||||
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
|
||||
contactManifold->refreshContactPoints(obA->m_worldTransform,obB->m_worldTransform);
|
||||
|
||||
int numContacts = contactManifold->GetNumContacts();
|
||||
int numContacts = contactManifold->getNumContacts();
|
||||
for (int j=0;j<numContacts;j++)
|
||||
{
|
||||
btManifoldPoint& pt = contactManifold->GetContactPoint(j);
|
||||
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 1);
|
||||
|
||||
btVector3 ptA = pt.GetPositionWorldOnA();
|
||||
btVector3 ptB = pt.GetPositionWorldOnB();
|
||||
btVector3 ptA = pt.getPositionWorldOnA();
|
||||
btVector3 ptB = pt.getPositionWorldOnB();
|
||||
|
||||
glVertex3d(ptA.x(),ptA.y(),ptA.z());
|
||||
glVertex3d(ptB.x(),ptB.y(),ptB.z());
|
||||
@@ -149,10 +149,10 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
||||
}
|
||||
|
||||
//you can un-comment out this line, and then all points are removed
|
||||
//contactManifold->ClearManifold();
|
||||
//contactManifold->clearManifold();
|
||||
}
|
||||
|
||||
//GL_ShapeDrawer::DrawCoordSystem();
|
||||
//GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
|
||||
@@ -162,7 +162,7 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
||||
{
|
||||
|
||||
objects[i].m_worldTransform.getOpenGLMatrix( m );
|
||||
GL_ShapeDrawer::DrawOpenGL(m,objects[i].m_collisionShape,btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,objects[i].m_collisionShape,btVector3(1,1,1),getDebugMode());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -168,16 +168,16 @@ void ConcaveDemo::initPhysics()
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(0,-2,0));
|
||||
|
||||
CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
|
||||
CcdPhysicsController* staticTrimesh = localCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
|
||||
//enable custom material callback
|
||||
staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
||||
staticTrimesh->getRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
||||
|
||||
{
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
|
||||
startTransform.setOrigin(btVector3(2*i,1,1));
|
||||
LocalCreatePhysicsObject(true, 1, startTransform,boxShape);
|
||||
localCreatePhysicsObject(true, 1, startTransform,boxShape);
|
||||
}
|
||||
}
|
||||
m_physicsEnvironmentPtr->setGravity(-1,-10,1);
|
||||
|
||||
@@ -74,10 +74,10 @@ void ConstraintDemo::initPhysics()
|
||||
bool isDynamic = false;
|
||||
float mass = 1.f;
|
||||
|
||||
CcdPhysicsController* ctrl0 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape);
|
||||
CcdPhysicsController* ctrl0 = localCreatePhysicsObject( isDynamic,mass,trans,shape);
|
||||
trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0));
|
||||
isDynamic = true;
|
||||
CcdPhysicsController* ctrl1 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape);
|
||||
CcdPhysicsController* ctrl1 = localCreatePhysicsObject( isDynamic,mass,trans,shape);
|
||||
|
||||
|
||||
clientResetScene();
|
||||
|
||||
@@ -110,12 +110,12 @@ void btContinuousConvexCollisionDemo::initPhysics()
|
||||
shapePtr[0] = boxA;
|
||||
shapePtr[1] = boxB;
|
||||
|
||||
shapePtr[0]->SetMargin(0.01f);
|
||||
shapePtr[1]->SetMargin(0.01f);
|
||||
shapePtr[0]->setMargin(0.01f);
|
||||
shapePtr[1]->setMargin(0.01f);
|
||||
|
||||
for (int i=0;i<numObjects;i++)
|
||||
{
|
||||
btTransformUtil::CalculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
|
||||
btTransformUtil::calculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -144,7 +144,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
//GL_ShapeDrawer::DrawCoordSystem();
|
||||
//GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
int i;
|
||||
@@ -152,7 +152,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
/*for (i=0;i<numObjects;i++)
|
||||
{
|
||||
fromTrans[i].getOpenGLMatrix( m );
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]);
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -168,16 +168,16 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
btScalar subStep = s * 1.f/(float)numSubSteps;
|
||||
btTransform interpolatedTrans;
|
||||
|
||||
btTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
|
||||
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
|
||||
|
||||
//fromTrans[i].getOpenGLMatrix(m);
|
||||
//GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]);
|
||||
//GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
||||
|
||||
//toTrans[i].getOpenGLMatrix(m);
|
||||
//GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]);
|
||||
//GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
||||
|
||||
interpolatedTrans.getOpenGLMatrix( m );
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
for (i=0;i<numObjects;i++)
|
||||
{
|
||||
fromTrans[i].getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
}
|
||||
|
||||
btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0]);
|
||||
@@ -264,15 +264,15 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
btTransform hitTrans;
|
||||
btTransformUtil::IntegrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
|
||||
btTransformUtil::integrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
|
||||
|
||||
hitTrans.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode());
|
||||
|
||||
btTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
|
||||
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
|
||||
|
||||
hitTrans.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(0,-4,0));
|
||||
|
||||
LocalCreatePhysicsObject(false,0,startTransform,new btBoxShape(btVector3(30,2,30)));
|
||||
localCreatePhysicsObject(false,0,startTransform,new btBoxShape(btVector3(30,2,30)));
|
||||
|
||||
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
|
||||
{
|
||||
@@ -184,7 +184,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
vertex1 -= centroid;
|
||||
vertex2 -= centroid;
|
||||
|
||||
trimesh->AddTriangle(vertex0,vertex1,vertex2);
|
||||
trimesh->addTriangle(vertex0,vertex1,vertex2);
|
||||
|
||||
index0+=mBaseCount;
|
||||
index1+=mBaseCount;
|
||||
@@ -200,7 +200,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
btTransform trans;
|
||||
trans.setIdentity();
|
||||
trans.setOrigin(centroid);
|
||||
m_convexDemo->LocalCreatePhysicsObject(isDynamic, mass, trans,convexShape);
|
||||
m_convexDemo->localCreatePhysicsObject(isDynamic, mass, trans,convexShape);
|
||||
|
||||
mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
|
||||
|
||||
@@ -234,7 +234,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
vertex1 *= localScaling;
|
||||
vertex2 *= localScaling;
|
||||
|
||||
trimesh->AddTriangle(vertex0,vertex1,vertex2);
|
||||
trimesh->addTriangle(vertex0,vertex1,vertex2);
|
||||
}
|
||||
|
||||
btCollisionShape* convexShape = new btConvexTriangleMeshShape(trimesh);
|
||||
@@ -245,7 +245,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(20,2,0));
|
||||
|
||||
LocalCreatePhysicsObject(isDynamic, mass, startTransform,convexShape);
|
||||
localCreatePhysicsObject(isDynamic, mass, startTransform,convexShape);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void clientDisplay(void) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
//GL_ShapeDrawer::DrawCoordSystem();
|
||||
//GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
int i;
|
||||
@@ -115,14 +115,14 @@ void clientDisplay(void) {
|
||||
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
|
||||
|
||||
btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f);
|
||||
convexConvex.SetCachedSeperatingAxis(seperatingAxis);
|
||||
convexConvex.setCachedSeperatingAxis(seperatingAxis);
|
||||
|
||||
btPointCollector gjkOutput;
|
||||
btGjkPairDetector::ClosestPointInput input;
|
||||
input.m_transformA = tr[0];
|
||||
input.m_transformB = tr[1];
|
||||
|
||||
convexConvex.GetClosestPoints(input ,gjkOutput,0);
|
||||
convexConvex.getClosestPoints(input ,gjkOutput,0);
|
||||
|
||||
if (gjkOutput.m_hasResult)
|
||||
{
|
||||
@@ -142,23 +142,23 @@ void clientDisplay(void) {
|
||||
|
||||
tr[i].getOpenGLMatrix( m );
|
||||
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
|
||||
|
||||
}
|
||||
|
||||
simplex.SetSimplexSolver(&sGjkSimplexSolver);
|
||||
simplex.setSimplexSolver(&sGjkSimplexSolver);
|
||||
btPoint3 ybuf[4],pbuf[4],qbuf[4];
|
||||
int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf);
|
||||
simplex.Reset();
|
||||
simplex.reset();
|
||||
|
||||
for (i=0;i<numpoints;i++)
|
||||
simplex.AddVertex(ybuf[i]);
|
||||
simplex.addVertex(ybuf[i]);
|
||||
|
||||
btTransform ident;
|
||||
ident.setIdentity();
|
||||
ident.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
||||
|
||||
|
||||
btQuaternion orn;
|
||||
|
||||
@@ -106,7 +106,7 @@ bool createBoxShape( int shapeIndex )
|
||||
//{
|
||||
// g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) );
|
||||
|
||||
// g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 );
|
||||
// g_pConvexShapes[ shapeIndex ]->setMargin( 0.05 );
|
||||
|
||||
// g_convexShapesTransform[ shapeIndex ].setIdentity();
|
||||
|
||||
@@ -123,7 +123,7 @@ bool createBoxShape( int shapeIndex )
|
||||
//{
|
||||
// g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 25, 10, 25 ) );
|
||||
|
||||
// g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 );
|
||||
// g_pConvexShapes[ shapeIndex ]->setMargin( 0.05 );
|
||||
|
||||
// //btMatrix3x3 basis( 0.658257, 0.675022, -0.333709,
|
||||
// // -0.333120, 0.658556, 0.675023,
|
||||
@@ -138,7 +138,7 @@ bool createBoxShape( int shapeIndex )
|
||||
|
||||
g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) );
|
||||
|
||||
g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 );
|
||||
g_pConvexShapes[ shapeIndex ]->setMargin( 1e-1 );
|
||||
|
||||
g_convexShapesTransform[ shapeIndex ].setIdentity();
|
||||
|
||||
@@ -151,7 +151,7 @@ bool createSphereShape( int shapeIndex )
|
||||
{
|
||||
g_pConvexShapes[ shapeIndex ] = new btSphereShape( g_sphereRadius );
|
||||
|
||||
g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 );
|
||||
g_pConvexShapes[ shapeIndex ]->setMargin( 1e-1 );
|
||||
|
||||
g_convexShapesTransform[ shapeIndex ].setIdentity();
|
||||
g_convexShapesTransform[ shapeIndex ].setOrigin( randomPosition( g_sceneVolumeMin, g_sceneVolumeMax ) );
|
||||
@@ -196,7 +196,7 @@ bool calcPenDepth()
|
||||
btScalar squaredDistance = SIMD_INFINITY;
|
||||
btScalar delta = 0.f;
|
||||
|
||||
const btScalar margin = g_pConvexShapes[ 0 ]->GetMargin() + g_pConvexShapes[ 1 ]->GetMargin();
|
||||
const btScalar margin = g_pConvexShapes[ 0 ]->getMargin() + g_pConvexShapes[ 1 ]->getMargin();
|
||||
const btScalar marginSqrd = margin * margin;
|
||||
|
||||
btScalar maxRelErrorSqrd = 1e-3 * 1e-3;
|
||||
@@ -210,8 +210,8 @@ bool calcPenDepth()
|
||||
btVector3 seperatingAxisInA = -v * g_convexShapesTransform[ 0 ].getBasis();
|
||||
btVector3 seperatingAxisInB = v * g_convexShapesTransform[ 1 ].getBasis();
|
||||
|
||||
btVector3 pInA = g_pConvexShapes[ 0 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA );
|
||||
btVector3 qInB = g_pConvexShapes[ 1 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB );
|
||||
btVector3 pInA = g_pConvexShapes[ 0 ]->localGetSupportingVertexWithoutMargin( seperatingAxisInA );
|
||||
btVector3 qInB = g_pConvexShapes[ 1 ]->localGetSupportingVertexWithoutMargin( seperatingAxisInB );
|
||||
|
||||
btPoint3 pWorld = g_convexShapesTransform[ 0 ]( pInA );
|
||||
btPoint3 qWorld = g_convexShapesTransform[ 1 ]( qInB );
|
||||
@@ -234,8 +234,8 @@ bool calcPenDepth()
|
||||
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
|
||||
btScalar vLength = sqrt( squaredDistance );
|
||||
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -251,8 +251,8 @@ bool calcPenDepth()
|
||||
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
|
||||
btScalar vLength = sqrt( squaredDistance );
|
||||
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -271,8 +271,8 @@ bool calcPenDepth()
|
||||
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
|
||||
btScalar vLength = sqrt( squaredDistance );
|
||||
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength );
|
||||
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
|
||||
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ bool calcPenDepth()
|
||||
}
|
||||
}
|
||||
|
||||
return epaPenDepthSolver.CalcPenDepth( simplexSolver, g_pConvexShapes[ 0 ], g_pConvexShapes[ 1 ],
|
||||
return epaPenDepthSolver.calcPenDepth( simplexSolver, g_pConvexShapes[ 0 ], g_pConvexShapes[ 1 ],
|
||||
g_convexShapesTransform[ 0 ], g_convexShapesTransform[ 1 ], v,
|
||||
g_wWitnesses[ 0 ], g_wWitnesses[ 1 ], 0 );
|
||||
}
|
||||
@@ -311,11 +311,11 @@ void drawShape( int shapeIndex )
|
||||
|
||||
glMultMatrixf( m );
|
||||
|
||||
if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == BOX_SHAPE_PROXYTYPE )
|
||||
if ( g_pConvexShapes[ shapeIndex ]->getShapeType() == BOX_SHAPE_PROXYTYPE )
|
||||
{
|
||||
glutWireCube( ( ( btBoxShape* ) g_pConvexShapes[ shapeIndex ] )->GetHalfExtents().x() * 2 );
|
||||
glutWireCube( ( ( btBoxShape* ) g_pConvexShapes[ shapeIndex ] )->getHalfExtents().x() * 2 );
|
||||
}
|
||||
else if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == SPHERE_SHAPE_PROXYTYPE )
|
||||
else if ( g_pConvexShapes[ shapeIndex ]->getShapeType() == SPHERE_SHAPE_PROXYTYPE )
|
||||
{
|
||||
glutWireSphere( 1, 16, 16 );
|
||||
}
|
||||
@@ -370,7 +370,7 @@ void clientDisplay(void) {
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
glDisable( GL_LIGHTING );
|
||||
|
||||
GL_ShapeDrawer::DrawCoordSystem();
|
||||
GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
|
||||
|
||||
@@ -185,12 +185,12 @@ const float TRIANGLE_SIZE=20.f;
|
||||
tr.setOrigin(btVector3(0,-20.f,0));
|
||||
|
||||
//create ground object
|
||||
LocalCreatePhysicsObject(false,0,tr,groundShape);
|
||||
localCreatePhysicsObject(false,0,tr,groundShape);
|
||||
|
||||
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f));
|
||||
tr.setOrigin(btVector3(0,0.f,0));
|
||||
|
||||
m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape);
|
||||
m_carChassis = localCreatePhysicsObject(true,800,tr,chassisShape);
|
||||
|
||||
clientResetScene();
|
||||
|
||||
@@ -207,7 +207,7 @@ const float TRIANGLE_SIZE=20.f;
|
||||
0,0,0);
|
||||
|
||||
///never deactivate the vehicle
|
||||
m_carChassis->GetRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
|
||||
m_carChassis->getRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId);
|
||||
|
||||
@@ -218,25 +218,25 @@ const float TRIANGLE_SIZE=20.f;
|
||||
int upIndex = 1;
|
||||
int forwardIndex = 2;
|
||||
|
||||
gVehicleConstraint->SetCoordinateSystem(rightIndex,upIndex,forwardIndex);
|
||||
gVehicleConstraint->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
|
||||
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[0],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[0],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius);
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[1],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[1],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
|
||||
isFrontWheel = false;
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[2],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[2],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[3],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[3],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
@@ -276,7 +276,7 @@ void ForkLiftDemo::renderme()
|
||||
{
|
||||
updateCamera();
|
||||
|
||||
debugDrawer.SetDebugMode(getDebugMode());
|
||||
debugDrawer.setDebugMode(getDebugMode());
|
||||
float m[16];
|
||||
int i;
|
||||
|
||||
@@ -287,7 +287,7 @@ void ForkLiftDemo::renderme()
|
||||
{
|
||||
//draw wheels (cylinders)
|
||||
wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
||||
}
|
||||
|
||||
DemoApplication::renderme();
|
||||
@@ -301,14 +301,14 @@ void ForkLiftDemo::clientMoveAndDisplay()
|
||||
|
||||
{
|
||||
int steerWheelIndex = 2;
|
||||
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex);
|
||||
gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
|
||||
steerWheelIndex = 3;
|
||||
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex);
|
||||
gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
|
||||
|
||||
steerWheelIndex = 0;
|
||||
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
steerWheelIndex = 1;
|
||||
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ void ForkLiftDemo::updateCamera()
|
||||
glLoadIdentity();
|
||||
|
||||
//look at the vehicle
|
||||
m_cameraTargetPosition = m_carChassis->GetRigidBody()->m_worldTransform.getOrigin();
|
||||
m_cameraTargetPosition = m_carChassis->getRigidBody()->m_worldTransform.getOrigin();
|
||||
|
||||
//interpolate the camera height
|
||||
m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0;
|
||||
|
||||
@@ -96,18 +96,18 @@ void LinearConvexCastDemo::initPhysics()
|
||||
|
||||
btBoxShape* boxA = new btBoxShape(boxHalfExtentsA);
|
||||
/* btBU_Simplex1to4 boxB;
|
||||
boxB.AddVertex(btPoint3(-5,0,-5));
|
||||
boxB.AddVertex(btPoint3(5,0,-5));
|
||||
boxB.AddVertex(btPoint3(0,0,5));
|
||||
boxB.AddVertex(btPoint3(0,5,0));
|
||||
boxB.addVertex(btPoint3(-5,0,-5));
|
||||
boxB.addVertex(btPoint3(5,0,-5));
|
||||
boxB.addVertex(btPoint3(0,0,5));
|
||||
boxB.addVertex(btPoint3(0,5,0));
|
||||
*/
|
||||
|
||||
btBoxShape* boxB = new btBoxShape(boxHalfExtentsB);
|
||||
shapePtr[0] = boxA;
|
||||
shapePtr[1] = boxB;
|
||||
|
||||
shapePtr[0]->SetMargin(0.01f);
|
||||
shapePtr[1]->SetMargin(0.01f);
|
||||
shapePtr[0]->setMargin(0.01f);
|
||||
shapePtr[1]->setMargin(0.01f);
|
||||
|
||||
btTransform tr;
|
||||
tr.setIdentity();
|
||||
@@ -137,7 +137,7 @@ void LinearConvexCastDemo::displayCallback(void)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
//GL_ShapeDrawer::DrawCoordSystem();
|
||||
//GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
int i;
|
||||
@@ -145,7 +145,7 @@ void LinearConvexCastDemo::displayCallback(void)
|
||||
for (i=0;i<numObjects;i++)
|
||||
{
|
||||
tr[i].getOpenGLMatrix( m );
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ void LinearConvexCastDemo::displayCallback(void)
|
||||
toTransWorld.setOrigin(hitPoint);
|
||||
|
||||
toTransWorld.getOpenGLMatrix( m );
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],btVector3(0,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[0],btVector3(0,1,1),getDebugMode());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ int BMF_DrawCharacter(BMF_Font* font, char c)
|
||||
int BMF_DrawString(BMF_Font* font, const char* str)
|
||||
{
|
||||
if (!font) return 0;
|
||||
((BMF_BitmapFont*)font)->DrawString(str);
|
||||
((BMF_BitmapFont*)font)->drawString(str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -141,22 +141,22 @@ int BMF_GetCharacterWidth(BMF_Font* font, char c)
|
||||
int BMF_GetStringWidth(BMF_Font* font, char* str)
|
||||
{
|
||||
if (!font) return 0;
|
||||
return ((BMF_BitmapFont*)font)->GetStringWidth(str);
|
||||
return ((BMF_BitmapFont*)font)->getStringWidth(str);
|
||||
}
|
||||
|
||||
|
||||
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r)
|
||||
{
|
||||
if (!font) return;
|
||||
((BMF_BitmapFont*)font)->GetBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
|
||||
((BMF_BitmapFont*)font)->getBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
|
||||
}
|
||||
|
||||
int BMF_GetFontTexture(BMF_Font* font) {
|
||||
if (!font) return -1;
|
||||
return ((BMF_BitmapFont*)font)->GetTexture();
|
||||
return ((BMF_BitmapFont*)font)->getTexture();
|
||||
}
|
||||
|
||||
void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) {
|
||||
if (!font) return;
|
||||
((BMF_BitmapFont*)font)->DrawStringTexture(string, x, y, z);
|
||||
((BMF_BitmapFont*)font)->drawStringTexture(string, x, y, z);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, i
|
||||
/**
|
||||
* Convert the given @a font to a texture, and return the GL texture
|
||||
* ID of the texture. If the texture ID is bound, text can
|
||||
* be drawn using the texture by calling DrawStringTexture.
|
||||
* be drawn using the texture by calling drawStringTexture.
|
||||
*
|
||||
* @param font The font to create the texture from.
|
||||
* @return The GL texture ID of the new texture, or -1 if unable
|
||||
@@ -109,7 +109,7 @@ int BMF_GetFontTexture(BMF_Font* font);
|
||||
/**
|
||||
* Draw the given @a str at the point @a x, @a y, @a z, using
|
||||
* texture coordinates. This assumes that an appropriate texture
|
||||
* has been bound, see BMF_BitmapFont::GetTexture(). The string
|
||||
* has been bound, see BMF_BitmapFont::getTexture(). The string
|
||||
* is drawn along the positive X axis.
|
||||
*
|
||||
* @param font The font to draw with.
|
||||
|
||||
@@ -64,7 +64,7 @@ BMF_BitmapFont::~BMF_BitmapFont(void)
|
||||
}
|
||||
|
||||
|
||||
void BMF_BitmapFont::DrawString(const char* str)
|
||||
void BMF_BitmapFont::drawString(const char* str)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ void BMF_BitmapFont::DrawString(const char* str)
|
||||
}
|
||||
|
||||
|
||||
int BMF_BitmapFont::GetStringWidth(char* str)
|
||||
int BMF_BitmapFont::getStringWidth(char* str)
|
||||
{
|
||||
unsigned char c;
|
||||
int length = 0;
|
||||
@@ -105,7 +105,7 @@ int BMF_BitmapFont::GetStringWidth(char* str)
|
||||
return length;
|
||||
}
|
||||
|
||||
void BMF_BitmapFont::GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax)
|
||||
void BMF_BitmapFont::getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax)
|
||||
{
|
||||
xMin = m_fontData->xmin;
|
||||
yMin = m_fontData->ymin;
|
||||
@@ -113,7 +113,7 @@ void BMF_BitmapFont::GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yM
|
||||
yMax = m_fontData->ymax;
|
||||
}
|
||||
|
||||
int BMF_BitmapFont::GetTexture()
|
||||
int BMF_BitmapFont::getTexture()
|
||||
{
|
||||
int fWidth = m_fontData->xmax - m_fontData->xmin;
|
||||
int fHeight = m_fontData->ymax - m_fontData->ymin;
|
||||
@@ -174,7 +174,7 @@ int BMF_BitmapFont::GetTexture()
|
||||
return texId;
|
||||
}
|
||||
|
||||
void BMF_BitmapFont::DrawStringTexture(char *str, float x, float y, float z)
|
||||
void BMF_BitmapFont::drawStringTexture(char *str, float x, float y, float z)
|
||||
{
|
||||
unsigned char c;
|
||||
float pos = 0;
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
* Draws a string at the current raster position.
|
||||
* @param str The string to draw.
|
||||
*/
|
||||
void DrawString(const char* str);
|
||||
void drawString(const char* str);
|
||||
|
||||
void DrawStringMemory(char* str);
|
||||
void drawStringMemory(char* str);
|
||||
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
* @param str The string to draw.
|
||||
* @return The width of the string.
|
||||
*/
|
||||
int GetStringWidth(char* str);
|
||||
int getStringWidth(char* str);
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the font. The width and
|
||||
@@ -77,22 +77,22 @@ public:
|
||||
* box represent the extent of the font and its positioning
|
||||
* about the origin.
|
||||
*/
|
||||
void GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax);
|
||||
void getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax);
|
||||
|
||||
/**
|
||||
* Convert the font to a texture, and return the GL texture
|
||||
* ID of the texture. If the texture ID is bound, text can
|
||||
* be drawn using the texture by calling DrawStringTexture.
|
||||
* be drawn using the texture by calling drawStringTexture.
|
||||
*
|
||||
* @return The GL texture ID of the new texture, or -1 if unable
|
||||
* to create.
|
||||
*/
|
||||
int GetTexture();
|
||||
int getTexture();
|
||||
|
||||
/**
|
||||
* Draw the given @a string at the point @a x, @a y, @a z, using
|
||||
* texture coordinates. This assumes that an appropriate texture
|
||||
* has been bound, see BMF_BitmapFont::GetTexture(). The string
|
||||
* has been bound, see BMF_BitmapFont::getTexture(). The string
|
||||
* is drawn along the positive X axis.
|
||||
*
|
||||
* @param string The c-string to draw.
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
* @param y The y coordinate to start drawing at.
|
||||
* @param z The z coordinate to start drawing at.
|
||||
*/
|
||||
void DrawStringTexture(char* string, float x, float y, float z);
|
||||
void drawStringTexture(char* string, float x, float y, float z);
|
||||
|
||||
protected:
|
||||
/** Pointer to the font data. */
|
||||
|
||||
@@ -46,7 +46,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
||||
{
|
||||
}
|
||||
|
||||
virtual void DrawCoordSystem(const btTransform& tr)
|
||||
virtual void drawCoordSystem(const btTransform& tr)
|
||||
{
|
||||
float m[16];
|
||||
tr.getOpenGLMatrix(m);
|
||||
@@ -71,9 +71,9 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
||||
|
||||
float m[16];
|
||||
btTransform hitTrans;
|
||||
btTransformUtil::IntegrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||
hitTrans.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
|
||||
GL_ShapeDrawer::drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -397,8 +397,8 @@ void DemoApplication::shootBox(const btVector3& destination)
|
||||
startTransform.setOrigin(camPos);
|
||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
||||
|
||||
btRigidBody* body = this->LocalCreateRigidBody(isDynamic, mass, startTransform,boxShape);
|
||||
m_dynamicsWorld->AddCollisionObject(body);
|
||||
btRigidBody* body = this->localCreateRigidBody(isDynamic, mass, startTransform,boxShape);
|
||||
m_dynamicsWorld->addCollisionObject(body);
|
||||
|
||||
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
||||
linVel.normalize();
|
||||
@@ -420,7 +420,7 @@ void DemoApplication::shootBox(const btVector3& destination)
|
||||
startTransform.setOrigin(camPos);
|
||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
||||
|
||||
CcdPhysicsController* newBox = LocalCreatePhysicsObject(isDynamic, mass, startTransform,boxShape);
|
||||
CcdPhysicsController* newBox = localCreatePhysicsObject(isDynamic, mass, startTransform,boxShape);
|
||||
|
||||
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
||||
linVel.normalize();
|
||||
@@ -440,7 +440,7 @@ float gOldPickingDist = 0.f;
|
||||
btRigidBody* pickedBody = 0;//for deactivation state
|
||||
|
||||
|
||||
btVector3 DemoApplication::GetRayTo(int x,int y)
|
||||
btVector3 DemoApplication::getRayTo(int x,int y)
|
||||
{
|
||||
|
||||
float top = 1.f;
|
||||
@@ -482,7 +482,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
//printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y);
|
||||
//button 0, state 0 means left mouse down
|
||||
|
||||
btVector3 rayTo = GetRayTo(x,y);
|
||||
btVector3 rayTo = getRayTo(x,y);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
@@ -508,7 +508,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
float normal[3];
|
||||
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo);
|
||||
m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback);
|
||||
m_dynamicsWorld->rayTest(m_cameraPosition,rayTo,rayCallback);
|
||||
if (rayCallback.HasHit())
|
||||
{
|
||||
|
||||
@@ -539,7 +539,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
if (hitObj)
|
||||
{
|
||||
CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj);
|
||||
btRigidBody* body = physCtrl->GetRigidBody();
|
||||
btRigidBody* body = physCtrl->getRigidBody();
|
||||
if (body)
|
||||
{
|
||||
body->SetActivationState(ACTIVE_TAG);
|
||||
@@ -576,7 +576,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
float hit[3];
|
||||
float normal[3];
|
||||
btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo);
|
||||
m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback);
|
||||
m_dynamicsWorld->rayTest(m_cameraPosition,rayTo,rayCallback);
|
||||
if (rayCallback.HasHit())
|
||||
{
|
||||
|
||||
@@ -621,7 +621,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
{
|
||||
|
||||
CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj);
|
||||
btRigidBody* body = physCtrl->GetRigidBody();
|
||||
btRigidBody* body = physCtrl->getRigidBody();
|
||||
|
||||
if (body && !body->IsStatic())
|
||||
{
|
||||
@@ -704,14 +704,14 @@ void DemoApplication::mouseMotionFunc(int x,int y)
|
||||
{
|
||||
//keep it at the same picking distance
|
||||
|
||||
btVector3 newRayTo = GetRayTo(x,y);
|
||||
btVector3 newRayTo = getRayTo(x,y);
|
||||
btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]);
|
||||
btVector3 dir = newRayTo-eyePos;
|
||||
dir.normalize();
|
||||
dir *= gOldPickingDist;
|
||||
|
||||
btVector3 newPos = eyePos + dir;
|
||||
p2p->SetPivotB(newPos);
|
||||
p2p->setPivotB(newPos);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -726,14 +726,14 @@ void DemoApplication::mouseMotionFunc(int x,int y)
|
||||
{
|
||||
//keep it at the same picking distance
|
||||
|
||||
btVector3 newRayTo = GetRayTo(x,y);
|
||||
btVector3 newRayTo = getRayTo(x,y);
|
||||
btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]);
|
||||
btVector3 dir = newRayTo-eyePos;
|
||||
dir.normalize();
|
||||
dir *= gOldPickingDist;
|
||||
|
||||
btVector3 newPos = eyePos + dir;
|
||||
p2p->SetPivotB(newPos);
|
||||
p2p->setPivotB(newPos);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -741,11 +741,11 @@ void DemoApplication::mouseMotionFunc(int x,int y)
|
||||
|
||||
|
||||
|
||||
btRigidBody* DemoApplication::LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
|
||||
btRigidBody* DemoApplication::localCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
|
||||
{
|
||||
btVector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
shape->CalculateLocalInertia(mass,localInertia);
|
||||
shape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
btMassProps massProps(0.f,localInertia);
|
||||
|
||||
@@ -765,7 +765,7 @@ btRigidBody* DemoApplication::LocalCreateRigidBody(bool isDynamic, float mass, c
|
||||
|
||||
|
||||
///Very basic import
|
||||
CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
|
||||
CcdPhysicsController* DemoApplication::localCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
|
||||
{
|
||||
|
||||
startTransforms[numObjects] = startTransform;
|
||||
@@ -779,7 +779,7 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
|
||||
int i = numObjects;
|
||||
{
|
||||
gShapePtr[i] = shape;
|
||||
gShapePtr[i]->SetMargin(0.05f);
|
||||
gShapePtr[i]->setMargin(0.05f);
|
||||
|
||||
btQuaternion orn = startTransform.getRotation();
|
||||
|
||||
@@ -806,7 +806,7 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
|
||||
|
||||
if (isDynamic)
|
||||
{
|
||||
gShapePtr[i]->CalculateLocalInertia(ccdObjectCi.m_mass,localInertia);
|
||||
gShapePtr[i]->calculateLocalInertia(ccdObjectCi.m_mass,localInertia);
|
||||
}
|
||||
|
||||
ccdObjectCi.m_localInertiaTensor = localInertia;
|
||||
@@ -816,10 +816,10 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
|
||||
physObjects[i]= new CcdPhysicsController( ccdObjectCi);
|
||||
|
||||
// Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS
|
||||
physObjects[i]->GetRigidBody()->m_ccdSquareMotionTreshold = 0.f;
|
||||
physObjects[i]->getRigidBody()->m_ccdSquareMotionTreshold = 0.f;
|
||||
|
||||
//Experimental: better estimation of CCD Time of Impact:
|
||||
//physObjects[i]->GetRigidBody()->m_ccdSweptShereRadius = 0.5*CUBE_HALF_EXTENTS;
|
||||
//physObjects[i]->getRigidBody()->m_ccdSweptShereRadius = 0.5*CUBE_HALF_EXTENTS;
|
||||
|
||||
m_physicsEnvironmentPtr->addCcdPhysicsController( physObjects[i]);
|
||||
|
||||
@@ -837,11 +837,11 @@ void DemoApplication::renderme()
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
int numObjects = m_dynamicsWorld->GetNumCollisionObjects();
|
||||
int numObjects = m_dynamicsWorld->getNumCollisionObjects();
|
||||
btVector3 wireColor(1,0,0);
|
||||
for (int i=0;i<numObjects;i++)
|
||||
{
|
||||
btCollisionObject* colObj = m_dynamicsWorld->GetCollisionObjectArray()[i];
|
||||
btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
colObj->m_worldTransform.getOpenGLMatrix(m);
|
||||
|
||||
btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
|
||||
@@ -871,7 +871,7 @@ void DemoApplication::renderme()
|
||||
}
|
||||
}
|
||||
|
||||
GL_ShapeDrawer::DrawOpenGL(m,colObj->m_collisionShape,wireColor,getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,colObj->m_collisionShape,wireColor,getDebugMode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@ void DemoApplication::renderme()
|
||||
{
|
||||
|
||||
CcdPhysicsController* ctrl = m_physicsEnvironmentPtr->GetPhysicsController(i);
|
||||
btRigidBody* body = ctrl->GetRigidBody();
|
||||
btRigidBody* body = ctrl->getRigidBody();
|
||||
|
||||
body->m_worldTransform.getOpenGLMatrix( m );
|
||||
|
||||
@@ -919,7 +919,7 @@ void DemoApplication::renderme()
|
||||
wireColor = btVector3(0.f,0.0f,1.f);
|
||||
}
|
||||
///color differently for active, sleeping, wantsdeactivation states
|
||||
if (ctrl->GetRigidBody()->GetActivationState() == 1) //active
|
||||
if (ctrl->getRigidBody()->GetActivationState() == 1) //active
|
||||
{
|
||||
if (i & 1)
|
||||
{
|
||||
@@ -929,7 +929,7 @@ void DemoApplication::renderme()
|
||||
wireColor += btVector3 (.5f,0.f,0.f);
|
||||
}
|
||||
}
|
||||
if (ctrl->GetRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING
|
||||
if (ctrl->getRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING
|
||||
{
|
||||
if (i & 1)
|
||||
{
|
||||
@@ -941,8 +941,8 @@ void DemoApplication::renderme()
|
||||
}
|
||||
|
||||
char extraDebug[125];
|
||||
sprintf(extraDebug,"Island:%i, Body:%i",ctrl->GetRigidBody()->m_islandTag1,ctrl->GetRigidBody()->m_debugBodyId);
|
||||
ctrl->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug);
|
||||
sprintf(extraDebug,"Island:%i, Body:%i",ctrl->getRigidBody()->m_islandTag1,ctrl->getRigidBody()->m_debugBodyId);
|
||||
ctrl->getRigidBody()->getCollisionShape()->setExtraDebugInfo(extraDebug);
|
||||
|
||||
float vec[16];
|
||||
btTransform ident;
|
||||
@@ -950,7 +950,7 @@ void DemoApplication::renderme()
|
||||
ident.getOpenGLMatrix(vec);
|
||||
|
||||
|
||||
GL_ShapeDrawer::DrawOpenGL(m,ctrl->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,ctrl->getRigidBody()->getCollisionShape(),wireColor,getDebugMode());
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class DemoApplication
|
||||
m_debugMode = mode;
|
||||
}
|
||||
|
||||
CcdPhysicsEnvironment* GetPhysicsEnvironment()
|
||||
CcdPhysicsEnvironment* getPhysicsEnvironment()
|
||||
{
|
||||
return m_physicsEnvironmentPtr;
|
||||
}
|
||||
@@ -142,11 +142,11 @@ class DemoApplication
|
||||
///Demo functions
|
||||
void shootBox(const btVector3& destination);
|
||||
|
||||
btVector3 GetRayTo(int x,int y);
|
||||
btVector3 getRayTo(int x,int y);
|
||||
|
||||
CcdPhysicsController* LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
CcdPhysicsController* localCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
|
||||
btRigidBody* LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
btRigidBody* localCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
|
||||
|
||||
///callback methods by glut
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ GLDebugDrawer::GLDebugDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
void GLDebugDrawer::DrawLine(const btVector3& from,const btVector3& to,const btVector3& color)
|
||||
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
|
||||
{
|
||||
if (m_debugMode > 0)
|
||||
{
|
||||
@@ -34,13 +34,13 @@ void GLDebugDrawer::DrawLine(const btVector3& from,const btVector3& to,const btV
|
||||
}
|
||||
}
|
||||
|
||||
void GLDebugDrawer::SetDebugMode(int debugMode)
|
||||
void GLDebugDrawer::setDebugMode(int debugMode)
|
||||
{
|
||||
m_debugMode = debugMode;
|
||||
|
||||
}
|
||||
|
||||
void GLDebugDrawer::DrawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
|
||||
void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
|
||||
{
|
||||
if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
|
||||
{
|
||||
|
||||
@@ -13,13 +13,13 @@ public:
|
||||
|
||||
GLDebugDrawer();
|
||||
|
||||
virtual void DrawLine(const btVector3& from,const btVector3& to,const btVector3& color);
|
||||
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
|
||||
|
||||
virtual void DrawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color);
|
||||
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color);
|
||||
|
||||
virtual void SetDebugMode(int debugMode);
|
||||
virtual void setDebugMode(int debugMode);
|
||||
|
||||
virtual int GetDebugMode() const { return m_debugMode;}
|
||||
virtual int getDebugMode() const { return m_debugMode;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ subject to the following restrictions:
|
||||
#include "BMF_Api.h"
|
||||
#include <stdio.h> //printf debugging
|
||||
|
||||
void GL_ShapeDrawer::DrawCoordSystem() {
|
||||
void GL_ShapeDrawer::drawCoordSystem() {
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
@@ -67,7 +67,7 @@ class GlDrawcallback : public btTriangleCallback
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void ProcessTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
|
||||
{
|
||||
public:
|
||||
virtual void InternalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
|
||||
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
|
||||
{
|
||||
glBegin(GL_TRIANGLES);//LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
@@ -104,28 +104,28 @@ public:
|
||||
};
|
||||
|
||||
|
||||
void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
||||
void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
||||
{
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf(m);
|
||||
|
||||
if (shape->GetShapeType() == COMPOUND_SHAPE_PROXYTYPE)
|
||||
if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
|
||||
{
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
||||
for (int i=compoundShape->GetNumChildShapes()-1;i>=0;i--)
|
||||
for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
|
||||
{
|
||||
btTransform childTrans = compoundShape->GetChildTransform(i);
|
||||
const btCollisionShape* colShape = compoundShape->GetChildShape(i);
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
||||
float childMat[16];
|
||||
childTrans.getOpenGLMatrix(childMat);
|
||||
DrawOpenGL(childMat,colShape,color,debugMode);
|
||||
drawOpenGL(childMat,colShape,color,debugMode);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
//DrawCoordSystem();
|
||||
//drawCoordSystem();
|
||||
|
||||
//glPushMatrix();
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
@@ -137,12 +137,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
|
||||
if (!(debugMode & btIDebugDraw::DBG_DrawWireframe))
|
||||
{
|
||||
switch (shape->GetShapeType())
|
||||
switch (shape->getShapeType())
|
||||
{
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
|
||||
btVector3 halfExtent = boxShape->GetHalfExtents();
|
||||
btVector3 halfExtent = boxShape->getHalfExtents();
|
||||
glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]);
|
||||
glutSolidCube(1.0);
|
||||
useWireframeFallback = false;
|
||||
@@ -160,7 +160,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
|
||||
float radius = sphereShape->GetMargin();//radius doesn't include the margin, so draw with margin
|
||||
float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
|
||||
glutSolidSphere(radius,10,10);
|
||||
useWireframeFallback = false;
|
||||
break;
|
||||
@@ -169,8 +169,8 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
case CONE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
|
||||
float radius = coneShape->GetRadius();//+coneShape->GetMargin();
|
||||
float height = coneShape->GetHeight();//+coneShape->GetMargin();
|
||||
float radius = coneShape->getRadius();//+coneShape->getMargin();
|
||||
float height = coneShape->getHeight();//+coneShape->getMargin();
|
||||
//glRotatef(-90.0, 1.0, 0.0, 0.0);
|
||||
glTranslatef(0.0, 0.0, -0.5*height);
|
||||
glutSolidCone(radius,height,10,10);
|
||||
@@ -188,11 +188,11 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
case CYLINDER_SHAPE_PROXYTYPE:
|
||||
{
|
||||
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
|
||||
int upAxis = cylinder->GetUpAxis();
|
||||
int upAxis = cylinder->getUpAxis();
|
||||
|
||||
GLUquadricObj *quadObj = gluNewQuadric();
|
||||
float radius = cylinder->GetRadius();
|
||||
float halfHeight = cylinder->GetHalfExtents()[upAxis];
|
||||
float radius = cylinder->getRadius();
|
||||
float halfHeight = cylinder->getHalfExtents()[upAxis];
|
||||
|
||||
glPushMatrix();
|
||||
switch (upAxis)
|
||||
@@ -244,7 +244,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
if (useWireframeFallback)
|
||||
{
|
||||
/// for polyhedral shapes
|
||||
if (shape->IsPolyhedral())
|
||||
if (shape->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
|
||||
|
||||
@@ -253,10 +253,10 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0;i<polyshape->GetNumEdges();i++)
|
||||
for (i=0;i<polyshape->getNumEdges();i++)
|
||||
{
|
||||
btPoint3 a,b;
|
||||
polyshape->GetEdge(i,a,b);
|
||||
polyshape->getEdge(i,a,b);
|
||||
|
||||
glVertex3f(a.getX(),a.getY(),a.getZ());
|
||||
glVertex3f(b.getX(),b.getY(),b.getZ());
|
||||
@@ -269,24 +269,24 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
if (debugMode==btIDebugDraw::DBG_DrawFeaturesText)
|
||||
{
|
||||
glRasterPos3f(0.0, 0.0, 0.0);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo());
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->getExtraDebugInfo());
|
||||
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
for (i=0;i<polyshape->GetNumVertices();i++)
|
||||
for (i=0;i<polyshape->getNumVertices();i++)
|
||||
{
|
||||
btPoint3 vtx;
|
||||
polyshape->GetVertex(i,vtx);
|
||||
polyshape->getVertex(i,vtx);
|
||||
glRasterPos3f(vtx.x(), vtx.y(), vtx.z());
|
||||
char buf[12];
|
||||
sprintf(buf," %d",i);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||
}
|
||||
|
||||
for (i=0;i<polyshape->GetNumPlanes();i++)
|
||||
for (i=0;i<polyshape->getNumPlanes();i++)
|
||||
{
|
||||
btVector3 normal;
|
||||
btPoint3 vtx;
|
||||
polyshape->GetPlane(normal,vtx,i);
|
||||
polyshape->getPlane(normal,vtx,i);
|
||||
btScalar d = vtx.dot(normal);
|
||||
|
||||
glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d);
|
||||
@@ -301,7 +301,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
}
|
||||
}
|
||||
|
||||
if (shape->GetShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btTriangleMeshShape* concaveMesh = (btTriangleMeshShape*) shape;
|
||||
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
@@ -313,12 +313,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
|
||||
GlDrawcallback drawCallback;
|
||||
|
||||
concaveMesh->ProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (shape->GetShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
||||
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
|
||||
|
||||
@@ -326,7 +326,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
||||
TriangleGlDrawcallback drawCallback;
|
||||
convexMesh->GetStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
convexMesh->getStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
|
||||
}
|
||||
|
||||
@@ -335,12 +335,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z());
|
||||
if (debugMode&btIDebugDraw::DBG_DrawText)
|
||||
{
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetName());
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getName());
|
||||
}
|
||||
|
||||
if (debugMode& btIDebugDraw::DBG_DrawFeaturesText)
|
||||
{
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetExtraDebugInfo());
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getExtraDebugInfo());
|
||||
}
|
||||
glEnable(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ class GL_ShapeDrawer
|
||||
{
|
||||
public:
|
||||
|
||||
static void DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
||||
static void DrawCoordSystem();
|
||||
static void drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
||||
static void drawCoordSystem();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -34,16 +34,16 @@ GL_Simplex1to4::GL_Simplex1to4()
|
||||
}
|
||||
|
||||
///
|
||||
/// Debugging method CalcClosest calculates the closest point to the origin, using m_simplexSolver
|
||||
/// Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver
|
||||
///
|
||||
void GL_Simplex1to4::CalcClosest(float* m)
|
||||
void GL_Simplex1to4::calcClosest(float* m)
|
||||
{
|
||||
btTransform tr;
|
||||
tr.setFromOpenGLMatrix(m);
|
||||
|
||||
|
||||
|
||||
GL_ShapeDrawer::DrawCoordSystem();
|
||||
GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
if (m_simplexSolver)
|
||||
{
|
||||
|
||||
@@ -29,9 +29,9 @@ class GL_Simplex1to4 : public btBU_Simplex1to4
|
||||
|
||||
GL_Simplex1to4();
|
||||
|
||||
void CalcClosest(float* m);
|
||||
void calcClosest(float* m);
|
||||
|
||||
void SetSimplexSolver(btSimplexSolverInterface* simplexSolver) {
|
||||
void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
|
||||
m_simplexSolver = simplexSolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "RenderTexture.h"
|
||||
#include "renderTexture.h"
|
||||
#include <memory.h>
|
||||
#include "BMF_FontData.h"
|
||||
|
||||
RenderTexture::RenderTexture(int width,int height)
|
||||
renderTexture::renderTexture(int width,int height)
|
||||
:m_height(height),m_width(width)
|
||||
{
|
||||
m_buffer = new unsigned char[m_width*m_height*4];
|
||||
@@ -30,14 +30,14 @@ RenderTexture::RenderTexture(int width,int height)
|
||||
{
|
||||
for (int y=0;y<m_height;y++)
|
||||
{
|
||||
SetPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
|
||||
setPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int starty)
|
||||
void renderTexture::grapicalPrintf(char* str, BMF_FontData* fontData, int startx,int starty)
|
||||
{
|
||||
unsigned char c;
|
||||
int rasterposx = startx;
|
||||
@@ -55,7 +55,7 @@ void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int sta
|
||||
char packedColor = bitmap[y];
|
||||
float colorf = packedColor & bit ? 1.f : 0.f;
|
||||
btVector4 rgba(colorf,colorf,colorf,1.f);
|
||||
SetPixel(rasterposx+x,rasterposy+8-y-1,rgba);
|
||||
setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
|
||||
bit >>=1;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int sta
|
||||
}
|
||||
}
|
||||
|
||||
RenderTexture::~RenderTexture()
|
||||
renderTexture::~renderTexture()
|
||||
{
|
||||
delete [] m_buffer;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ subject to the following restrictions:
|
||||
#include "BMF_FontData.h"
|
||||
|
||||
///
|
||||
///RenderTexture provides a software-render context (setpixel/printf)
|
||||
///renderTexture provides a software-render context (setpixel/printf)
|
||||
///
|
||||
class RenderTexture
|
||||
class renderTexture
|
||||
{
|
||||
int m_height;
|
||||
int m_width;
|
||||
@@ -30,10 +30,10 @@ class RenderTexture
|
||||
|
||||
public:
|
||||
|
||||
RenderTexture(int width,int height);
|
||||
~RenderTexture();
|
||||
renderTexture(int width,int height);
|
||||
~renderTexture();
|
||||
|
||||
inline void SetPixel(int x,int y,const btVector4& rgba)
|
||||
inline void setPixel(int x,int y,const btVector4& rgba)
|
||||
{
|
||||
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
|
||||
|
||||
@@ -43,10 +43,10 @@ public:
|
||||
pixel[3] = (unsigned char)(255*rgba.getW());
|
||||
}
|
||||
|
||||
const unsigned char* GetBuffer() const { return m_buffer;}
|
||||
int GetWidth() const { return m_width;}
|
||||
int GetHeight() const { return m_height;}
|
||||
void Printf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0);
|
||||
const unsigned char* getBuffer() const { return m_buffer;}
|
||||
int getWidth() const { return m_width;}
|
||||
int getHeight() const { return m_height;}
|
||||
void grapicalPrintf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
/*
|
||||
Raytracer uses the Convex Raycast to visualize the Collision Shapes/Minkowski Sum.
|
||||
Raytracer uses the Convex rayCast to visualize the Collision Shapes/Minkowski Sum.
|
||||
Very basic raytracer, rendering into a texture.
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ Very basic raytracer, rendering into a texture.
|
||||
|
||||
|
||||
|
||||
#include "RenderTexture.h"
|
||||
#include "renderTexture.h"
|
||||
|
||||
btVoronoiSimplexSolver simplexSolver;
|
||||
|
||||
@@ -60,7 +60,7 @@ GL_Simplex1to4 simplex;
|
||||
btConvexShape* shapePtr[maxNumObjects];
|
||||
btTransform transforms[maxNumObjects];
|
||||
|
||||
RenderTexture* raytracePicture = 0;
|
||||
renderTexture* raytracePicture = 0;
|
||||
|
||||
int screenWidth = 128;
|
||||
int screenHeight = 128;
|
||||
@@ -90,16 +90,16 @@ int main(int argc,char** argv)
|
||||
|
||||
void Raytracer::initPhysics()
|
||||
{
|
||||
raytracePicture = new RenderTexture(screenWidth,screenHeight);
|
||||
raytracePicture = new renderTexture(screenWidth,screenHeight);
|
||||
|
||||
myBox.SetMargin(0.02f);
|
||||
myCone.SetMargin(0.2f);
|
||||
myBox.setMargin(0.02f);
|
||||
myCone.setMargin(0.2f);
|
||||
|
||||
simplex.SetSimplexSolver(&simplexSolver);
|
||||
simplex.AddVertex(btPoint3(-1,0,-1));
|
||||
simplex.AddVertex(btPoint3(1,0,-1));
|
||||
simplex.AddVertex(btPoint3(0,0,1));
|
||||
simplex.AddVertex(btPoint3(0,1,0));
|
||||
simplex.setSimplexSolver(&simplexSolver);
|
||||
simplex.addVertex(btPoint3(-1,0,-1));
|
||||
simplex.addVertex(btPoint3(1,0,-1));
|
||||
simplex.addVertex(btPoint3(0,0,1));
|
||||
simplex.addVertex(btPoint3(0,1,0));
|
||||
|
||||
|
||||
/// convex hull of 5 spheres
|
||||
@@ -123,7 +123,7 @@ void Raytracer::initPhysics()
|
||||
shapePtr[2] =convexHullShape;
|
||||
shapePtr[3] =&myMink;//myBox;//multiSphereShape
|
||||
|
||||
simplex.SetMargin(0.3f);
|
||||
simplex.setMargin(0.3f);
|
||||
|
||||
|
||||
}
|
||||
@@ -155,7 +155,7 @@ void Raytracer::displayCallback()
|
||||
transforms[i].setRotation(orn);
|
||||
}
|
||||
}
|
||||
myMink.SetTransformA(btTransform(transforms[0].getRotation()));
|
||||
myMink.setTransformA(btTransform(transforms[0].getRotation()));
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
@@ -236,7 +236,7 @@ void Raytracer::displayCallback()
|
||||
for (int y=0;y<screenHeight;y++)
|
||||
{
|
||||
btVector4 rgba(0.f,0.f,0.f,0.f);
|
||||
raytracePicture->SetPixel(x,y,rgba);
|
||||
raytracePicture->setPixel(x,y,rgba);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,12 +286,12 @@ void Raytracer::displayCallback()
|
||||
light = 1.f;
|
||||
|
||||
rgba = btVector4(light,light,light,1.f);
|
||||
raytracePicture->SetPixel(x,y,rgba);
|
||||
raytracePicture->setPixel(x,y,rgba);
|
||||
} else
|
||||
{
|
||||
//clear is already done
|
||||
//rgba = btVector4(0.f,0.f,0.f,0.f);
|
||||
//raytracePicture->SetPixel(x,y,rgba);
|
||||
//raytracePicture->setPixel(x,y,rgba);
|
||||
|
||||
}
|
||||
|
||||
@@ -306,10 +306,10 @@ void Raytracer::displayCallback()
|
||||
|
||||
extern BMF_FontData BMF_font_helv10;
|
||||
|
||||
raytracePicture->Printf("CCD RAYTRACER",&BMF_font_helv10);
|
||||
raytracePicture->grapicalPrintf("CCD RAYTRACER",&BMF_font_helv10);
|
||||
char buffer[256];
|
||||
sprintf(buffer,"%d RAYS / Frame",screenWidth*screenHeight*numObjects);
|
||||
raytracePicture->Printf(buffer,&BMF_font_helv10,0,10);
|
||||
raytracePicture->grapicalPrintf(buffer,&BMF_font_helv10,0,10);
|
||||
|
||||
|
||||
#endif //TEST_PRINTF
|
||||
@@ -321,7 +321,7 @@ void Raytracer::displayCallback()
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity(); // Reset The Modelview Matrix
|
||||
glLoadIdentity(); // reset The Modelview Matrix
|
||||
glTranslatef(0.0f,0.0f,-3.0f); // Move Into The Screen 5 Units
|
||||
|
||||
|
||||
@@ -329,11 +329,11 @@ void Raytracer::displayCallback()
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D,glTextureId );
|
||||
|
||||
const unsigned char *ptr = raytracePicture->GetBuffer();
|
||||
const unsigned char *ptr = raytracePicture->getBuffer();
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
raytracePicture->GetWidth(),raytracePicture->GetHeight(),
|
||||
raytracePicture->getWidth(),raytracePicture->getHeight(),
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
@@ -368,7 +368,7 @@ void Raytracer::displayCallback()
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
GL_ShapeDrawer::DrawCoordSystem();
|
||||
GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
@@ -386,9 +386,9 @@ void Raytracer::displayCallback()
|
||||
|
||||
transA.getOpenGLMatrix( m );
|
||||
/// draw the simplex
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1));
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1));
|
||||
/// calculate closest point from simplex to the origin, and draw this vector
|
||||
simplex.CalcClosest(m);
|
||||
simplex.calcClosest(m);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -71,7 +71,7 @@ void SimplexDemo::displayCallback()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
GL_ShapeDrawer::DrawCoordSystem();
|
||||
GL_ShapeDrawer::drawCoordSystem();
|
||||
|
||||
float m[16];
|
||||
int i;
|
||||
@@ -88,10 +88,10 @@ void SimplexDemo::displayCallback()
|
||||
transA.getOpenGLMatrix( m );
|
||||
|
||||
/// draw the simplex
|
||||
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||
|
||||
/// calculate closest point from simplex to the origin, and draw this vector
|
||||
simplex.CalcClosest(m);
|
||||
simplex.calcClosest(m);
|
||||
|
||||
}
|
||||
pitch += 0.005f;
|
||||
@@ -104,12 +104,12 @@ void SimplexDemo::displayCallback()
|
||||
void SimplexDemo::initPhysics()
|
||||
{
|
||||
|
||||
simplex.SetSimplexSolver(&simplexSolver);
|
||||
simplex.setSimplexSolver(&simplexSolver);
|
||||
|
||||
simplex.AddVertex(btPoint3(-2,0,-2));
|
||||
simplex.AddVertex(btPoint3(2,0,-2));
|
||||
simplex.AddVertex(btPoint3(0,0,2));
|
||||
simplex.AddVertex(btPoint3(0,2,0));
|
||||
simplex.addVertex(btPoint3(-2,0,-2));
|
||||
simplex.addVertex(btPoint3(2,0,-2));
|
||||
simplex.addVertex(btPoint3(0,0,2));
|
||||
simplex.addVertex(btPoint3(0,2,0));
|
||||
|
||||
shapePtr[0] = &simplex;
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void UserCollisionAlgorithm::initPhysics()
|
||||
|
||||
btVector3 maxAabb(10000,10000,10000);
|
||||
btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
|
||||
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
|
||||
|
||||
m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase);
|
||||
@@ -137,16 +137,16 @@ void UserCollisionAlgorithm::initPhysics()
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(0,-2,0));
|
||||
|
||||
CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
|
||||
CcdPhysicsController* staticTrimesh = localCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
|
||||
//enable custom material callback
|
||||
staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
||||
staticTrimesh->getRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
||||
|
||||
{
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
btCollisionShape* sphereShape = new btSphereShape(1);
|
||||
startTransform.setOrigin(btVector3(1,2*i,1));
|
||||
LocalCreatePhysicsObject(true, 1, startTransform,sphereShape);
|
||||
localCreatePhysicsObject(true, 1, startTransform,sphereShape);
|
||||
}
|
||||
}
|
||||
m_physicsEnvironmentPtr->setGravity(-1,-10,1);
|
||||
|
||||
@@ -186,12 +186,12 @@ const float TRIANGLE_SIZE=20.f;
|
||||
tr.setOrigin(btVector3(0,-20.f,0));
|
||||
|
||||
//create ground object
|
||||
LocalCreatePhysicsObject(false,0,tr,groundShape);
|
||||
localCreatePhysicsObject(false,0,tr,groundShape);
|
||||
|
||||
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f));
|
||||
tr.setOrigin(btVector3(0,0.f,0));
|
||||
|
||||
m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape);
|
||||
m_carChassis = localCreatePhysicsObject(true,800,tr,chassisShape);
|
||||
|
||||
clientResetScene();
|
||||
|
||||
@@ -208,7 +208,7 @@ const float TRIANGLE_SIZE=20.f;
|
||||
0,0,0);
|
||||
|
||||
///never deactivate the vehicle
|
||||
m_carChassis->GetRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
|
||||
m_carChassis->getRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
|
||||
|
||||
gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId);
|
||||
|
||||
@@ -219,25 +219,25 @@ const float TRIANGLE_SIZE=20.f;
|
||||
int upIndex = 1;
|
||||
int forwardIndex = 2;
|
||||
|
||||
gVehicleConstraint->SetCoordinateSystem(rightIndex,upIndex,forwardIndex);
|
||||
gVehicleConstraint->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
|
||||
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[0],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[0],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius);
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[1],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[1],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
|
||||
isFrontWheel = false;
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[2],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[2],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
|
||||
gVehicleConstraint->AddWheel(&wheelMotionState[3],
|
||||
gVehicleConstraint->addWheel(&wheelMotionState[3],
|
||||
(PHY__Vector3&)connectionPointCS0,
|
||||
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
|
||||
|
||||
@@ -277,7 +277,7 @@ void VehicleDemo::renderme()
|
||||
{
|
||||
updateCamera();
|
||||
|
||||
debugDrawer.SetDebugMode(getDebugMode());
|
||||
debugDrawer.setDebugMode(getDebugMode());
|
||||
float m[16];
|
||||
int i;
|
||||
|
||||
@@ -288,7 +288,7 @@ void VehicleDemo::renderme()
|
||||
{
|
||||
//draw wheels (cylinders)
|
||||
wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m);
|
||||
GL_ShapeDrawer::DrawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
||||
GL_ShapeDrawer::drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
||||
}
|
||||
|
||||
DemoApplication::renderme();
|
||||
@@ -302,14 +302,14 @@ void VehicleDemo::clientMoveAndDisplay()
|
||||
|
||||
{
|
||||
int steerWheelIndex = 2;
|
||||
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex);
|
||||
gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
|
||||
steerWheelIndex = 3;
|
||||
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex);
|
||||
gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
|
||||
|
||||
steerWheelIndex = 0;
|
||||
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
steerWheelIndex = 1;
|
||||
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
|
||||
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ void VehicleDemo::updateCamera()
|
||||
glLoadIdentity();
|
||||
|
||||
//look at the vehicle
|
||||
m_cameraTargetPosition = m_carChassis->GetRigidBody()->m_worldTransform.getOrigin();
|
||||
m_cameraTargetPosition = m_carChassis->getRigidBody()->m_worldTransform.getOrigin();
|
||||
|
||||
//interpolate the camera height
|
||||
m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0;
|
||||
|
||||
Reference in New Issue
Block a user