Write Up 09

Game at the start:

Game after Camera and Cube Movement:

 

 

 

 

Cube Intersecting floor plane:

General Controls:

Press Escape to quit the application.

 

Cube Controls:

Press the right arrow key to move the cube towards the right.

 

Press the left arrow key to move the cube towards the left.

 

Press the up arrow key to move the cube up.

 

Press the down arrow key to move the cube down.

 

Camera Controls:

Press the ‘A’ key to move the camera towards the left.

 

Press the ‘D’ key to move the camera towards the right.

 

Press the ‘W’ key to move the camera up.

 

Press the ‘S’ key to move the camera down.

 

Press the ‘Q’ key to move the camera backwards.

 

Press the ‘E’ key to move the camera forwards.

 

Press the ‘T’ key to rotate the camera counterclockwise along its local Y axis.

 

Press the ‘G’ key to rotate the camera clockwise along its local Y axis.

 

Press the ‘Y’ key to rotate the camera counterclockwise along its local X axis.

 

Press the ‘H’ key to rotate the camera clockwise along its local X axis.

 

The main objective of Assignment09 was to build 3D meshes, assign them a Rigidbody and create a camera to navigate the example game’s space.

 

In this assignment, the vertex format of the meshes was changed to take 3 floats for the x,y and z components. A sRigidbody struct was used to handle the position updates of the meshes. Now, only the velocity of the rigidbody of a mesh is changed via key presses and the Physics::sRigidBodyState::Update() function changes the position based on the velocity changes of the rigidbody.

 

A camera object was created in order to navigate the game space. It is created in the cExampleGame::Initialize() function as follows:

 

gameCamera = new eae6320::Graphics::Camera(cameraRigidBody,45.0f,1.0f,0.1f,100.0f);

 

Its parameters are the following:

  • Parameter 1: the rigidbody assigned to the camera.

  • Parameter 2: the verticalFieldOfView, given in degrees here and then converted into radians.

  • Parameter 3: the aspect ratio.

  • Parameter 4: the near plane value.

  • Parameter 5: the far plane value.

 

In order to get the meshes in this assignment to be properly drawn, the mesh has to be drawn from local space to projected space. Local space is the where the mesh is at the local origin and facing forward. Its vertices are placed relative to the mesh’s origin. The mesh and its vertices are then placed in world space which represents the mesh’s constant position or global position. This is done via the localToWorld matrix that is calculated per draw call. The mesh is then transformed into camera space via the worldToCamera matrix where the world is relative to the position of the observer. In camera space, the camera is at the origin and facing forward. Finally, the mesh is transformed into projected space via the cameraToProjected matrix where the 3D data is transformed back to 2D to show a perspective view of the mesh.

 

To calculate all of these matrices appropriately, I created a macro in shaders.inc called CalculateMatrixVectorMultiplication().

 

It is used the following way in the vertex shader of the mesh:

 

float4 vertexPosition_world = CalculateMatrixVectorMultiplication(g_transform_localToWorld,vertexPosition_local);    

Lastly, a depth buffer was implemented in this assignment in order to render the pixels of overlapping meshes properly.

 

The time it took me to complete this assignment was 8 hours.