Giant Roadblock

I'm writing a game engine, but I've hit a mjor roadblock. You see I'm using GLtools and this allows you to easily move a camera around the 3D world, it also has a function that I believe returns the XYZ coordinates of the camera.

Only problem is that my character is supposed to have a gun, now in relation to the camera (and the direction the camera is facing) the gun is always in the same place.

The class GLFrame in gltools has some info on which way it's facing, I'm figuring I'll write a function that returns the vector.

So my chosen method of displaying the gun is essentially to convert (somehow) the new position of the camera AND the vector (the way the camera is facing) BACK to the default (namely 0,0,0 and 0,0, -1) and then REVERSE this on the constant position of the gun to receive the NEW gun location.

My question is, how do I this.

In other words how do I find the equation that will convert the coordinates.
I believe this is the way most FPSs do it:
Image the world as consisting of three parts. The 3D scene, which contains the actual map; the 3D HUD, which contains the character's weapon; and the 2D HUD, which contains health and ammo gauges, etc. The 3D scene is rendered to the framebuffer as one unit based on the camera position, as you're thinking. Once that's done, the camera is set to a fixed point and direction (the 3D scene will be invisible at this point, so it doesn't matter where the point is) such that the weapon is visible, and this view is rendered on top of the previous one. The result is akin to having the character stand in front of a screen that displays the scene, which is why weapons don't clip through walls when you get really close to them. Finally, the 2D HUD is drawn directly onto the framebuffer without using the camera.
OHHHHH TY SO MUCH, so the weapon isn't actually "in" the map?

So first thing: Render scene.

Then set new origin to camera point? Render weapon, then paste weapon on top of map scene. Then display HUD.

Is that what you're saying?

Sorry I'm a noob :).
Yes, yes, and yes.
Topic archived. No new replies allowed.