It's just TOO many coordinate system changes!
I have my 3d map editor and need to pick out which triangles the mouse is over. It''s just a bit complicated for 1am though! I tried shooting a ray from the eye-point through the cursor but that doesn''t work. I know this comes up a lot but can''t think of what exactly to search for!
I''m hoping I can go to sleep now, then wake up to the answer and not waste any time!
Thanks for your help - really appreciate it.
EDIT:
How to convert a 2d window coordinate to a 3d point is a problem. I could just choose any z value and find the coord for that z which would map to the 2d window coord I have, right?
But what exact sequence of matrix transformations would I use?
Is this the process to get a 3d point to my monitor?
1)The vertices go through the world matrix
2)->view matrix
3)->projection
4)->scale to fit on backbuffer
5)->scale to fit backbuffer into my window''s client area
It looks simple-ish, but I don''t get step 4). What range is the output of the projection matrix in: 0-1 or 0-640 etc?
Oh and w00t - I have over 1000 hits (in 3 weeks, is that good?)
Read about my game, project #1
NEW (13th August): A new screenshot is up, plus diaries for week #3
John 3:16
if you are using OpenGL, use the selection buffer (technique is known as picking - there''s a NeHe tutorial on it). For directx, i dunno. I assume they have an equivalent.
Look at D3DXVec3Unproject(...) It takes screen space and changes to world space. Put the mouse coord in two points. Let z = 0 in one and z = 1 in the other. Transform them to world space with D3DXVec3Unproject. Then subtract one point from the other and you have a ray going through your scene in world space. Use whatever intersection code you want with that ( D3DX has mesh, sphere, box, and triangle intersection functions BTW ).
Jack
Jack
For this type of thing I usually get the screen position of the object or vertex and text if the mouse is over it
Search for how to do that, its kinda hard to explain but there are a few posts
If you looks at UnrealEd or similr program, they have 3 2D windows for each plane, thats an easy way to select geometry
Search for how to do that, its kinda hard to explain but there are a few posts
If you looks at UnrealEd or similr program, they have 3 2D windows for each plane, thats an easy way to select geometry
Sorted now, except if the mouse is over the edge of a triangle or one of it''s vertices then it doesn''t find any intersections.
Read about my game, project #1
NEW (13th August): A new screenshot is up, plus diaries for week #3
John 3:16
Read about my game, project #1
NEW (13th August): A new screenshot is up, plus diaries for week #3
John 3:16
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement