with my project i have implemented irrlicht's own collision detection, unfortunately there are bugs and sometimes the camera either falls through the plane or can't move on the floor.
is there any alternative methods which can be applied to .obj and .irr scene files, not to mention characters?
Code: Select all
void redNovember::handleCollision()
{
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
}
void redNovember::LoadScene(const char* SceneModelFile)
{
ILightSceneNode* light1 = smgr->addLightSceneNode( 0, core::vector3df(0,20,10), video::SColorf(255.0f,255.0f,255.0f), 100.0f, 1 );
scene::ISceneNode* znode = 0;
model = smgr->getMesh(SceneModelFile); //placeholder.3ds
node = smgr->addAnimatedMeshSceneNode( model );
//smgr->loadScene(SceneModelFile);
node->setMaterialTexture( 0, driver->getTexture("assets/carpark.jpg") );
node->setPosition(core::vector3df(0,0,0));
node->setMaterialFlag(EMF_LIGHTING,true);
node->setMaterialFlag(EMF_FOG_ENABLE,false);
//collison detection
// node->setMaterialType((video::E_MATERIAL_TYPE)bokehDOFMaterial);
//setup xeffects materials
node->setMaterialType(EMT_SOLID);
effect->addShadowToNode(node,EFT_4PCF,ESM_BOTH);
//add collision rigid body // needs more collision stuff
znode = smgr->addAnimatedMeshSceneNode(model);
znode->getMaterial(0).EmissiveColor.set(0,0,0,0);
if (model)
znode = smgr->addOctTreeSceneNode(model->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (znode)
{
znode->setPosition(core::vector3df(0,0,0));
selector = smgr->createOctTreeTriangleSelector(model->getMesh(0), znode, 128);
znode->setTriangleSelector(selector);
selector->drop();
}
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
selectedSceneNode = 0;
lastSelectedSceneNode = 0;
}