CS 4722 - Computer Graphics and Multimedia
Module #5, Assignment #1Exercise #1Modify the given LookAtCubePerspective application so that it implements additional functionalities: The current HTML code is given here: LookAtCubePerspective.html. The current JavaScript code is given here: LookAtCubePerspective.js. After your modifications, you should have the additional functioning sliders as shown: In addition to the new sliders, make sure your program handles the Up Arrow and Down Arrow keys, so pressing the Up Arrow moves you closer to the cube in the scene, and pressing the Down Arrows moves you further away. And make the Left Arrow rotate the cube to the left, and the Right Arrow rotate the cube to the right. And make sure all four arrow keys work for both Perspective and Orthographic views, and that the Up Arrow and Down Arrow keys also change their corresponding slider values, and those keys don't allow those values to get smaller or larger than their minimum and maximum slider values, respectively. Exercise #2The TetraToSphere program given below creates a tetrahedron drawn with a wire frame that you can see through:From the above angle, you cannot see that it is being drawn without opaque sides, but if you rotate it this issue becomes apparent: Modify the TetraToSphere program so it is drawn with green opaque sides that have black borders along the triangular edges: Furthermore, the tetrahedron() method in the code takes a fifth argument that controls how many times the sides of the tetrahedron will be recursively redrawn as smaller tetrahedrons, causing its sides to progressively expand into a sphere-like shape. After four expansions the tetrahedron looks like the following: So, in addition to your other modification, modify the TetraToSphere program so that you add the following buttons that allow you to rotate it in a horizontal theta angle and a vertical phi angle, and add buttons that allow you to increase the recursive calls from a minimum of zero to a maximum of 6 (after 6 subdivisions, the program gets very slow): In addition to these buttons, add key handlers so that when the user presses the Up Arrow the object rotates up, and when the user presses the Down Arrow the object rotates down, and when the user presses the Left Arrow the object rotates left, and when the user presses the Right Arrow the object rotates right. The partial HTML code for the TetraToSphere program is given here: TetraToSphere.html. The partial Javascript code is given here: TetraToSphere.js. The first thing you need to do is add your six buttons with the appropriate labels to your HTML code below your canvas. Then, you will need to modify your Fragment Shader so that it uses either the black and the green color when given an appropriate uniform flag value. Let's assume the uniform value will be called "useBlack" again, like before. But this time it will be a "bool" variable, and if that is the case, you will need to first declare that uniform variable, and then your Fragment Shader's main method should look something like the following: if (useBlack)
{
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); // Black color
}
else
{
gl_FragColor = vec4( 0.0, 1.0, 0.0, 1.0 ); // Green color
}
In addition to this, you will need to make the following changes to your Javascript code:
Add a Comment block section to the top of your Javascript program in this assignment with the following information filled in using the following format: /*
* Course: CS 4722
* Section: .....
* Name: ......
* Professor: ......
* Assignment #: ......
*/
Be sure your program runs without error. DeliverablesTurn in the files:
Do this by uploading the file as an attachment to this Module's assignment drop box in D2L Brightspace. |