Feature 1 Post Mortem

To load OBJ meshes into my scene, I didn’t change too much from the examples in the videos. I used the same function in ObjUtilities to load them in, and I used arrays of VertexAttributes, ShaderPrograms, and VertexArrays to store the different objects. Before I set the individual elements of the arrays, I initialized all of my meshes into different instances of VertexAttributes. This way I could simply assign the different meshes to each element in the array.

After this, I went about assigning these attributes to different elements in the array. For elements that used the same mesh, I used a loop to avoid repeated code. I had to individually assign xform matrices to each element, because each had a different position. To make this task easier, as I didn’t want to just guess at positions and check to make sure the objects were in the right place, I set my camera to print the current x and z positions. Then I could simply walk to where I wanted objects and record the correct positions. I also set the y coordinate of each object to the value of my terrain object at that point.

Doing this allowed me to load my objects into my scene. All of my meshes besides my terrain were downloaded from http://thefree3dmodels.com.

I didn’t encounter many problems loading meshes into my scene, but it was a little annoying to have to edit each obj file before using it. I didn’t get around to editting the ObjUtilities function until all of my objects were already loaded, but I wanted to do it anyway to make future use easier. I walk through each obj file twice now, the first time counting the number of vertices and faces and the second time recording the positions. Part of the reason I had put this off was because I thought it would be difficult, but I found that it wasn’t hard at all.

Lastly, here’s a video of my meshes. The shading looks terrible now, but I’ll fix that for feature 3.

http://www.youtube.com/watch?v=6KW8d9Z3bFQ

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *