#### Archived

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

# Calculating a straight line

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

## 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 on other sites
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 on other sites
Yes, basically, what I need is a GUI to world conversion.

Height Map Editor

##### 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:
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 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

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

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633268
• Total Posts
3011142
• ### Who's Online (See full list)

There are no registered users currently online

×