Object Picking problem

Started by
1 comment, last by ilian 19 years, 6 months ago
My goal is to trace a ray from the mosue cursor position into the scren and see what it hits. Due to the API I am using, this is the only information I have: Position of the Camera in world coordinates. Direction/angles the camera is looking. mouse coordinates in screen space. the mouse coordiantes in world coordinates on the near plane of the frustrum. So since I allready have the position, I now just need a direction to draw my line, is it possible to get from only this info? The obvious simple case is that if the mouse is in the exact center of the screen, I can use the cameras direction to pick my object. But what about, when the cursor is not in the exact center? I should be able to use its position in world coordiantes on teh nearplane, and the cameras world posistion/angle to get the proper direction, right? Im just not sure how. Anyone want to help give me a kick start on this?
Advertisement
If you have "the mouse coordiantes in world coordinates on the near plane of the frustrum" and you have the camera position in world coords, then you have a direction vector (Worldmousepos - CameraPosition).

Luck!
Guimo
hey! that was quite obvious, wasnt it!

I just couldnt see it for some reason, but It definately makes sense, got it working, thanks a lot for the help.

This topic is closed to new replies.

Advertisement