Hi..
I am working on first person shooter game engine, i need to create ray from camera. I know only camera's angle, origin, and the screen coordinates of mouse cursor. Do anyone know how can I calculate the ray direction?
thanks in advance[/u]
picking - sending ray from camera, depending on mouse coords
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Code: Select all
// from mouse coordinates:
core::vector2d<s32> mousePos( X, Y);
core::line3d<f32> yourRay = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(mousePos, yourCameraOrNorhingForActiveCamHere);
But usually you want to shoot from the screen center, so you can directly use camera +z vector. Please take a look at the irrlicht-1.7.1\examples\07.Collision to have some better explanation. As a whole, you can use the collision demo as a base.
Please post such questions in the "Beginner`s help" section. Thank you and good luck! See ya around...
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."