FPS Weapon Rendering

Started by
13 comments, last by jonbell 20 years, 11 months ago
Yes but the origin does not lie at the camera position. You can ''place'' the camera at (0, 1000, 0) using gluLookAt and render something at 0,0,0. The rendered object will not be rendered at the camera''s position rather it will be rendered 1000 units down the Y axis. Whereas if i places the camera at 0,1000,0 then glLoadIdentity() then render the object at 0,0,0 it will be rendered at the camera''s current position.
Advertisement
hrm.. tough one this. when u use gluLookAt to ''position'' the camera at (0, 1000, 0), u''re really telling OpenGL to render everything else at (0, -1000, 0) onwards. its true the ''virtual'' origin is at (0, 0, 0) and the camera is in the ''virtual'' systems position of (0, 1000, 0). the whole reason a LoadIdentity places stuff at the camera is because the ACTUAL origin is still at the camera irrespective of ur transformation. the whole camera-model is just a way for us to perceive view transformation in a more humanly sense, but when it involves resetting the matrices and all, knowing this fact comes in handy.
- To learn, we share... Give some to take some -
quote:Original post by LordShade
Render as you normally would but be sure to shut off the Z-buffer else your weapon will stick into walls and other geometry.


Turning the z-buffer off is not a good idea, because the z ordening of your 3d weapon object will get in trouble. The right thing to do is to clear the z-buffer after rendering the scen and thén rendering the object wíth z-buffer on.
[www.LifeIsDigital.net - My open source projects and articles.
as craze said (he''s right u know) there is no camera.
the camera is an abstract concept for 3d.
to see what i mean:
lets say ur head is the origin.
look at a point on a wall.
move ur head to the left.
what do u see? the point is more to the right now. but the origin cant move so that means that the point moved.
thats what opengl does.

the weapon will always point forwards even if u are facing the point on the wall or if u are facing opposite from it because using an identity matrix, it will not be rotated or translated like the point, get what i mean?

if u want to move the weapon around a little to make the effect of running with it just rotate it around the x axys increasing the angle every frame.
to make it even easier: it absolutely doesnt matter what is moving in which direction, because loading the identity will reset the matrix and will make it completely unimportant what glulookat did to the matrix earlier. if you insist on your camera, then identity will reset the camera also.
f@dzhttp://festini.device-zero.de

This topic is closed to new replies.

Advertisement