Collision detection
Collision detection
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.
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
When you make your call to "getSceneNodeFromScreenCoordinatesBB()" you are outside of the main loop so therefore the engine is only going to check at initilization. Move that code into the main loop and it will check dynamically.
What is happening is that Irrlicht is checking right after you load the model to the middle of the screen and your mouse would be there because it has just been created and not moved. You never change this result because there is not code in the main loop.
What is happening is that Irrlicht is checking right after you load the model to the middle of the screen and your mouse would be there because it has just been created and not moved. You never change this result because there is not code in the main loop.
Do you mean like this? :
the same thing. It finds the object even if the mouse pointer is not on the object. Try it yourself...
Is this a bug in the getSceneNodeFromScreenCoordinatesBB function?
Code: Select all
while(device->run()) {
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;
}
driver->beginScene(true, true, irr::video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
}
Is this a bug in the getSceneNodeFromScreenCoordinatesBB function?
Works fine for me. Can you send me lb.zip or put it on a webpage or something like that ? Maybe problem is with the mesh.
And try to change rendering device to OpenGL, because it's what i'm using.
And try to change rendering device to OpenGL, because it's what i'm using.
Tomasz Nowakowski
Openoko - www.openoko.pl
Openoko - www.openoko.pl
Thank you so much for your offer, I will send you some of my meshes (they are most of the cases .obj). With opengl the problem is getting better , but it is not gone. in that example there is a point under the real mesh, where it finds also the mesh. Besides that point it works fine with that mesh.
Thank you again, that is so nice of you!!!!
sorry about that lb.zip, I have never worked with that besides with the one saigumi uses in his tutorial orthogonal, because normally I just use single meshes to create 3D buttons. But I will send xou the lb.zip too.
Thank you again, that is so nice of you!!!!
sorry about that lb.zip, I have never worked with that besides with the one saigumi uses in his tutorial orthogonal, because normally I just use single meshes to create 3D buttons. But I will send xou the lb.zip too.
has written the code, but beside me problems, than is furtherjoy wrote:Do you mean like this? :
the same thing. It finds the object even if the mouse pointer is not on the object. Try it yourself...Code: Select all
while(device->run()) { 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; } driver->beginScene(true, true, irr::video::SColor(0,100,100,100)); smgr->drawAll(); driver->endScene(); }
Is this a bug in the getSceneNodeFromScreenCoordinatesBB function?
found object, that he does not stand out.
See on this: Download
Hi, thank you for answering, but I didn't understand your command very good *sorry*
When I press on Download I come to a Russian page which I don't understand. Did you mean, that I should download http://www.compilers.narod.ru/i2k.Cult.zip to see how you solved the problem?
Thank you
When I press on Download I come to a Russian page which I don't understand. Did you mean, that I should download http://www.compilers.narod.ru/i2k.Cult.zip to see how you solved the problem?
Thank you
Hi.joy wrote:Hi, thank you for answering, but I didn't understand your command very good *sorry*
When I press on Download I come to a Russian page which I don't understand. Did you mean, that I should download http://www.compilers.narod.ru/i2k.Cult.zip to see how you solved the problem?
Thank you
Sorry, download from hear:
Click Hear
Thank you for posting your meshes. I inserted them into the code above and they were drawn fine! -BUT the collision detection still won't work right .
I am very confused. As it works with you guys and my code is not wrong I have no idea why my collision detection won't work!
I additionally see that the collision detection works worse using different renderer. With the software renderer and openGL it works ok (I mean about 80% right) and with DirectX not at all (about 99% of the cases wrong). I seems that it has to do with something like that but probably not with the code (but I am not sure at all, it is very very odd and very enoying, because I need this feature!!!)
I am very confused. As it works with you guys and my code is not wrong I have no idea why my collision detection won't work!
I additionally see that the collision detection works worse using different renderer. With the software renderer and openGL it works ok (I mean about 80% right) and with DirectX not at all (about 99% of the cases wrong). I seems that it has to do with something like that but probably not with the code (but I am not sure at all, it is very very odd and very enoying, because I need this feature!!!)
Give me you're mail or isq and We Agree about this.joy wrote:By the way I tried your main.exe and it worked fine... could you give me your code so that I can build my own one with just your code?
(If I all it is correct has translated)
My mail : i2k@yandex.ru
My isq : 349581313