Calculating a straight line
I am working at an isometric map editor.
So, obviously, I have to be able to point on the screen, and select the objects that intersect with that line.
Now, I have 2 angles (the x angle (top/down) and the z angle (left/right) ).
So, basically, I want some sort of formula that would generate a line from where the mouse x on the screen (x,y) to the ground, according to those angle (the camera position can be considered fixed).
I know there were some similar questions here, but they dealed with pure 3D (I am using isometric (Ortho) mode), so things should be less fancy...
Thanks in advance,
Radu.
Height Map Editor
You will need a cursor in world-space, not just in GUI space.
So you detect a mouse motion of [x,y], do a transform using that motion on your cursor, and thats the motion.
For your tile interesection, check to see where your cursor hot-point is and work off of that.
So you detect a mouse motion of [x,y], do a transform using that motion on your cursor, and thats the motion.
For your tile interesection, check to see where your cursor hot-point is and work off of that.
A primary question is whether your GUI resides in the world or out of it; ie, do you have your gui objects being special objects in world space, or is it closer to a Windows control-type setup.
If GUI is in the world, you can probably draw some lines and do some collision testing. Not terribly hard, more grun work than anything else, I think.
Otherwise:
Take your window size and relate it to your camera view.
Have a function say Cursor2World(int x, int y) where you pass it the 2 window coords and do a transform based on window pixel size and camera viewpoint on your plane.
I forget the basic equations; something along the line of perspective equations I think.
Bugle4d
If GUI is in the world, you can probably draw some lines and do some collision testing. Not terribly hard, more grun work than anything else, I think.
Otherwise:
Take your window size and relate it to your camera view.
Have a function say Cursor2World(int x, int y) where you pass it the 2 window coords and do a transform based on window pixel size and camera viewpoint on your plane.
I forget the basic equations; something along the line of perspective equations I think.
Bugle4d
What I see is what I get, so the former is the case here. I know all the theory, I only need the ecuation
So far, I decided to use a top down view, with no x or z rotation, so everything on the GUY can be mapped as a perpendicular line to the ground, with virtually no ecuation (in fact, only a very simple ecuation).
But it would be nice to be able to actually edit my map in whiel viewing it under different angles...
Height Map Editor
So far, I decided to use a top down view, with no x or z rotation, so everything on the GUY can be mapped as a perpendicular line to the ground, with virtually no ecuation (in fact, only a very simple ecuation).
But it would be nice to be able to actually edit my map in whiel viewing it under different angles...
Height Map Editor
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement