Exemple #1
0
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();
}
Exemple #2
0
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();
}
Exemple #6
0
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();
}
}