PDA

View Full Version : weapon in fps



targe
01-30-2004, 11:44 AM
I'm having trouble getting a 3d model of a weapon to render just in front of the camera.

I've been able to find a few short descriptions on the web which indicate there may be about 3 different (common) ways of doing this:

1. Using the position of the camera, the viewpoint of the camera and some distance-formula math to draw the model.

2. Turning off the z-buffer and drawing the weapon last? Not sure about this one.

3. Applying the same tranlations/rotations as the camera to draw the model in the same spot.

I've come close with #1 - the weapon is the correct distance from the camera, but when the camera rotates left/right, the weapon 'circles' the camera erratically!

If anyone can help me out with this I'll be
really thankful!

MrShoe
01-30-2004, 03:31 PM
REnder the weapons model last with the transformation on it being generally a negative z one. So in pseudocode something like:

drawEverythingHere();

glPushMAtrix();
glTranslatef(0.0f, 0.0f, -z);
drawWeapon();
glPopMatrix();

Now, you might want to put in some y and x transforms on it depending on where you want the weapon to be in the viewport, but yoiull figure it out.

Note also, this is more or less assuming that the weapon model itself is centered at 0.0,0.0,0.0, some models are not centered.

targe
02-01-2004, 03:58 AM
Thanks for the info!

M/\dm/\n
02-01-2004, 07:16 AM
Take a look at my post ~3days ago...

targe
02-01-2004, 11:18 AM
Thanks M/\dm/\n!

I did search the boards, but ignored this one
as the topic "cubemap reflections" didn't seem relevant!

T