BSP Map collision

SFCBias

28-04-2010 19:39:08

Ive been searching the forums for ways to use OgreOde to make collisions between BSP maps. I happened to run into a post which the person edited BspLevel.cpp and converted his bsp map to a mesh internally with Ogre. (This was for OgreNewt)

MeshPtr BspLevel::ConvertToMesh(const Quake3Level& q3lvl){
int idxStart, numVertex;
int obCount = 0;

SceneManager *sceneMgr = Root::getSingleton().getSceneManager("EI_BSPMANAGER");
ManualObject *_manualObject = sceneMgr->createManualObject("BspMesh_mo");
MeshPtr _mesh;

for (int u = 0; u < q3lvl.mNumFaces; u++) {
bsp_face_t* face = &q3lvl.mFaces[u];

if (face->type == BSP_FACETYPE_NORMAL)
{
_manualObject->begin("EmptyMaterial", RenderOperation::OT_TRIANGLE_LIST);

for(int j=face->vert_start; j<face->vert_start+face->vert_count; j++){
_manualObject->textureCoord(q3lvl.mVertices[j].texture[0], q3lvl.mVertices[j].texture[1]);
_manualObject->normal(q3lvl.mVertices[j].normal[0], q3lvl.mVertices[j].normal[1], q3lvl.mVertices[j].normal[2]);
_manualObject->position(q3lvl.mVertices[j].point[0], q3lvl.mVertices[j].point[1], q3lvl.mVertices[j].point[2]);
}
for(int j=face->elem_start; j<face->elem_start+face->elem_count; j++){
_manualObject->index(static_cast<unsigned short>(q3lvl.mElements[j]));
}
_manualObject->end();
}
}
_mesh = _manualObject->convertToMesh("BspMesh", "General");
_mesh->buildTangentVectors();
_mesh->buildEdgeList();

return _mesh;
}


I changed this code slightly to make getting the sceneManager a little easier.

So problem is that the mesh is being created and i use this code to added it to OgreOde
ConfigFile cf;
cf.load("quakemap.cfg");
String mArchive = cf.getSetting("Archive");
String mMap = cf.getSetting("Map");

ResourceGroupManager::getSingleton().addResourceLocation(mArchive, "Zip",
ResourceGroupManager::getSingleton().getWorldResourceGroupName(), true);

ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
rgm.linkWorldGeometryToResourceGroup(rgm.getWorldResourceGroupName(), mMap, mSceneManager);
rgm.initialiseResourceGroup(rgm.getWorldResourceGroupName());
rgm.loadResourceGroup(rgm.getWorldResourceGroupName(), false);

Entity *bspEntity = mSceneManager->createEntity("BspEntity", "BspMesh");//The mesh that was created is called BspMesh

SceneNode *bspNode = mSceneManager->createSceneNode("BspNode");

bspNode->attachObject(bspEntity);
EntityInformer ei(bspEntity,bspNode->_getFullTransform());
Geometry *_bspGeom = ei.createStaticTriangleMesh(mWorld,mSpace);
_bspGeom->setName("BspMap");


This code SHOULD be working, infact when i load the ogretestmap.bsp the collisions are detected, not perfectly, but they are there. However when i load a bigger map(and i've tried a few) such as the chiropteradm.bsp, the collisions do not happen. Im not sure as to the reason why so im wondering if anyone else had any ideas?

rush

17-05-2010 10:23:36

i've got the same problem. Try to increase
Contact->setBouncyness(10.0);
Contact->setCoulombFriction(OgreOde::Utility::Infinity);
Contact->setForceDependentSlip(170.0);
Contact->setAdditionalFDS(170.0);


and set very high mass

that's (I suppose) because the map is very large (2000 ogremeters)

I did not solve it. with a box object it works, but not so good with spheres. Sometimes my boxes passes trough walls..

SFCBias

29-05-2010 17:52:50

I actually had found a better solution...Use OgreNewt! It works perfectly with that library, however OgreOde is alot easier IMO to use