Im just wondering if anyone could give some help on rendering and setting up collision for Quake3 BSP. I've looked at the BSPDemo but can't get the code to work in my project. Well, it seems like it generates the data but I can't render it, when I use the code from the Demo to render, nothing shows up and it kills the framerate.
Heres the code I'm using to generate the data:
Code: Select all
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
float scaling = 1.0f;
for (int i =0; i < m_numOfLeafs; i++ )
{
bool isValidBrush = false;
tBSPLeaf* leaf = &m_pLeafs[i];
for ( int b=0; b < leaf->numOfLeafBrushes; b++ )
{
btAlignedObjectArray<btVector3> planeEquations;
tBSPBrush* brush = &m_pBrushes[m_pLeafBrushes[leaf->leafBrush + b]];
if ( brush->textureID != -1 )
{
if (m_pTextures[ brush->textureID ].textureType & BSPCONTENTS_SOLID )
{
brush->textureID = -1;
for ( int p = 0; p < brush->numOfBrushSides; p++ )
{
int sideid = brush->brushSide + p;
tBSPBrushSide* brushside = &m_pBrushSides[sideid];
int planeid = brushside->plane;
tBSPPlane* plane = &m_pPlanes[planeid];
btVector3 planeEq;
planeEq.setValue(
plane->vNormal.x,
plane->vNormal.y,
plane->vNormal.z,
scaling*-plane->d);
planeEquations.push_back(planeEq);
isValidBrush=true;
}
if (isValidBrush)
{
btAlignedObjectArray<btVector3> vertices;
btGeometryUtil::getVerticesFromPlaneEquations(planeEquations,vertices);
bool isEntity = false;
btVector3 entityTarget(0.f,0.f,0.f);
addConvexVerticesCollider(vertices,isEntity,entityTarget);
}
}
}
}
}
Just a simple method of drawing the collision data in wireframe or poly's would be much appreciated, without the use of any external methods like in the Demo's.
Thanks for your help.