Skip to main content
GameDev.net gamedev.net
🔒 Locked

3D axis

Started by TeSsL Apr 5, 2009 at 10:13 PM 9 replies 1.7k views
Original Post
TeSsL
TeSsL
Hihi. I would like to check if there are any available source or lib which gives the axis(as in the arrows pointing the the X,Y, and Z) for every point specified?
Zakwayda
Zakwayda
Not sure what you mean - can you be more specific?
tnutty
tnutty
x = right/left
y = up/down
z = in/out of the screen.

Do you need the model for a project or just to see how it works.
Our whole life is a opengl application.
TeSsL
TeSsL
Ya its for a project. I need an axis model which will appear on the clicked point i.e when you click on any point on the screen, it will draw the 3 arrows on that specified point. and then from there user can click on the X/Y/Z axis to move the point accordingly.
Is there calls for such 3D axis arrow model? Cause currently i am trying to draw cylinder and then move to the specified point accordingly and the math is killing me. So am wondering if there is an easier way out.
Zakwayda
Zakwayda
Is it the drawing part you're having trouble with? Or the user interface part (i.e. determining which axis was clicked and moving the point accordingly)?
TeSsL
TeSsL
Currently having trouble in transforming my axis onto the point. I got the coordinate of the point lets say(10,3,-25) but what i draw is at (0,0,0). How should i move my shapes to the point.
Lord_Evil
Lord_Evil
Have you tried glTranslate*(10, 3, -25) along with a glPush/PopMatrix pair?

Edit: you could also just render 3 lines, e.g. from (10, 3, -25) to (11, 3, -25), from (10, 3, -25) to (10, 4, -25) and from (10, 3, -25) to (10, 3, -24)
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
TeSsL
TeSsL
I tried to glTranslate*(10, 3, -25) but the cylinder disappear. But strangely when i tried drawing a point at the origin, and does the same translation it works alrite.
If i uses line, i wont be able to draw cone as the arrow. It will look abit flat.
shakurshams
shakurshams
i think you are using orthographic projection...may be you should try perspective projection rather.
Lord_Evil
Lord_Evil
You should be able to find plenty of info on line-cylinder collisions.
You might, however, want to move the "coordinate system" by dragging an axis.

Here's what I do:
- get the intersection between the mouse ray and a plane the line lies in
- if the distance between the line segment and the intersection point is below the cylinder's thickness, you potentially hit the cylinder
- project the intersection point onto the ray the line lies on and see if it is within the line segment (between start and end)
- if the cylinder was hit, store the projected point

On subsequent drags do the same and move by the distance between the previous and the current intersection point.

As for the plane, I'd suggest using an axial billboard approach: the plane includes the line but it's normal points as much to the viewer as it can. (Have look here for some explanations).

Hope that helps.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
TeSsL
TeSsL
Thanks this should help=D

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.