Modify Program 4.4 to include a second planet, which is your custom 3D shape from Exercise 4.1.

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

Step by Step Answer:

Related Book For  book-img-for-question

Computer Graphics Programming In OpenGL With JAVA

ISBN: 9781683922193

2nd Edition

Authors: V. Scott Gordon PhD, John L. Clevenger PhD

Question Posted: