CS 4722 - Computer Graphics and Multimedia
Module #2, Assignment #1Exercise #1Create the following static cube image: You must use the following cube vertices (although you need to rearrange them and add duplicates of them): vec3(-0.5, -0.5, 0.5), // Vertex 0
vec3(-0.5, 0.5, 0.5), // Vertex 1
vec3(0.5, 0.5, 0.5), // Vertex 2
vec3(0.5, -0.5, 0.5), // Vertex 3
vec3(-0.5, -0.5, -0.5), // Vertex 4
vec3(-0.5, 0.5, -0.5), // Vertex 5
vec3(0.5, 0.5, -0.5), // Vertex 6
vec3(0.5, -0.5, -0.5), // Vertex 7
And you must use the following corresponding colors per vertex: vec4(0.0, 0.0, 0.0, 1.0), // black for Vertex 0
vec4(1.0, 0.0, 0.0, 1.0), // red for Vertex 1
vec4(1.0, 1.0, 0.0, 1.0), // yellow for Vertex 2
vec4(0.0, 1.0, 0.0, 1.0), // green for Vertex 3
vec4(0.0, 0.0, 1.0, 1.0), // blue for Vertex 4
vec4(1.0, 0.0, 1.0, 1.0), // magenta for Vertex 5
vec4(1.0, 1.0, 1.0, 1.0), // white for Vertex 6
vec4(0.0, 1.0, 1.0, 1.0), // cyan for Vertex 7
And you must use the following rendering call: gl.drawArrays(gl.TRIANGLES, 0, vertices.length);
And you must use the following vertice locations per triangle: 1, 0, 3
3, 2, 1
2, 3, 7
7, 6, 2
3, 0, 4
4, 7, 3
6, 2, 1
1, 5, 6
4, 5, 6
6, 7, 4
5, 4, 0
0, 1, 5
The HTML code for your program is given here StaticCube.html. This code is complete and you will not need to modify it. The partial Javascript code is given here StaticCube.js. Exercise #2Create the following SpinningCube program that rotates the following cube, with buttons below the cube that change the rotation into the direction of the axis that you select. For this program you are to use a gl.ELEMENT_ARRAY_BUFFER type of buffer as an index buffer called iBuffer. The HTML code for your program is given here SpinningCube.html. This code is complete and you will not need to modify it. The partial Javascript code is given here SpinningCube.js. This code is incomplete and you will need to modify it in the following ways:
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. |