Write Up 14

First translucent object in front of second

Second translucent object in front of first

General Controls:

Press Escape to quit the application.

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 Assignment14 was to submit two translucent objects in a different order to properly test drawing translucent objects back-to-front. In order to do so, I first create separate vectors for meshes and translucent meshes. Each vector is a vector of tuples that contain a pointer to a mesh, a pointer to an effect, a pointer to a texture and a position of type Math::sVector.

The mesh tuples are the following:

std::vector<std::tuple<eae6320::Graphics::Mesh*,eae6320::Graphics::Effect*, eae6320::Graphics::cTexture *,Math::sVector>> meshes;

std::vector<std::tuple<eae6320::Graphics::Mesh *, eae6320::Graphics::Effect *, eae6320::Graphics::cTexture *, Math::sVector>> translucentMeshes;

The vector named “meshes” contains all the opaque meshes and are drawn first in the eae6320::cExampleGame::SubmitDataToBeRendered() function.

In the Graphics.cpp file, a function called eae6320::Graphics::SortTranslucentMeshes() receives the vector of tuples “translucentMeshes”. Since the meshes in this vector of tuples are translucent, they are sorted in regards to the z component of their position in Camera space. To do this, the value of

s_dataBeingSubmittedByApplicationThread->constantData_perFrame.g_transform_worldToCamera

is multiplied by the world position of the translucent meshes. The z components are then compared for pairs of entries of the vector of tuples using std::sort() and passing the function MeshSortCondition() as the sorting condition.

These draws calls are sorted on the application thread.

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