better collision

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
aburt11
Posts: 66
Joined: Sun Jan 15, 2012 10:27 am

better collision

Post by aburt11 »

hey there,
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; 
 
 
 
}
 
thanks!
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: better collision

Post by hendu »

Yes, use a physics engine ;)
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Re: better collision

Post by blAaarg »

You're using "createOctTreeTriangleSelector()" and "addOctreeSceneNode()". Are you using the most up-to-date version of Irrlicht? Because it's now
"createOctreeTriangleSelector()", etc. (no double tT) Maybe there was a bug fix since. IDK.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
Post Reply