how to make an axis?

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 29, 2003 at 08:49

i want to have an altitude axis on the right side of the window,
no matter how my objects move the a xis should stay on the right side with the correct values (my camera is following the objects wherever they go).
i have no idea woh to do it.
any suggestions? :wtf:

17 Replies

Please log in or register to post a reply.

40da7e74fdca33768b6714646853b3f5
0
TheLionKing 101 Sep 29, 2003 at 10:16

Change the values of the camera along with the changed value of your objects.

Use Push and Pop Matrix stacks to prevent changing the original axis :blush:

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 29, 2003 at 11:27

the a xis is not an object , i dont want it to have the properties of an object ,it should not be viewd in perspective , basically it is like the axes of a graph (only the graph itself is in 3d)

40da7e74fdca33768b6714646853b3f5
0
TheLionKing 101 Sep 29, 2003 at 11:41

I think it will be a good idea to move by using glTranslatef() to the edge of the screen and lock the camera on that position.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 29, 2003 at 14:58

i am writing the altitude every y=1000,
i am using bitmap fonts to do it ,
is there a way to jump to (0,0,0) from any position?
that way i could use the gltranslatef

E05263ec846eb85da803f56e2917962d
0
Noor 101 Sep 29, 2003 at 15:40

Why not just draw the axes (GL_LINES?) and then move it to where ever you want.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 29, 2003 at 17:15

you could push the matrix and use glOrtho and render your altitude bar in screen coordinates

40da7e74fdca33768b6714646853b3f5
0
TheLionKing 101 Sep 30, 2003 at 00:42

@urika

is there a way to jump to (0,0,0) from any position?

glLoadIdentity() reset the Matrix to (0, 0, 0)

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 30, 2003 at 07:56

glLoadidentity() makes the current position as (0,0,0) doesnt it?
that is exactly my problem , the altitude shows 0 for my object .
i think it is something with push/pop matririx.
checkng that

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 30, 2003 at 08:54

ok, you did it… neither do i exactly know what you want to do nor is it clear what is going wrong… could you restate what you want to do and what is not working ?

altitude axis : i imagine this to be a HUD that shows your current altitude above the ground. right ?

if this is the case it’s easy to render it like this :

select modelview matrix
push matrix
load identity

select projection matrix
push matrix
use glOrtho ( maybe gluOrtho2d instead )
render all HUD elements ( just the altitude bar for you )
pop matrix

select modelview matrix
pop matrix

done

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 30, 2003 at 09:35

first of all thanks all,
i will try and simplify what i am trying to do (i dont know what is a HUD).
1. i built an application that basically follows a jet and a rocket in space , their position and angles are from a file.
2. for each object there is a list of altitude and space position . the lists are fixed on the window and work great.
3. i want to add a list of numbers on the right side of the screen for every y==1000 (untill say 10000).
that means if i am looking at the jet at y=3856 i would see the number 4000 slightly higher than the jet (and to the right)(similar to hi-tech binochulars).
4. what i am trying to do now is to write the numbers in the correct place using bitmap fonts , glTranslatef(x,alt*,z)—>alt[0]==0,alt[1]==1000…
and glRaster3f(0,0,0).
5. what happens is that i always see 0 at the right side of the screen no matter where i am or what i am looking at.
6. thanks again
*

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 30, 2003 at 14:24

HUD means heads up display. in computer games this might be a radar or your healtf display (every info display that is blended over the scene).

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 30, 2003 at 15:48

i think my problem is the glLoadIdentity in the beginning of my RenderScene();
–>each frame it resets the parameters and when i draw the axis it is always 0.

F923e021a633170fb10416df23dffddd
0
urika 101 Oct 01, 2003 at 14:39

the problem is there are 2 parameters that need different things:
1) the y position is absolute – it represents the altitude and is fixed in space.
2) the x position is according to the camera position which mioves all the time.
i can show either one in the correct place but not both!
im sorry if my problem seems stupid but i just cant fix it :eek:

40da7e74fdca33768b6714646853b3f5
0
TheLionKing 101 Oct 01, 2003 at 14:58

Use push and pop matrix stacks. Do you know how to use them :blush: ?

F923e021a633170fb10416df23dffddd
0
urika 101 Oct 01, 2003 at 15:20

yes i do :sigh:

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Oct 01, 2003 at 15:47

could you maybe post some code… maybe it will be easier to figure out what’s going wrong

590e8bdac8129bd87b188df15e62d0e5
0
CyraX 101 Oct 04, 2003 at 07:10

Me back (again?? you think).
Well I had some heck of a work and less of a time. Working on a game that gives me my salary -).
Btw I had done this once earlier.
Your axis is some sort of a HUD (in case of some games). So I guess you should be really worried about the HUD type of issues. Axis is something that would always be present hence you better use Ortho projects on the model View matrix. For a better illustration you will find the tutorial in www.gametutorial.com
It will have a working code. The tutorial is about a sniper scope kind app.

http://gametutorials.com/Tutorials/OpenGL/…/OpenGL_Pg2.htm
Masking And Ortho Mode

Try it. Only difference is that he draws all the stuff @ the middle of the viewport. You can do that in the bottom : Modify the ModelView matrix - OR -
- Push Matrix
- Transform to the bottom right position
- draw axis (use texture mapping for sizzles and frills. Else good old glColor3f() draw line and so on. (as in 3DS MAx style)
- Pop Matrix. That is all you will need.