Jump to content


how to make an axis?


17 replies to this topic

#1 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 29 September 2003 - 08:49 AM

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:

#2 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 29 September 2003 - 10:16 AM

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:
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#3 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 29 September 2003 - 11:27 AM

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)

#4 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 29 September 2003 - 11:41 AM

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.
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#5 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 29 September 2003 - 02:58 PM

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

#6 Noor

    Senior Member

  • Members
  • PipPipPipPip
  • 503 posts

Posted 29 September 2003 - 03:40 PM

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

#7 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 29 September 2003 - 05:15 PM

you could push the matrix and use glOrtho and render your altitude bar in screen coordinates
If Prolog is the answer, what is the question ?

#8 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 30 September 2003 - 12:42 AM

urika said:

is there a way to jump to (0,0,0) from any position?
glLoadIdentity() reset the Matrix to (0, 0, 0)
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#9 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 30 September 2003 - 07:56 AM

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

#10 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 30 September 2003 - 08:54 AM

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
If Prolog is the answer, what is the question ?

#11 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 30 September 2003 - 09:35 AM

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[i],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

#12 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 30 September 2003 - 02:24 PM

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).
If Prolog is the answer, what is the question ?

#13 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 30 September 2003 - 03:48 PM

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.

#14 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 01 October 2003 - 02:39 PM

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:

#15 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 01 October 2003 - 02:58 PM

Use push and pop matrix stacks. Do you know how to use them :blush: ?
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#16 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 01 October 2003 - 03:20 PM

yes i do :sigh:

#17 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 01 October 2003 - 03:47 PM

could you maybe post some code... maybe it will be easier to figure out what's going wrong
If Prolog is the answer, what is the question ?

#18 CyraX

    Valued Member

  • Members
  • PipPipPip
  • 144 posts

Posted 04 October 2003 - 07:10 AM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users