[SlimDX] Picking a point on a plane

Started by
14 comments, last by OppiXP 14 years, 2 months ago
Quote:As far as I understand the whole unproject thing should return coordinates from -1 to 1 as long as I stay inside the "cube" of my coordinate system.

If you're looking for a range of -1 to 1, it sounds like you're talking about view-projection space. Unproject will return world-space coordinates.

WRT the viewmatrix, you might try using the standard D3DXMatrixLookAtLH (or the SlimDX equivalent).

Just for fun, to see if things make sense, when you calculate the intersect position, turn right around and Project that point using the same parameters and see if you get the mouse position.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Advertisement
That's it!!! Man! If I use Matrix.LookAtLH the whole thing works perfectly.

The next question is how can I rotate the eye vector around (0,0,0) in x and y directions with varying distance?

Quote:how can I rotate the eye vector around (0,0,0) in x and y directions with varying distance?

Are you trying to allow the camera to be translated and rotated?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Are you trying to allow the camera to be translated and rotated?


Basically I'd like the eye vector to be located on the hull of a sphere whilst looking to the center of the sphere. By using the mouse wheel the user can change the distance to the center and by moving the mouse up/down and left/right the horizontal and vertical position on the hull.

The calculation of the view matrix did that fine but obviously screwed up a few things. Could you please give me a hint how I can move the eye vector the way I explained?

Thank you very much!
A simple approach would be to initialize the cameraDistance, the sphere position, the camera up vector and the camera direction to the center of the sphere.

The mousewheel just changes the distance.

For left/right:
orthoVector = Normalize(CrossProduct(dir,up));// you may have to swap right and left to make it move correctlyif(moves right) cameraDir += smallIncrement*orthoVector;else cameraDir -= smallIncrement*orthoVector;Normalize(cameraDir);cameraPosition = spherePosition * cameraDistance*cameraDir;

For up/down
if( forward ) cameraUp += smallIncrement*cameraDir;else cameraUp -= smallIncrement*cameraDir;Normalize(cameraUp);

LookAtLH(cameraPosition, cameraPosition+cameraDir, cameraUp,...)

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Everything works fine now. Many thanks for your help!

This topic is closed to new replies.

Advertisement