2019-02-26

Feb 27 In-Class Exercise Thread.

Post your solutions to the Feb 27 In-Class Exercise to this thread.
Best,
Chris
Post your solutions to the Feb 27 In-Class Exercise to this thread. Best, Chris
2019-03-06

-- Feb 27 In-Class Exercise Thread
To create another object, be it a plane or a cylinder, you need to follow 3 steps. First, you need to create 3 new buffers for the object(vertex, color,index). Next you need to create the model view matrix to get the uniform matrix. Finally you call the method to draw elements.
To create another object, be it a plane or a cylinder, you need to follow 3 steps. First, you need to create 3 new buffers for the object(vertex, color,index). Next you need to create the model view matrix to get the uniform matrix. Finally you call the method to draw elements.

-- Feb 27 In-Class Exercise Thread
To draw a second cube in the same scene, we need to create another buffer for the second cube, create another gl worldmatrix, and call gl uniform for the second cube worldmatrix, then call gl drawElement to draw it on the scene.
To draw a second cube in the same scene, we need to create another buffer for the second cube, create another gl worldmatrix, and call gl uniform for the second cube worldmatrix, then call gl drawElement to draw it on the scene.

-- Feb 27 In-Class Exercise Thread
To draw a second cube in the same scene, you need to add the vertices to the vertex buffer, the indices to the index buffer, and the colors if you want color. That is the easy, brute force method. However to separate each object into their own matrix, looking at the answers above, you need to repeat initBuffers with different values for the data arrays to bind to the buffers in another matrix (I haven't actually tried it; I only used one matrix for HW#2).
 
To draw a plane, you just initialize an array of 4 3Dvectors that cover each corner of the plane, and then specify the indices of those 2 triangles to be drawn in the indices buffer.
For a cylinder you can use a formula: the higher numSegments is the smoother your cylinder will be
for(int i = -3.14; i < 3.14; i+=2*3.14/numSegments) x = cos(angle)*radius z = sin(angle)*radius y = 1
repeat this code twice for y=-1
To draw a second cube in the same scene, you need to add the vertices to the vertex buffer, the indices to the index buffer, and the colors if you want color. That is the easy, brute force method. However to separate each object into their own matrix, looking at the answers above, you need to repeat initBuffers with different values for the data arrays to bind to the buffers in another matrix (I haven't actually tried it; I only used one matrix for HW#2). To draw a plane, you just initialize an array of 4 3Dvectors that cover each corner of the plane, and then specify the indices of those 2 triangles to be drawn in the indices buffer. For a cylinder you can use a formula: the higher numSegments is the smoother your cylinder will be for(int i = -3.14; i < 3.14; i+=2*3.14/numSegments) x = cos(angle)*radius z = sin(angle)*radius y = 1 repeat this code twice for y=-1
2019-03-11

-- Feb 27 In-Class Exercise Thread
To draw a second cube, you must create another buffer, worldMatrix, and use drawElement.
To draw a second cube, you must create another buffer, worldMatrix, and use drawElement.
X