Question: Modify Program 4.4 to include a second planet, which is your custom 3D shape from Exercise 4.1. Make sure that your new planet is in

Modify Program 4.4 to include a second “planet,” which is your custom 3D shape from Exercise 4.1. Make sure that your new “planet” is in a different orbit than the existing planet, so that they don’t collide.

Exercise 4.1

Modify Program 4.1 to replace the cube with some other simple 3D shape of your own design. Be sure to properly specify the number of vertices in the glDrawArrays() command.

Program 4.1Java/JOGL Application import java.nio.*; import javax.swing.*; import java.lang.Math;import static com.jogamp.opengl.GL4.*; import com.jogamp.opengl.*; import com.jogamp.opengl.awt.GLCanvas;// allocate variables used in display() function, so that they won't need to be allocated during renderingpublic void init(GLAutoDrawable drawable) { GL4 gl= (GL4) GLContext.getCurrentGL(); rendering Program =public void display(GLAuto Drawable drawable) { GL4 gl = (GL4) GLContext.getCurrentGL(); gl.glClear(GL_DEPTH} // copy perspective and MV matrices to corresponding uniform variables gl.glUniformMatrix4fv(mvLoc, 1,private void setupVertices() { GL4 gl= (GL4) GLContext.getCurrentGL(); // 36 vertices of the 12 triangles} } -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f,

Program 4.4private Matrix4fStack mvStack = new Matrix4fStack(5); public void display(GLAutoDrawable drawable) { // setupgl.glDrawArrays(GL_TRIANGLES, 0, 18); mvStack.popMatrix(); // draw the sun // remove the sun's axial rotation} //-- smaller cube == moon mvStack.pushMatrix(); mvStack.translate(0.0f, (float)Math.sin(tf)*2.0f,

Java/JOGL Application import java.nio.*; import javax.swing.*; import java.lang.Math;

Step by Step Solution

3.42 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!