# This seems like it should be simple... [solved]

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

## Recommended Posts

Hi All, So here's the deal: I'm making a 2.5D game (3D world and geometry, 2D gameplay). I need to place a mouse cursor in the game world. Everything in the game world is centered on the same point on the Z-Axis. I want the mouse cursor to also be centered at that same point. I have written a ray picking feature already, so I am able to convert the windows mouse position into screen coordinates, and then I am able to take the coordinate and convert it in a point and ray in the game world. But I can't not figure out a simple and elegant solution to placing the cursor on that ray with a z value of 0 (the position shared by all objects). Does anyone have a simple solution? And please let me know if you need any more information. Matt [Edited by - matthughson on November 12, 2005 1:07:11 AM]

##### Share on other sites
I may be totally misunderstanding what you're saying, but it sounds like you just want to intersect the ray with the plane z = 0:
t = -rayOrigin.z/rayDir.z;point = rayOrigin+t*rayDir;
Which should always work given that the picking ray will not be parallel to the plane. If that's totally off base, perhaps you could clarify a bit what you're looking for.

##### Share on other sites
It sounds like you understood the question correctly, but the only problem with that is that the ray will not always be paralell to the X-Y plane. That's because it is based on the view frustum: ie. click on the left of the screen and the ray will shot slightly to the left.

I'm thinking something like get the distance from the rays origin to the target in the z (target.z - orig.z) and multiply the normalized ray vector by that scaler. But in my head that seems like it would create an arc, rather than locking to the x-y plane...

Sorry misread ur response! Thanks, I'll give her a shot!

Update: Works great! Thanks!

Matt

[Edited by - matthughson on November 12, 2005 1:52:54 AM]

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633690
• Total Posts
3013339
×