Archived

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

Quick Question Thx.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i got a quick question. right now i am looking at this first person shooter game source code and he is using huge values in glVertex3f() like 300, 100, -321 or whatever. just much bigger values than usual. so i went to how he set up his viewing stuff and he used this line: gluPerspective(60.0f,(GLdouble)width/(GLdouble)height,1.0f,1250.0f); but in nehes tutorials and such, when they do that same thing, and they use really small values like 1.0 and stuff in glVertex3f() and it covers a big area. how is he using such big values, how is he doing that. the url to the source code is: http://www.gldomain.com/programs/FirstPersonShooter.zip well thanks. i hope you understood what i said up that. i was alittle hasty, i have school.... well thanks alot

Share this post


Link to post
Share on other sites
Have you ever looked at a professional level editor for a FPS (QRadiant, UnrealEd, etc.). Did you notice that the default size value for most objects is 128, not 0.2 or anything that small - in "real" projects you should stick to any value scale that you find most appropriate - for example you could introduce the metric system, 100 opengl space units being equal to 100 cm. Since the available space in which you can build your world is "infinite" to you, the programmer, meaning that you''ll probably never be needing more than is made available for you, there is no reason to cramp the numbers in really small values...

Hope this clears it up for you,
Crispy

Share this post


Link to post
Share on other sites
That cleared up alot for me.
the next thing i need is to know how to put scaling in my program.
what code do i have to put in to make it so i can use bigger values for glVertex3f()
how do i make the world measauring units bigger is what am saying..
thanks for the reply

Share this post


Link to post
Share on other sites
you just use bigger numbers, there''s nothing special you have to do. it doesn;t matter what scale you use as long as you stick to it all the time. the numbers you use are relative to each other so something that is 100 wide and is 100 away from the camera looks the same as something which is 1 wide and 1 away.

Share this post


Link to post
Share on other sites
quote:
Original post by Crispy
Since the available space in which you can build your world is "infinite" to you


er... let "infinite" = constrained by max_float value though, no?

this is actually a question that''s been bothering me for a little while as i settle in on a model scale for my engine. if you use big numbers, don''t you un-necesesarily constrain the size of your world? i guess likewise, if you make the numbers to small you limit the precision with which you can move objects about in the world b/c you would run into floating-point precision barriers.

yes/no??

-me

Share this post


Link to post
Share on other sites
Ha thanks alot for the answers so quick
you guys are great!
Thanks


One more thing,
say you want to make a hud.
and your camera moves around everywhere.
how do you make the little text in the corner of the screen always move with the camera instead of just staying in the place where you first rendered it.
i saw some code like:
pustmatrix
loadidenty
draw the hud
popmatrix


they may work but it doesnt make sense to me. doesnt that just reload everything to its orignal settings and yu would still render the hud in the same place everytime..
well thanks

Share this post


Link to post
Share on other sites
I''m not a GL programmer, bear with me.

I''d suspect that you get the position of the camera and draw it right at whatever depth the camera is at in GL_ORTHO_2D mode. Someone correct me, I''m bound to be wrong.

Share this post


Link to post
Share on other sites
what i always do is draw things like the hud before i translate the cammera, that way everything that stays put is drawn before the world goes moving around.

-------------------------------------------------
Don''t take life too seriously, you''''ll never get out of it alive. -Bugs Bunny

Share this post


Link to post
Share on other sites
I may be wrong, pleaes correct me

You said you draw the hud before you do anything else with the carmera and such so the hud stays put.
what i dont see is that you draw the hud, then you move the camera in another direction and draw the world. So you could be looking in the opposite direciton of where the hud really is so you would never see the hud..
that is probley wrong, please correct me.
i really want to learn..
thanks for the replys

Share this post


Link to post
Share on other sites
Draw the HUD in ortho mode as stated by SuperRoy (though it''s not done quite like he stated) - look into glOrtho(). It doesn''t matter when you draw the HUD - you can switch to orthogonal mode at any time during the drawing of you scene. As a sidenote, if you don''t want 3d text or perspective text (so that it gets smaller if it''s farther away), always draw it in ortho mode - there are, naturally, a bunch of other uses for it too. See that Nehe''s tutorial where he introduces the "lines" kind of game (I think it was 21) for how to switch to ortho mode and back if you can''t figure it out from the help.

Palidine - that''s why I put infinite in quotation marks

Crispy

Share this post


Link to post
Share on other sites
I am understanding what you are saying with the glOrtho() stuff.
but maybe you could clear up a little thing for me real quick..
lets say the orgin 0,0 is in the middle of the screen.
and you movce the camera to the right on the x axis by like 500 or whatever so the orgin is nolonger in sight.
and then you draw the hud in glOrtho() at like the bottom-left and bottom-right of the screen. you wouldnt see the hud because you are too far to the right to see either of them because both the huds are centered around the orgin..
is that completly wrong becuase i really odnt know.
does the orgin of drawing move with the camera..
sorry if i am giving you a heart attack,
i really dont know..
thanks

Share this post


Link to post
Share on other sites
quote:
Original post by UponTheEnd
I am understanding what you are saying with the glOrtho() stuff.
but maybe you could clear up a little thing for me real quick..
lets say the orgin 0,0 is in the middle of the screen.
and you movce the camera to the right on the x axis by like 500 or whatever so the orgin is nolonger in sight.
and then you draw the hud in glOrtho() at like the bottom-left and bottom-right of the screen. you wouldnt see the hud because you are too far to the right to see either of them because both the huds are centered around the orgin..
is that completly wrong becuase i really odnt know.
does the orgin of drawing move with the camera..
sorry if i am giving you a heart attack,
i really dont know..
thanks



Use glPushMatrix and glPopMatrix in between your ortho drawing.
Ortho mode is explained really good in the Textured Fonts Tutorial. I don''t remember the number.

Share this post


Link to post
Share on other sites
UponTheEnd,
What people usually do with glOrtho is,
1) Render all your 3d stuff.
2) Swith to Ortho
3) draw your hud.
4) swith back to normal perspective

I usually think about glOrtho as "swith to 2d mode". Your perspective and looking position will kinda reset to new "mode". So you draw in ortho mode as if it is 2d. Hope you understand what I try to mean here.

Share this post


Link to post
Share on other sites