Write Up 10

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 Assignment10 was to load meshes from .lua files. In order to do this, a mesh lua format file was created in order to hold the vertices and indices of the mesh to be loaded. The mesh lua format was made in a way so as to make it human readable and easy to change. The advantages of this approach are that:

  • Mesh vertices and indices can be modified quickly and easily.

  • Stored values can be given keys in lua to improve readability.

  • A designer or someone not technically savvy can understand and edit the content.

  • Debugging is easier due to the data being on a separate file.

 

The mesh lua file format I chose is shown below for my static mesh (floor mesh):

 

return

{

            -- Vertices

            vertices =

            {

                        -- Vertex 0

                        {

                                    position =

                                    {

                                                x = -2.0,

                                                y = -0.5,

                                                z = 4.0,

                                    },

                                    color =

                                    {

                                                r = 0.5,

                                                g = 0.5,

                                                b = 0.5,

                                                a = 1,

                                    },

                        },

 

                        -- Vertex 1

                        {

                                    position =

                                    {

                                                x = -2.0,

                                                y = 0.5,

                                                z = -4.0,

                                    },

                                    color =

                                    {

                                                r = 0,

                                                g = 0,

                                                b = 0,

                                                a = 1,

                                    },

                        },

 

                        -- Vertex 2

                        {

                                    position =

                                    {

                                                x = 2.0,

                                                y = 0.5,

                                                z = -4.0,

                                    },

                                    color =

                                    {

                                                r = 1,

                                                g = 1,

                                                b = 1,

                                                a = 1,

                                    },

                        },

 

                        -- Vertex 3

                        {

                                    position =

                                    {

                                                x = 2.0,

                                                y = -0.5,

                                                z = 4.0,

                                    },

                                    color =

                                    {

                                                r = 0.5,

                                                g = 0.5,

                                                b = 0.5,

                                                a = 1,

                                    },

                        },

            },

 

 

            --Indices

            indices =

            {

                        0 ,1 ,2, 0, 2, 3,

            },

}

 

I decided to create separate tables for vertices and indices and give keys to each one to improve readability. I made indices as an array due to order being important and the number values being self-explanatory. However, for the vertices, I decided to encapsulate the position and color of each vertex between braces ({},) to separate the components per vertex. I assigned keys to position and its components as well as color and its components in order to not leave any ambiguity between the values. When reading the position and color data of a vertex, I retrieve the values by key value.

 

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