The main objective of this assignments is to create a Maya Exporter which is used to export a maya model in the human readable format. We can then use this human readable format and load it into the game. We also create a transparency effect for which we create render states for opaque and transparency effect.
So the work of the MayaMeshExporter is to convert the model in Maya to the human readable format. For that we have to write a function called WriteToMeshFile() according to our human readable format and this will convert the Maya model into our format.
As far as the dependency goes, the MayaMeshExporter is independent i.e. it does not depend on any other project in the solution. This is because its sole purpose is to convert the Maya model into the human readable format. You can pretty much just export the Maya model and build this MayaMeshExporter alone and independently and it will generate the human readable format for that particular model which is a great feature to have.
The following image shows the Plug-in Manager in Maya 2016. You can also see the two custom names. For my Release version the name is “eae6320_mankoo_hardit.mll” and for my DEBUG version the name is “eae6320_mankoo_hardit_DEBUG.mll”.
My scene below contains 4 meshes:
- House Mesh
- Man Mesh
- Floor Mesh
- Sphere Mesh
My output is as shown in the image above. You can see the transparency effect on the sphere which is between the man and house. Earlier I had given the same color for the triangle faces of the house and the man but it was looking like a flat a plane. So to give the model some depth I varied the color on the faces with the lightest colors on the left and darker colors on the right to give an effect as if there is a point light on the left of the scene. This process would be much simpler when we learn texture coordinates.
So basically the man, the house and the floor are opaque that is they have an opaque effect . This means that their alpha_transparency is disabled. Their settings are as follows:
alpha_transparency = false;
depth_testing = true;
depth_writing = true;
face_culling = true;
The sphere on the other hand which lies between the man and the house has the alpha transparency and the depth writing enabled. Due to this the sphere looks semi transparent and every object that lies behind it would be visible but would have the semi transparent effect for the objects that lie behind it and are covered by the radius of the sphere. And the objects that are in front of it will not have the semi transparent effect . They transparency settings are as follows:
alpha_transparency = true;
depth_testing = true;
depth_writing = false;
face_culling = true;
My effect.lua file looks like as follows . As you can see I have chosen to add all the render states in one table under “render_states” because it makes sense to club those 4 boolean values which represent the render states under one table. It makes it easier for me to understand.
Basically we store the the render states in a uint8_t variable. The uint8_t is a 8 bit data type. Even from those 8 bits we only use 4 rightmost bits which correspond to alpha_transparency, depth_testing, depth_writing and face_culling. Hence uin8_t is actually big enough and dont need to consider uint16_t so and so on.
So earlier I had harcoded the values but from the discussions in class it makes sense not to hardcode them and associate a name for each. The advantage of associating a name is that we done need to remember which bit represents which render state.
For this I just defined 4 names as follows:
I just used the same order that was given in the assignment page, i.e. alpha_transparency represents 0, depth_testing represents 1, depth_testing represents 2 and face_culling represents 3. Our render state is basically a combination of 4 values which are
Alpha Transparency, Depth Testing, Depth Writing and Face Culling. All of these are boolean which allows us to enable of disable them.
To enable or disable these values we use bitwise operations. So say we have our render_state_value and we want to enable the alpha transparency and we want to enable the depth testing . For this we need to do a bitwise OR operation so that we can set or enable the rightmost two bits as follow:
render_state_value|= 1<<0 . This enables alpha transparency.
render_state_value|= 1<<1 . This enables depth testing.
So now our render_state_variable looks like 0011.
This is how my binary files look for the opaque and transparency effect.
If you look at the highlighted value for opaque effects it shows “0E” which is 0xE which is 1110 . The information we get from this is that alpha transparency which is the rightmost bit is disabled, depth testing which is the next one is enabled, depth writing is enabled and face culling is enabled. So the information is correct as the opaque objects have no transparency and matches the values in our human readable effect file.
Similarly if you look at the transparent effect, the highlighted value shows “OB” which is 0xB which is 1011. This means that the alpha transparency , the depth testing and face culling are enabled but the depth writing is disabled. This again matches our human readable file.
For debugging the meshes in Maya I created a primitive test model called BigBox.mesh . So if you see the screenshot of the debugging below you can see in the i_fileName the name of the asset which is being debugged which is BigBox.mesh . It also provides the vertex buffer and the index buffer information for the model which is a very cool feature .
Overall this assignment took me 17 hours to finish .
You can download the Zip File of Assignment_11 from the following
link to get the square output.
The controls for camera are First Person Shooter controls as follows:
A – to strafe left
D – to strafe right
W – to move forward
S – to move backward
Space – To fly upward
Z – to Dive Downward
E – rotate Camera ClockWise
Q – rotate Camera AntiClockwise
C- rotate the man around the house in clockwise direction to guard the house
X- rotate the man around the house in anti-clockwise direction to guard the house
Use arrow keys to control the mans movement
After downloading the link run Game.exe.