hi.
is there a build-in function in IrrLicht that converts 2D screen coordinates to 3D coordinates. or if not could anyone give me some directions on how to do it. I've google it and $%@# but no luck.
thanks.
2D to 3D coordinates
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Code: Select all
line3d<f32> testLine = smgr->getSceneCollisionManager ()->getRayFromScreenCoordinates (core::position2d< s32> pos, ICameraSceneNode * camera = 0);
after smgr->drawAll();
Code: Select all
smgr->getSceneCollisionManager()->getSceneNodeFromRayBB(testLine,0, false);
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
You didn't say what kind of collision you wanted, so I'll post a snippet that shows how to get the collision point with a plane. In this case, it's the XZ plane at Y=0, but you can set up and collide with any plane you like.
Code: Select all
static plane3df const shipPlane(vector3df(0.f, 0.f, 0.f),
vector3df(1.f, 0.f, 0.f),
vector3df(0.f, 0.f, 1.f));
position2d<s32> cursorPosition(gs_device->getCursorControl()->getPosition());
line3d<f32> ray(gs_collisionManager->getRayFromScreenCoordinates(cursorPosition, gs_tacticalCamera));
vector3df intersectWithPlane;
if(shipPlane.getIntersectionWithLine(ray.start, ray.getVector(), intersectWithPlane))
{
... and intersectWithPlane is your 3D point
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 56
- Joined: Thu Oct 12, 2006 5:15 am