View Full Version : Rendering the gun in an FPS
01-15-2004, 08:18 AM
What's the best way to render, for instance, the gun in a first person shooter. That is, to say, an object that will stay in the same place relative to the screen at all times.
I'm sure this is a pretty simple problem. Thanks for any suggestions.
There would be a few ways to do this, depending on weather the weapon will be a model or a 2d image. Basically, you need to draw the gun on the screen and THEN do the 3d camera transformations for the rest of the world. Any movement made will then only effect the world models and not the weapon. Obviously you can build on this to allow movement of the weapon but you get the idea http://www.opengl.org/discussion_boards/ubb/redface.gif)
One small addition - you may find it easier to draw the gun at the end to ensure it is in front of everything on the screen. If so, reset to the identity matrix to clear all the transformations you've made and disable depth-buffer writing before drawing.
Technically this costs a little extra processing time, but unless you're John Carmack it's likely to have no real impact.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.