-- 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