Collision Detection code not working... please help..

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
codebox
Posts: 8
Joined: Thu Nov 03, 2005 10:47 am
Location: Karachi, Pakistan
Contact:

Collision Detection code not working... please help..

Post by codebox »

hi again everyone :)

i m unable to get the collision detection to work. here is my code. please tell me what am i doing wrong here :)

when i use my arrow keys and go ahead and hit the box model i have imported (uvbox3.obj), i just pass through it without any collision being detected. any help is highly appreciated :)

thanks a lot.

Code: Select all

#include <irrlicht.h>

using namespace irr;

IrrlichtDevice* device = 0; 

int main()
{  
    device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 16, false, false, false);
    
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
          
    scene::ISceneNode* mynode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("uvbox3.obj"));
    mynode->setPosition(core::vector3df(0,0,10));   
    mynode->setMaterialFlag(video::EMF_LIGHTING, false);
    mynode->setMaterialTexture(0, driver->getTexture("wall.jpg"));
    
    scene::ITriangleSelector* selector = 0;
           
    if (mynode)
    {                       
        selector = smgr->createTriangleSelectorFromBoundingBox(mynode);
        mynode->setTriangleSelector(selector);
        selector->drop();
    }    
    
    scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
    camera->setPosition(core::vector3df(-3,3,-5));
    
    scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(selector, 
                                                                     camera, 
                                                                     core::vector3df(10,20,10), 
                                                                     core::vector3df(0,0,0), 
                                                                     core::vector3df(0,50,0));
    
    camera->addAnimator(anim);
    anim->drop();    
    
    device->getCursorControl()->setVisible(false); 
    
    while(device->run())
    {
       driver->beginScene(true, true, video::SColor(155,155,155,155));
       smgr->drawAll();
       driver->endScene();
    }

    device->drop();
    return 0;
}
you just need an start, the rest is upto your art
Maize
Posts: 163
Joined: Sat Oct 29, 2005 12:12 am
Location: In a cave...
Contact:

Post by Maize »

I didnt bother to read your code but I would reccomend my collision manager I posted about a week ago in the beginners help forum.
codebox
Posts: 8
Joined: Thu Nov 03, 2005 10:47 am
Location: Karachi, Pakistan
Contact:

Post by codebox »

thanks but i dont have visual c++.

i downloaded the collision manager files and i tried importing the visual c++ project into Dev c++. It imported successfully. I tweaked to meet the linker requirements and paths, yet i get some errors.


I have posted the errors in the original thread of collision manager which you started.

other ppl: plz help me with the code i posted above :) thanks.
you just need an start, the rest is upto your art
codebox
Posts: 8
Joined: Thu Nov 03, 2005 10:47 am
Location: Karachi, Pakistan
Contact:

Post by codebox »

interestingly,the code is now working after i scaled the mesh a litle bit..

i added this:

mynode->setScale(...);

and scaled a bit.. and it worked... so thanks..
you just need an start, the rest is upto your art
Post Reply