This is a continuation of the first topic.
At the first topic, we never used a camera.
We set the mesh view to default.
Let's create a camera that will be able to move freely in the 3D space..
Add the following lines to the top of your class.
Matrix viewMatrix=Matrix.Identiy, rotationMatrix = Matrix.Identiy; // View matrix is your eyesight in the 3d space, rotation matrix is the rotation of the camera in the value of matrix
Vector3 cameraPosition= Vector3.Zero; //Camera position set to 0
Vector3 cameraOffset = new Vector3(10, 0, -10); //Set up a vector3 that will be added to the cameraposition and serves as the camera target
Vector3 cameraRotation = Vector3.Zero; //camera rotation is the rotation of camera in Vector3, we'll update the value of this based on input
Vector3 cameraVelocity = Vector3.Zero; // The velocity of the camera
float movespeed = 5f; // Movespeed of camera
At your update ,set the value of view matrix and a rotation matrix.
cameraPosition = Vector3 .Transform (cameraPosition ,rotationMatrix );
Transform the cameraposition with the rotation of the camera
viewMatrix = Matrix.CreateLookAt(cameraPosition, cameraPosition + cameraOffset, Vector3.Up);
//set the view matrix, to create a look at we need the camera position, the target, the direction of camera view
At your draw method, replace the
effect.View = Matrix.Identity
to
effect.View = viewMatrix;
With this, the value of house view will be equal to the viewMatrix..
Next, we need to update the camera..
On your update method, create a set of if statements..
[updating in progress]