Add animation to Program 8.1, such that either the objects or the light (or both) move around

Question:

Add animation to Program 8.1, such that either the objects or the light (or both) move around on their own—such as one revolving around the other. The shadow effects will be more pronounced if you add a ground plane to the scene, such as the one illustrated in Figure 8.14.

Program 8.1// Much is the same as we have seen before. New sections to support shadows are highlighted. // The importsprivate float[] lightAmbient = new float[] {0.Of, 0.0f, 0.0f, 1.0f}; private float[] lightDiffuse = new// shadow-related variables private int screen SizeX, screenSizeY; private int [] shadow Tex = new int [1];rendering Program1= Utils.createShaderProgram("code/vert1shader.gisl", rendering Program2=setupVertices(); setupShadowBuffers (); b.set( 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f,gl.glBind Texture(GL_TEXTURE_2D, shadow Tex[0]); gl.glTexlmage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32,// set up perspective matrix for the camera, either here or in init() // set up view and perspective matrix} // make the custom frame buffer current, and associate it with the shadow texture// What follows now are the methods for the first and second passes. // They are largely identical to things// we are drawing from the light's point of view, so we use the light's P and V matrices} gl.glClear(GL_DEPTH_BUFFER_BIT); gl.glEnable(GL_CULL_FACE); gl.glFrontFace (GL_CCW);public void pass Two() { GL4 gl = (GL4) GLContext.getCurrentGL(); // rendering Program2 includes the pass twovMat.identity().setTranslation (-cameraLoc.x(), -cameraLoc.y(), -cameraLoc.z());shadowMVP2.mul(b); shadowMVP2.mul(lightPmat); shadowMVP2.mul(lightVmat); shadowMVP2.mul(mMat); // put the MV} gl.glClear(GL_DEPTH_BUFFER_BIT); gl.glEnable(GL_CULL_FACE); gl.glFront Face(GL_CCW);

Figure 8.14image 

Fantastic news! We've Found the answer you've been seeking!

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: