I'm new to Irrlicht (just a few days). I've managed to do some mesh rendering, terrain and mouse/keyboard input. Now I have a problem with mouse picking.
What I do is (skipped some texture code, camera and so on):
Init all the stuff
Code: Select all
device=createDevice( video::EDT_DIRECT3D9, dimension2d<u32>(SCREEN_W, SCREEN_H), 16, true, true, true, 0);
if (!(device)) return 1;
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
device->setEventReceiver(&eventReciever);
Code: Select all
IAnimatedMesh* kobita_mesh = smgr->getMesh("media\\models\\kaplica.obj");
IAnimatedMeshSceneNode* kobita_node = smgr->addAnimatedMeshSceneNode( kobita_mesh);
Code: Select all
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"MWM-CraterIsleHight.png",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(60.f, 4.0f, 60.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor
3, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
Code: Select all
ITriangleSelector* s = smgr->createOctreeTriangleSelector(kobita_mesh,
kobita_node, 32);
kobita_node->setTriangleSelector(s);
s->drop();
scene::ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
Code: Select all
irr::scene::ISceneNode* selectedSceneNode = collMan->getSceneNodeFromScreenCoordinatesBB(irr::core::position2di(eventReciever.mouseX(),eventReciever.mouseX()), 0, false, 0);
x=selectedSceneNode->getPosition().X;
y=selectedSceneNode->getPosition().Y;
z=selectedSceneNode->getPosition().Z;
Could anyone can help me with it? I can upload a full code, if someone have some time to look at.
Thanks in advance...
Kulesz