CSCI 440 - Homework Five

Now that you have an interesting object on the screen and you know all the parts are connected correctly, let's make it look a little more real and add some simple motion.

Add a perspective view. Create a perspective projection matrix and pass it to your Vertex Shader. Don't forgot to modify your Vertex Shader code to use both your projection and model matrices. If your projection matrix remains constant, then there is no need to send it to the GPU over and over and over. So, your projection matrix code can probably go inside Init() instead of Render().

Remember that your new world exists along the negative Z axis. The default view you previously used was centered at the origin. Hence, as soon as you add perspective, your object will probably disappear. You need to translate your object into your pyramid shaped world. You may find that you need to scale it up.

Add some movement. Have your object move around. Change the X, Y, and Z locations. When it is farther away it should automatically be smaller.

Also spin your object a little. Spinning your object will make the next assignment with lighting easier to see. After we add a light above your object, the top should be bright and the underside dark. The sides will change shades as the light hits the sides differently. So, this assignment should let us see your object from different angles.

There are several ways to add movement. You could create an array of X,Y,Z locations, then have your object move to each location. The same array could contain some Y axis and X axis rotations. You would need to change render() to be on a timer, instead of running through your array too fast. That would work fine, but would create jerky motion.

Another way to create motion is to slowly change the X, Y, and Z locations. That would create smooth movements. My simple moving triangle works that way. You could add some complexity by altering X, Y, and Z by varying amounts, or use a formula (like a sine wave) to create a smooth curve. Maybe X grows quickly until it hits a certain value, then it reverses. ... Your options for creating motion are endless.

Send your code to dannellys@winthrop.edu. Use the subject line "CSCI 440 - HW05. I will go to your web page and run your program. To make grading easier for me, please put your code as the body of the email message, not as an attachment.