Sign in to follow this  

[SOLVED] Rendering First Person Weapons

This topic is 4222 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
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
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

This topic is 4222 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this