Collision detection
Posted: Mon Jul 05, 2004 11:45 am
Just the next wonderful amazing post to the topic collision detection
After having some other stuff done I decided to try the collision detection again which I had already problems with (topic: http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2895). Anyway it still doesn't work. I tried to reduce the code as far as possible (using saigumis orthographic tutorial) and even don't use the orthographic view anymore.
That's left :
#include <irrlicht.h>
int main(){
irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_DIRECTX8, irr::core::dimension2d<irr::s32>(512, 384), 16, false, false, 0);
device->getFileSystem()->addZipFileArchive("lb.zip",true,true);
device->getFileSystem()->addZipFileArchive("Release/lb.zip",true,true);
device->getFileSystem()->addZipFileArchive("lb.zip",true,true);
device->setWindowCaption(L"Orthogonal Demo");
irr::video::IVideoDriver* driver = device->getVideoDriver();
irr::scene::ISceneManager* smgr = device->getSceneManager();
irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0,irr::core::vector3df(0.0f, 0.0f, 1.0f),irr::core::vector3df(0,0,0));
irr::scene::ISceneNode* marker = smgr->addAnimatedMeshSceneNode(smgr->getMesh("tile_3.ms3d"),0,-1,irr::core::vector3df(1.0f,0.0f,-1.0f),irr::core::vector3df(0.0f,0.0f,0.0f));
marker->setMaterialTexture(0, driver->getTexture("dummy.bmp"));
marker->setMaterialFlag(irr::video::EMF_LIGHTING, false);
irr::core::position2d<irr::s32> cursorPos = device->getCursorControl()->getPosition();
irr::scene::ISceneCollisionManager* pSCollMan = device->getSceneManager()->getSceneCollisionManager();
irr::scene::ISceneNode* selectedNode = pSCollMan->getSceneNodeFromScreenCoordinatesBB(cursorPos,1);
if (selectedNode != NULL)
{
int i=1;
}
while(device->run()) {
driver->beginScene(true, true, irr::video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
The red section is what I added. The problem is that it doesn't matter where my mousepointer is; it always finds a scenenode. May be someone could try it himself and say if he has the same problem. Or maybe the error is obvious, then I would be glad for any suggestions.
Thank you in advance.
After having some other stuff done I decided to try the collision detection again which I had already problems with (topic: http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2895). Anyway it still doesn't work. I tried to reduce the code as far as possible (using saigumis orthographic tutorial) and even don't use the orthographic view anymore.
That's left :
#include <irrlicht.h>
int main(){
irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_DIRECTX8, irr::core::dimension2d<irr::s32>(512, 384), 16, false, false, 0);
device->getFileSystem()->addZipFileArchive("lb.zip",true,true);
device->getFileSystem()->addZipFileArchive("Release/lb.zip",true,true);
device->getFileSystem()->addZipFileArchive("lb.zip",true,true);
device->setWindowCaption(L"Orthogonal Demo");
irr::video::IVideoDriver* driver = device->getVideoDriver();
irr::scene::ISceneManager* smgr = device->getSceneManager();
irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0,irr::core::vector3df(0.0f, 0.0f, 1.0f),irr::core::vector3df(0,0,0));
irr::scene::ISceneNode* marker = smgr->addAnimatedMeshSceneNode(smgr->getMesh("tile_3.ms3d"),0,-1,irr::core::vector3df(1.0f,0.0f,-1.0f),irr::core::vector3df(0.0f,0.0f,0.0f));
marker->setMaterialTexture(0, driver->getTexture("dummy.bmp"));
marker->setMaterialFlag(irr::video::EMF_LIGHTING, false);
irr::core::position2d<irr::s32> cursorPos = device->getCursorControl()->getPosition();
irr::scene::ISceneCollisionManager* pSCollMan = device->getSceneManager()->getSceneCollisionManager();
irr::scene::ISceneNode* selectedNode = pSCollMan->getSceneNodeFromScreenCoordinatesBB(cursorPos,1);
if (selectedNode != NULL)
{
int i=1;
}
while(device->run()) {
driver->beginScene(true, true, irr::video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
The red section is what I added. The problem is that it doesn't matter where my mousepointer is; it always finds a scenenode. May be someone could try it himself and say if he has the same problem. Or maybe the error is obvious, then I would be glad for any suggestions.
Thank you in advance.