void KeyCallback(unsigned char key, int x, int y) { switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("../../data/images/screenshot.jpg"); delete screenshot; } break; case 'r': pScene->GetCamera()->Reset(); break; case 'u': pScene->GetCamera()->ResetUp(); break; case 'q': exit(0); default: break; } glutPostRedisplay(); }
/** * Compute a morph through time by generating appropriate values of t and * repeatedly calling MorphImages(). Saves the image sequence to disk. */ void GenerateMorphFrames(STImage *sourceImage, const std::vector<Feature> &sourceFeatures, STImage *targetImage, const std::vector<Feature> &targetFeatures, float a, float b, float p) { // iterate and generate each required frame for (int i = 0; i <= kFrames - 1; ++i) { std::cout << "Metamorphosizing frame #" << i << "..."; // ********** // CS148 TODO: Compute a t value for the current frame and generate // the morphed image here. // ********** float t = easeFunction(i, kFrames); printf("\n%f\n", t); // float t = (float)i / (kFrames-1); STImage *result = MorphImages(sourceImage, sourceFeatures, targetImage, targetFeatures, t, a, b, p); // generate a file name to save std::ostringstream oss; oss << "frame" << std::setw(3) << std::setfill('0') << i << ".png"; // write and deallocate the morphed image if (result) { result->Save(oss.str()); delete result; } std::cout << " done." << std::endl; } }
void KeyCallback(unsigned char key, int x, int y) { switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("screenshot.jpg"); delete screenshot; } break; case 'r': resetCamera(); break; case 'u': resetUp(); break; case 'm': // switch between the mesh you create and the mesh from file mesh = !mesh; break; //case 'p': //switch proxy type between sphere and cylinder // proxyType=!proxyType; // if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); // else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); // break; case 'n': // switch between normalMapping and displacementMapping normalMapping = !normalMapping; break; case 'f': // switch between smooth shading and flat shading smooth = !smooth; break; //case 'l': // do loop subdivision // if(mesh){ // gTriangleMesh->LoopSubdivide(); // if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); // else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); // } // else // gManualTriangleMesh->LoopSubdivide(); // break; //case 'w': // gTriangleMesh->Write("output.obj"); // break; case 'a': for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->mDrawAxis=!gTriangleMeshes[id]->mDrawAxis; if(gManualTriangleMesh!=0) gManualTriangleMesh->mDrawAxis=!gManualTriangleMesh->mDrawAxis; break; case 'q': exit(0); default: break; } glutPostRedisplay(); }
void KeyCallback(unsigned char key, int x, int y) { switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("screenshot.jpg"); delete screenshot; } break; case 'r': resetCamera(); break; case 'm': // switch between the mesh you create and the mesh from file mesh = !mesh; break; case 'p': //switch proxy type between sphere and cylinder proxyType=!proxyType; if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); break; case 'n': // switch between normalMapping and displacementMapping normalMapping = !normalMapping; break; case 'f': // switch between smooth shading and flat shading smooth = !smooth; break; case 'l': // do loop subdivision if(mesh){ gTriangleMesh->LoopSubdivide(); if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); } else water->LoopSubdivide(); break; case 'q': exit(0); default: break; } glutPostRedisplay(); }
void KeyCallback(unsigned char key, int x, int y) { switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("screenshot.jpg"); delete screenshot; } break; case 'r': resetCamera(); break; case 't': teapot = !teapot; break; case '1': // lake mode lake = true; ocean = false; trampoline = false; t = 0.0; InitLakeWaves(); break; case '2': // ocean mode lake = false; ocean = true; trampoline = false; t = 0.0; break; case '3': lake = false; ocean = false; trampoline = true; t = 0.0; break; case 'q': exit(0); default: break; } glutPostRedisplay(); }
void KeyCallback(unsigned char key, int x, int y) { // TO DO: Any new key press events must be added to this function switch(key) { case 'a': { for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->mDrawAxis=!gTriangleMeshes[id]->mDrawAxis; if(gManualTriangleMesh!=0) gManualTriangleMesh->mDrawAxis=!gManualTriangleMesh->mDrawAxis; } break; case 'c': { // TO DO: Proj3_4 OpenGL // 1. Add a key press event 'c' that toggles the camera // between Fly and Orbit mode // 2. Use Camera::ToggleRotationMode //------------------------------------------------ pScene->GetCamera()->ToggleRotationMode(); //------------------------------------------------ } break; case 'd': { // TO DO: Proj3_4 OpenGL // 1. Add a key press event 'd' that toggles the scene // between ENVIRONMENTMAP and NAVIGATION mode // 2. Don't forget to change the RenderMode gloabl startMode // ToggleRenderMode() , set startMode, Setup() //------------------------------------------------ //------------------------------------------------ } break; case 'e': { // TO DO: Proj3_4 OpenGL // 1. Add a key press event 'e' that toggles the manipulator // geometry showing. This makes it easier to select // parts of the manipulator // ALL, TRANSONLY, ROTATEONLY // call ToggleManipGeometry() in the scene class //------------------------------------------------ //------------------------------------------------ } break; case 'f': {// switch between smooth shading and flat shading smooth = !smooth; } break; case 'k': { // TO DO: Proj3_4 OpenGL // 1. Add a key press event 'k' that toggles between local and parent mode // 2. Use Scene::ToggleManipMode() in scene class //------------------------------------------------ //------------------------------------------------ } break; case 'r': { pScene->GetCamera()->Reset(); } break; case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("../../data/images/screenshot.jpg"); delete screenshot; } break; // TO:DO do loop subdivision, uncomment this code // modify it so that it works with your sphere // simply make sure you are calling the functions // on the correct mesh. //--------------------------------- //case 'l': // if(mesh){ // gTriangleMesh->LoopSubdivide(); // if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); // else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(- case 'm': {// switch between the mesh you create and the mesh from file mesh = !mesh; } break; case 'n': { // switch between normalMapping and displacementMapping normalMapping = !normalMapping; } break; case 'u': { pScene->GetCamera()->ResetUp(); } break; case 'w': { for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->Write("output.obj"); } break; case 'q': { exit(0); } default: break; } glutPostRedisplay(); }
void KeyCallback(unsigned char key, int x, int y) { // TO DO: Any new key press events must be added to this function switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("../../data/images/screenshot.jpg"); delete screenshot; } break; case 'r': resetCamera(); break; case 'u': resetUp(); break; case 'm': // switch between the mesh you create and the mesh from file mesh = !mesh; break; case 'n': // switch between normalMapping and displacementMapping normalMapping = !normalMapping; break; case 't': createSphere(); break; // TO:DO do loop subdivision, uncomment this code // modify it so that it works with your sphere // simply make sure you are calling the functions // on the correct mesh. //--------------------------------- case 'l': if(mesh){ for(int i=0; i<gTriangleMeshes.size(); i++){ gTriangleMeshes[i]->LoopSubdivide(); if(proxyType) gTriangleMeshes[i]->CalculateTextureCoordinatesViaSphericalProxy(); //else // gTriangleMeshes[i]->CalculateTextureCoordinatesViaCylindricalProxy(); } break; case 'f': // switch between smooth shading and flat shading smooth = !smooth; break; case 'w': for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->Write("output.obj"); break; case 'a': for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->mDrawAxis=!gTriangleMeshes[id]->mDrawAxis; if(gManualTriangleMesh!=0) gManualTriangleMesh->mDrawAxis=!gManualTriangleMesh->mDrawAxis; break; case 'q': exit(0); default: break; } glutPostRedisplay(); } }