Implementing axis lines in a model viewer

Started by
0 comments, last by Zipster 16 years, 11 months ago
Hi, I'd like to implement three colored axis lines that indicate the world orientation in my simple model/scene viewer. Up until now all objects have been part of my scene graph as a hierarchy, but these lines are different. They should always be in the same place on the screen regardless of camera orientation but should of course always be rotated like the camera. Could anyone suggest a way to achieve this? The lines are at the moment implemented as scene nodes and I suppose one solution would be to add the lines as child nodes to the camera, which by the way is also a scene node. This way the lines would always be in view, following the camera. [Camera node] ..[Container node] ....[Blue Z-axis line] ....[Red X-axis line] ....[Green Y-axis line] One downside might be that since they are part of the scene, objects in front of them might cover them. Also they have to be translated every render call. Another option I guess is to render them to a texture which is then rendered onto the view as a quad, more like a gui element. Is there a better, more correct or more efficient way to do this or am I on to something? Thanks.
Advertisement
Orientation lines for world-space definitely seem like they should be a GUI element to me. You shouldn't have to render them onto a quad though, just render them last. Clear the depth buffer first so they don't disappear behind objects.

I would use view-space coordinates for the lines, so that you get them to stay at the same location on the screen. The directions of the lines are actually contained directly within the world-to-view matrix, either as the first three columns if you're using column vectors or rows if you're using row vectors. Each line has the same start point, and the end point is just the start point plus each line's respective direction. When you pass the coordinates to the API, make sure it doesn't perform the world-to-view transformation again - just projection.

This topic is closed to new replies.

Advertisement