Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Raduprv

Calculating a straight line

This topic is 5650 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

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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!