Jump to content
  • Advertisement
Sign in to follow this  
NickGravelyn

[SOLVED] Rendering First Person Weapons

This topic is 4502 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 cannot seem to figure this out. How can I use the up, look, and eye vectors of my camera along with it's view matrix to figure out how to place a weapon mesh for my player? I've tried a few different things, but nothing has actually worked yet. [Edited by - NickGravelyn on May 24, 2006 12:38:53 PM]

Share this post


Link to post
Share on other sites
Advertisement
The camera shouldn't have anything to do with how you place models in relation to your character. You should look into either some type of scene management (scene graphs) or at least how to make an object heirarchy for your game objects. This way you can simply offset from your players' world matrix by the guns local matrix, and viola! You have the correct position.

Obviously in an FPS you won't have a character (unless you also support a 3rd person mode). So in your case you would instead, simply offset from your cameras world matrix by your guns local matrix. If you are using some sort of 3D rendering software to create the gun, just place your camera at origin, then move the gun until it looks to be in the right position. Save this position and feed it to the gun models local matrix when you load the mesh.

Share this post


Link to post
Share on other sites
That sounds easy enough, but I don't know how to get the world matrix for the camera. All I have are those three vectors and the view matrix. How do I get the world matrix?

Share this post


Link to post
Share on other sites
Your "view matrix" is probably just an inverted camera world matrix, eh?

If it is what you're describing; the view matrix transforms world coordinates to viewspace by reversing a virtual camera's world transformations (this is what is described as "moving the world about the camera", if you've heard that before). So by "unreversing" your view matrix you'll have the camera's world matrix.

Use it's forward vector to place your weapon/whatever slightly afore and you're set.

edit - Good job on figuring it out! I got distracted by a blog while writing this... :-P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!