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;
}