Sign in to follow this  

Object Picking problem

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this