//////////////////////////////////////////////////////////////////////// // Called by GLUT when the scene needs to be redrawn. void ReDraw() { float rx = (scene.width * scene.ry) / (scene.height); if (scene.canMove) { vec3 temp = vec3(scene.eyePos[0] * -1, scene.eyePos[1] * -1, scene.eyePos[2] * -1); scene.WorldView = Translate(temp) * Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = Translate(-1*scene.eyePos.x, -1*scene.eyePos.y, -1*scene.eyePos.z) * Rotate(0, scene.tilt - 90)*Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); //scene.WorldView = Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90) * Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90); //scene.WorldView = Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin) *Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); } else { scene.WorldView = Translate(scene.tx, scene.ty, -1 * scene.zoom) * Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); // scene.WorldView = Translate(scene.tx, scene.ty, -1 * scene.zoom); // scene.WorldView = scene.WorldView * Rotate(0, scene.tilt - 90); // scene.WorldView = scene.WorldView * Rotate(2, scene.spin); } scene.WorldProj = Perspective(rx, scene.ry, scene.front, scene.back); scene.DrawScene(); TwDraw(); glutSwapBuffers(); }
void display (void) { /** Create Scene, This will parse the scenefile and start off the rendering process */ printf("Display function \n"); Scene myScene = Scene(scenefile); float width = myScene.imgWidth; float height = myScene.imgHeight; glWindowSizeX = width; glWindowSizeY = height; gluOrtho2D(0., glWindowSizeX, 0., glWindowSizeY); glViewport(0., 0., glWindowSizeX, glWindowSizeY); glutReshapeWindow(glWindowSizeX, glWindowSizeY); for (float i = 0; i < width; i++) { for (float j = 0; j < height; j++) { myScene.RenderScene(i, j); } } /* Perform Reflection now after all pixels havebeen rendered */ myScene.DrawScene(); glutSwapBuffers(); }
//////////////////////////////////////////////////////////////////////// // Called by GLUT when the scene needs to be redrawn. void ReDraw() { float rx = (scene.width * scene.ry) / (scene.height); if (scene.canMove) { if (scene.wDown) { scene.eyePos += scene.speed*(sin((scene.spin)*PI / 180), cos(scene.spin*PI / 180), 0); } if (scene.aDown) { scene.eyePos += scene.speed*((-1 * cos(scene.spin*PI / 180)), sin((scene.spin)*PI / 180), 0); } if (scene.sDown) { scene.eyePos -= scene.speed*(sin((scene.spin)*PI / 180), cos(scene.spin*PI / 180), 0); } if (scene.dDown) { scene.eyePos -= scene.speed*((-1 * cos(scene.spin*PI / 180)), sin((scene.spin)*PI / 180), 0); } Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); scene.WorldView = MAT4(); //scene.WorldView = makeEyeViewingTransform(scene.view, scene.upVector, scene.w) *Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); // *Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * makeEyeViewingTransform(scene.view, scene.upVector, scene.w); //scene.WorldView = Translate(-1*scene.eyePos.x, -1*scene.eyePos.y, -1*scene.eyePos.z) * Rotate(0, scene.tilt - 90)*Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); //scene.WorldView = Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90) * Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90); //scene.WorldView = Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin) *Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); } else { scene.WorldView = Translate(scene.tx, scene.ty, -1 * scene.zoom) * Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); // scene.WorldView = Translate(scene.tx, scene.ty, -1 * scene.zoom); // scene.WorldView = scene.WorldView * Rotate(0, scene.tilt - 90); // scene.WorldView = scene.WorldView * Rotate(2, scene.spin); } scene.WorldProj = Perspective(rx, scene.ry, scene.front, scene.back); scene.DrawScene(); TwDraw(); glutSwapBuffers(); }
//////////////////////////////////////////////////////////////////////// // Called by GLUT when the scene needs to be redrawn. void ReDraw() { float rx = (scene.width * scene.ry) / (scene.height); if (scene.canMove) { //vec3 temp = (scene.eyePos); if (scene.wDown) {//Stare at these for a little bit, THIS CLOSE //scene.eyePos += scene.speed*vec3(sin((scene.spin)*PI / 180), cos(scene.spin*PI / 180), 0); x -= speed*sin((scene.spin)*PI / 180); y -= speed *cos((scene.spin)*PI / 180); } if (scene.aDown) { //scene.eyePos -= scene.speed*vec3(cos((scene.spin)*PI / 180), -1 * sin((scene.spin)*PI / 180), 0.0); x +=speed* cos(scene.spin*PI / 180); y += speed*-1*sin(scene.spin*PI / 180); } if (scene.sDown) { //scene.eyePos = scene.eyePos - scene.speed*vec3(sin((scene.spin)*PI / 180), cos(scene.spin*PI / 180), 0); x += speed*sin(scene.spin*PI / 180); y += speed*cos(scene.spin*PI / 180); } if (scene.dDown) { //scene.eyePos = scene.eyePos + scene.speed*vec3(( cos(scene.spin*PI / 180)), -1*sin((scene.spin)*PI / 180), 0); x -= speed * cos(scene.spin*PI / 180); y -= speed*-1*sin(scene.spin*PI / 180); } //Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //scene.WorldView = MAT4(); //scene.WorldView = makeEyeViewingTransform(scene.view, scene.upVector, scene.w) *Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); // *Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * makeEyeViewingTransform(scene.view, scene.upVector, scene.w); //scene.WorldView = Translate(-1*scene.eyePos.x, -1*scene.eyePos.y, -1*scene.eyePos.z) * Rotate(0, scene.tilt - 90)*Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); //scene.WorldView = Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90) * Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyp ePos.z); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * Rotate(2, scene.spin) * Rotate(0, scene.tilt - 90); //scene.WorldView = Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin) *Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //scene.WorldView = makeEyeViewingTransform(scene.eyePos, scene.upVector, scene.w) * Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //* Rotate(0, scene.tilt-90) * Rotate(2, scene.spin); //scene.WorldView = Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z) * makeEyeViewingTransform(scene.eyePos, scene.upVector, scene.w); //scene.WorldView = makeEyeViewingTransform(scene.eyePos, scene.upVector, scene.w) * Translate(-1 * scene.eyePos.x, -1 * scene.eyePos.y, -1 * scene.eyePos.z); //scene.WorldView = Translate(-1 * scene.eyePos[0], -1 * scene.eyePos[1], -1 * scene.eyePos[2]) * Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); scene.WorldView = Rotate(0, scene.tilt - 90)* Rotate(2, scene.spin) * Translate(-scene.eyePos.x + x, -scene.eyePos.y + y, -scene.eyePos.z);//*Translate(-scene.eyePos.x + x, -scene.eyePos.y + y, -scene.eyePos.z);//Translate((-1 * x + scene.tx), (-1*y +scene.ty), (-1*z+(-1*scene.zoom))); } else { //scene.translate = Translate(scene.tx, scene.ty, -1 * scene.zoom); scene.WorldView = ( Translate(scene.tx, scene.ty, -1*scene.zoom)) * Rotate(0, scene.tilt - 90) * Rotate(2, scene.spin); //scene.WorldView = scene.WorldView * Rotate(2, scene.spin); // scene.WorldView = Translate(scene.tx, scene.ty, -1 * scene.zoom); // scene.WorldView = scene.WorldView * Rotate(0, scene.tilt - 90); // scene.WorldView = scene.WorldView * Rotate(2, scene.spin); } scene.WorldProj = Perspective(rx, scene.ry, scene.front, scene.back); scene.DrawScene(); TwDraw(); glutSwapBuffers(); }