Skin designed by Auron89.Find more great skins at Silent Designs!
Image hosted by Photobucket.com


 

 FPS camera
kritanta
Posted: Jan 9 2006, 12:59 PM


Newbie


Group: Members
Posts: 3
Member No.: 162
Joined: 11-December 05



i am currently using an FPS free fly camera but im having troble geting my 'Gun' to rotate around as my camera does. can any body help i will post the code if its needed im just not to sure how to go about this.
Top
Loffen
Posted: Jan 9 2006, 04:25 PM


n00bie administrator


Group: Admin
Posts: 146
Member No.: 82
Joined: 5-January 05



You mean a FPS Weapon, right? If the model has been designed how it should be, this is actually quite simple. (by designed the way it should be, i mean that if point (0,0) in the model is places at (0,0) relative to the camera, produces the wanted look). All you then have to do is transform the world before rendering the gun, using the camera matrix. Like this, the gun should point the same way, etc, as the camera (the wanted result?)...

If the model was not designed that way, you'll have to cope with the probles of translating the gun model correcly (still relative to the camera matrix).

Hope this helps
-- Loffen
Top
The Pentium Guy
Posted: Jan 11 2006, 01:22 AM


The Boss.


Group: Admin
Posts: 743
Member No.: 1
Joined: 4-July 03



Screenshots would be appreciated - I love checking out what other people have done wink.gif.

You already have a camera class right? Since this is an FPS game I'm assuming that the only thing that changes is the View matrix (for moving the character). Hopefully you've stored the angle that the world camera rotates by. The world camera can turn in the X and Y directions.

The gun needs to rotate in the X and Y directions as well. To rotate it left/right (X direction) you'd rotate it about the Y axis. To rotate it up/down, you'd rotate it about the X axis.

Just do a dxDevice.Transform.World = Matrix.Multiply(Matrix.RotationY(angleX), Matrix.RotationX(angleY))

Either that, or you switch around the first and second arguments. Should do the trick.

Take care,
-The Pentium Guy
Top
Loffen
Posted: Jan 12 2006, 06:12 PM


n00bie administrator


Group: Admin
Posts: 146
Member No.: 82
Joined: 5-January 05



CODE
dxDevice.Transform.World = Matrix.Multiply(Matrix.RotationY(angleX), Matrix.RotationX(angleY))

.. is a bad practice for later use? how do you intend to move the gun later? will you do another translation of the device's matrices? Dunno for sure about DX, but in OpenGL, whenever you do a glTransform(...) (dunno function name right now..) OpenGL sends a command of some sort to the GPU, and updates some stuff on the GPU (this takes time, and resources.. how much i cant say now.. read upon it if you're interested)...

For rotations, even if its a FPS camera, i'd go for Quaternions. Easy to use in VB, but powerful. This allows you to Yaw, Pitch AND Roll the camera, just like you want... And if you store the viewmatrix somewhere global, just use the same matrix on the gun... You'll find something about Quaternions on this forum...

-- Loffen
Top
Loffen
Posted: Jan 12 2006, 06:16 PM


n00bie administrator


Group: Admin
Posts: 146
Member No.: 82
Joined: 5-January 05



CODE
fRoll = 0.0f
fPitch = 0.0f
fYaw = 0.01f

' This part is the part wich matters...
Quat.RotationYawPitchRoll(fYaw, fPitch, fRoll)
RotQuat.RotationQuaternion(qQuat)
ModelMatrix.Multiply(mRotQuat)

Device.Transform.View = ViewMatrix


The previous one works for the ViewMatrix.. for the worldmatrix you'll need this (small diffrence, but it did the trick when I was doing DX coding..)

CODE

Quat = Quaternion.RotationYawPitchRoll(fYaw, fPitch, fRoll)
RotQuat = Matrix.RotationQuaternion(qQuat)
ModelMatrix = Matrix.Multiply(mRotQuat, ModelMatrix)


Hope that helps,
-- Loffen

err.. sry for dbl post..
Top


Topic Options Quick Reply




Hosted for free by InvisionFree (Terms of Use: Updated 7/7/05) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.2201 seconds | Archive

Check out the Shoutbox! Type in your name and the message to shout ;).