Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jonbell

FPS Weapon Rendering

This topic is 5526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to render the players current weapon to screen (fps style) and am having a few problems. I have my cameras position vector and look vector and am trying to render the weapon model in the correct place in the scene using these. However i think that maybe i should be looking at changing the projection and perhaps tackle the problem that way. Has anyone done this and if so how. Any thoughts would be most welcome.

Share this post


Link to post
Share on other sites
Advertisement

use an identity matrix for modelview ? or translate it by a little bit.

Share this post


Link to post
Share on other sites
well obviously i don''t want the identity matrix when i render cause the weapon will move around the world with the camera. I have been experimenting with rendering the weapon using the camera''s vectors as the starting point with limited success (rotations start playing havoc). I''m pretty sure that the best solution will involve altering the projection when i render it but i''m not exactly sure how.

Share this post


Link to post
Share on other sites
Render as you normally would but be sure to shut off the Z-buffer else your weapon will stick into walls and other geometry.

Share this post


Link to post
Share on other sites
if the weapon is modeled so that it is at (0,0,0) and pointing down the negative z axis, then as long as u have the identity matrix loaded, just translate to, say, (0,0,-5), depending on how big the model is and where exactly u want it on the screen.

Share this post


Link to post
Share on other sites
OK i have solved my problem and it works fine but this has really been bugging me. It shouldn''t work. If i load the identity matrix and render then the object should be rendereed at the origin not at the cameras current position, why does it work?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Because you are under the impression that you are really moving through a "world" when it is really the world moving around you. The "camera" never moves, it is always at the origin.

Share this post


Link to post
Share on other sites
I thought that gluLookAt setup the model view matrix so that the scene will be rendered from the cameras perspective but the origin is not at the camera point. I am sure this is right.

Share this post


Link to post
Share on other sites
In openGL, there is no REAL camera. yes, u do see things thorough a viewpoint, but when u ''move'' this viewpoint/''camera'' u''re really moving EVERYTHING the opposite direction than intended. So when u''re turning right, the objects are really turning left relative to your viewpoint.

wat gluLookAt does is it simplifies the specification of this so called camera. Try this: instead of using gluLookAt, u do the glRotate* and glTranslate* urself to simulate the ''camera'' movements. Heck, its not impossible, but it aint something u would want to keep doing coz personally, i rather like it clean. So gluLookAt does all the actual dirty work for you.

also, objects are positionally rendered disregarding actual framebuffer information. meaning, when u translate an object to (10, 0, -10) and render it, u get a translated object. But right after that, if u load an identity matrix, the translation is negated so all following objects are rendered relative to the origin = viewpoint position. So unless u translate the objects again, any subsequent rendering may actually ''overlap'' other objects already rendered in the framebuffer. Remember, if its position u wanna talk about, its all in the transformation.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!