Different ways of building a FPS style camera

Started by
9 comments, last by Toolmaker 16 years, 3 months ago
I'm trying to create a FPS style camera with Direct3D in C#. Have seen millions of tutorials, but they are all pretty much the same or give you only one part of the code and I can't figure it out. Most tutorials I have seen is with the Matrix.LookAtRH function which requires camera position AND camera target. Why the need for a target in a 1st person camera? Is there a way of setting up a camera without it? Something that would just have the camera movement and control the yaw/pitch/roll.
Advertisement
Here you can find some code that uses a different approach (the files for part 3, chapter 12). It's part of a book's source code.

BTW, that book has a second edition, but it's implementation is different and seems more limited.
Whenever I've done a FPS camera I've always stored the up, forward and right vectors and generated a view matrix from that (easy - you just have to shove them into a 4x4 matrix in the correct position and pad the rest out). For actual movement you can construct a 4x4 matrix and apply it to all the vectors. Eg. if you were turning left you'd make a rotation matrix around the 'up' vector for your turn amount and apply that.
Could you maybe show me some sample code of that please?
The code that I linked to implements exactly what OrangyTang described.
I meant sample code in C#.
The C# port of that code can be found here. It says that you need a password, but you don't (I just checked).
It says wrong DirectX version if I try to run that project. The whole thing is cursed maybe I should go back to Pascal...
Probably the easiest way to fix that is to create a new project and link the appropriate libraries.
Just did that, removed the DirectX references and added them again. It runs in full screen, but nothing happens, just a blank light orange colored screen.

This topic is closed to new replies.

Advertisement