Question: Modify Program 4.4 so that the sun, planet, and moon are textured spheres, such as the ones shown in Figure 4.11. Program 4.4 Figure 4.11

Modify Program 4.4 so that the “sun,” “planet,” and “moon” are textured spheres, such as the ones shown in Figure 4.11.

Program 4.4private Matrix4fStack myStack= new Matrix4fStack(5); public void display(GLAuto Drawable drawable) { // setupgl.glDrawArrays(GL_TRIANGLES, 0, 18); mvStack.popMatrix(); ||------- cube == planet} //-- smaller cube == moon mvStack.pushMatrix(); mvStack.translate(0.0f, (float)Math.sin(tf)*2.0f,Figure 4.11private Matrix4fStack mvStack = new Matrix4fStack(5); public void display(GLAutoDrawable drawable) { //

private Matrix4fStack mvStack = new Matrix4fStack(5); public void display(GLAutoDrawable drawable) { // setup of background, depth buffer, rendering program, and proj matrices unchanged tf = elapsed Time/1000.0; // time factor, as before // push view matrix onto the stack mvStack.pushMatrix(); mvStack.translate(-cameraX, // -cameraY, -cameraZ); pyramid== sun mvStack.pushMatrix(); mvStack translate (0.0f, 0.0f, 0.0f); // sun's position // sun's rotation on its axis mvStack.pushMatrix(); mvStack.rotate((float)tf, 1.0f, 0.0f, 0.0f); gl.glUniformMatrix4fv(mvLoc, 1, false, mvStack.get(vals)); gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]); gl.glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0); gl.glEnable VertexAttribArray(0); gl.glEnable(GL_DEPTH_TEST);

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In the original Program 44 The sun is rendered using a pyramid The planet and moon are cubes In this assignment we will Replace these shapes with UVma... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Graphics Programming Questions!