PDA

View Full Version : MD2 weapons rendering



02-19-2005, 03:06 PM
Hi there!

I wonder how to render quake 2 weapons, as they are in quake 2. I mean they stay in the right place on screen. But of course they are actually rotated (for light applying). And my question is how to do this. Well, i tried just glRotate, glTranslate etc... but models should be centered at (0,0,0) or the results aren't like they should be. Should I use the info from each frame (scale and translate vectors)???

Luminous Blue
02-20-2005, 04:07 PM
Hi

try

glLoadIdentity
glTranslatef
glRotatef

draw your world

glClear(GL_DEPTH_BUFFER_BIT)
glLoadIdentity
glTranslatef
glRotatef

draw your weapon

it's just one way

LB

02-21-2005, 04:31 PM
Actually, one of the easiest ways is to draw it before you rotate and translate your scene/camera. Usually at the very beggining of your scene code ,right after Clear Color|detph and loadIdentity and right before you're camera/scene translations.

Assuming it's a first person jig, then,it will always be right at point origin and "staty there" since its drawn before any camera/scene or world translations/rotations.

02-22-2005, 07:06 AM
Well, to be more precisely:

When I load a md2 model (decompresing vertices to full float format - using scale and transalte vectors of frame) I get a Big F*** Gun, virtually. The gun is quite big and not centered. So I should translate model to make it near (0,0,0) for proper rotation. But how will I know how much to translate it. Hard-coded?, ok. But if i will want to load another weapon. I think this post represents problem more exact.

02-23-2005, 09:01 AM
You can translate/rotate/scale the weapon as much as you like and it will not rotate/translate/scale with the rest of the scene because it's drawn before scene/camera rotations.

It will always be at/near point origin in the above scenario after you move to there.

to know "how much" you should translate/rotate/scale... is done according to personal preferences.

But, check and mess around with your near plane value as well, if you're using glu perspective...Cahnge it from 0.1f upwards, little by little.