Help with a First Person Shooter engine!!!!!!!!!!!!
Ok, first let me thank you for taking your time and helping me, i am 17 years, and just started to understand DirectX.
I have been building up online shooter for quite along time now, but I have two main problems:
1) I don't know how to make my mouse rotate the Camera in X and at the save time move it (the camera), to give the person the classical feel it him in that game. I mean, i know Direct Input and all, but all the matrix operation I have think of are useless. And I have tried to do something like this:
GraphDevice.Transform.View = Matrix.Multiply(Matrix.RotationY(-MousePos.X), Matrix.LookAtLH(New Vector3(-CameraPos.X, CameraPos.Y, CameraPos.Z),New Vector3(-CameraPos.X, CameraPos.Y, CameraPos.Z - Dif),New Vector3(0, 1, 0)))
I now that I am not taking care of the X axis right now, but atleast I wanted my "view" to rotate in Y.... But it does not work! If i get far from where my camera starts, the whole world starts rotating but taking my initial position as a Rotation center, witch is useless to me.
If I am not clear please let me now.
2) I just wanted to know how to add Cell-Shading to my game. I now how to use high shader lenguaje, but DirectX does not come with it, can you please help?
Again, thanks alot!!!!
hi, for the first question try this:
assume that the view target is 0,0,1 + your camera position...
then create a float to hold the camera rotation...
now use : view target = Vector3(Cos(rotation), 0, Sin(rotation)) + camera position.
now is just build the view matrix.
in the 2nd question:
create the effect.
Set all parameters : Matrices, Textures and other variables,
Set the Technique name(Effect.Technique), then:
int nPasses = Effect.Begin(Yor Shader Flags)
for(int cPass = 0; cPass < nPasses; cPass++)
{
Effect.BeginPass(cPass);
Render here all the objects with Cell Shading
Effect.EndPass();
}
Effect.End();
Hi
The following is the first article in a very good tutorial, it covers a lot about DirectX and the physics when creating a game
http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=938703&title=Beginning+Game+Development%3a+Part+I+%e2%80%93+Introduction
In about Article IV i think it covers the second problem you are having
In short what you want to do is get a Vector3 that represents the way you are pointing
The easiest way is extracting that from your View Matrix
Vector3 look = new Vector3();
_look.X = _viewMatrix.M13;
_look.Y = _viewMatrix.M23;
_look.Z = _viewMatrix.M33;
Then using that to move forwards
_position = _position + _look * units;
Note: The above example uses the Left Handed coordinate system
Chris