Пример #1
0
//--------------------------------------------------------------
void PinballChinoManager::setup(){
    
    

    // setup bullet world
	world.setup();
	world.setGravity( ofVec3f(0, 10, 17) );

    // setup camera
	camera.setPosition(ofVec3f(0, -2, -15.f));
	camera.lookAt(ofVec3f(0, 0, 0), ofVec3f(0, -1, 0));
    camera.setDistance(20);
	world.setCamera(&camera);
    
    
    // load camera position
    savedPose = loadCameraPosition(); 
    camera.setTransformMatrix(savedPose);
    
    // setup scenario
	myScenario.setupMissions(&currentMissions);
	myScenario.setCurrentMission(idcurrentMission);
    myScenario.setup(world, bAddScenarioCover);
    
    // setup scenario editor
    ScenarioEditor::getInstance()->setup(world, myScenario);
    
    // collision detection
    world.enableCollisionEvents();

	// Arduino Comunication
	arduCom.setup();
	
	// Listeners
	ofAddListener(world.COLLISION_EVENT, this, &PinballChinoManager::onCollision);
	
	ofAddListener(eventObjectScenario::onNewObject ,this, &PinballChinoManager::listenerAddObject2Scenario);
	
	ofAddListener(eventMoveObjectScenario::onMoveObject ,this, &PinballChinoManager::listenerMovingObjectScenario);
    
   
    
    bDrawDebug = false;
    
    chinoLights.setup();
	
	
	//Shadows
	//simple_shadow.setup(&camera);
	

    webSock.setup(this);
    
}
Пример #2
0
//--------------------------------------------------------------
void PinballChinoManager::keyReleased(int key){
	
    switch(key)
    {
        case 'f':
            bFullScreen = !bFullScreen;
            ofSetFullscreen(bFullScreen);
            break;
            
        case 's':
            savedPose = camera.getGlobalTransformMatrix();
            saveCameraPosition(savedPose); // ideal to save on XML
            cout << "saved camera Pose xml" << endl;
            break;
	
        case 'l':
            savedPose = loadCameraPosition(); // write over the savedCamPose var
            camera.setTransformMatrix(savedPose);
            cout << "load camera Pose xml" << endl;
            break;
		case 'n':
			SoundManager::getInstance()->TogleMute();
            break;
			/*
		case 'g':
			myScenario.ScenarioObjects[11]->onCollision();
			myScenario.ScenarioObjects[12]->onCollision();
			myScenario.ScenarioObjects[13]->onCollision();
            break;
			*/
			
			
    }
    
    InputEventManager::keyReleased(key);
   
	ScenarioEditor::getInstance()->keyReleased(key);
    
}
Пример #3
0
//--------------------------------------------------------------
void myAmeManager::setup()
{
	//	For final setup. Do not touch!
	
	ofEnableSmoothing();

	setup_GUI1(); 
	gui1->loadSettings("GUI/guiSettings1.xml");
	gui1->setDrawBack(true);

	setup_GUI2(); 
	gui2->loadSettings("GUI/guiSettings2.xml");
	gui2->setDrawBack(true);

	setup_GUI3(); 
	gui3->loadSettings("GUI/guiSettings3.xml");
	gui3->setDrawBack(true);//false

	//Stadistics Draw
	bStadisticsVisible = true;

	loadCameraPosition();


	//Volumetrics setup
	imageSequence.init("volumes/bruce/IM-0001-0",3,".tif", 1);	
	volWidth = imageSequence.getWidth();
    volHeight = imageSequence.getHeight();
    volDepth = imageSequence.getSequenceLength();
    cout << "setting up volume data buffer at " << volWidth << "x" << volHeight << "x" << volDepth <<"\n";
    volumeData = new unsigned char[volWidth*volHeight*volDepth];

    for(int z=0; z<volDepth; z++)
    {
        imageSequence.loadFrame(z);
        for(int x=0; x<volWidth; x++)
        {
            for(int y=0; y<volHeight; y++)
            {
                // convert from greyscale to RGBA, false color
                int i4 = ((x+volWidth*y)+z*volWidth*volHeight);
                int sample = imageSequence.getPixels()[x+y*volWidth];
        

                volumeData[i4] = sample;

            }
        }
    }

    myVolume.setup(volWidth, volHeight, volDepth, ofVec3f(1,1,1));
    myVolume.updateVolumeData(volumeData,volWidth,volHeight,volDepth,0,0,0);
    myVolume.setRenderSettings(FBOq, Zq, density, thresh);
	myVolume.setVolumeTextureFilterMode(GL_LINEAR);

	myTracker.setup();								//	Tracker
	mesh_tracker_interaction.setup();				//	Load Mesh, important to be located after Load GUI params

	//camera
	bcameraMode = true;
	
	//animation
	timeAnimation = 4000;
	animationTimer.setup(timeAnimation, false);
	//animationTimer.startTimer();
	//animationTimer.pauseTimer();
	bactionTimer = false;

	//Experiment mode
	bexperimentmode = false;

}
Пример #4
0
//--------------------------------------------------------------
void myAmeManager::keyPressed(int key ){
    switch(key)
    {
	case 'h':
		gui1->toggleVisible(); 
		gui2->toggleVisible(); 
		gui3->toggleVisible(); 
		bStadisticsVisible = !bStadisticsVisible;
        break;
	case 's':
		gui1->saveSettings("GUI/guiSettings1.xml"); 
		gui2->saveSettings("GUI/guiSettings2.xml"); 
		gui3->saveSettings("GUI/guiSettings3.xml"); 

		saveCameraPosition();
		printf("camera matrix saved\n");
		break;
	case 'l':
		loadCameraPosition();
		gui1->loadSettings("GUI/guiSettings1.xml");
		gui2->loadSettings("GUI/guiSettings2.xml");
		gui3->loadSettings("GUI/guiSettings3.xml");
		break;
	case 'f':
		ofSetWindowPosition(0, 0);
		ofSetVerticalSync(false);
		//ofSetFullscreen(false);
		break;
	case 'F':
		ofSetWindowPosition(windowXpos, 0);
		ofSetVerticalSync(true);
		ofSetFullscreen(true);
		break;
    case OF_KEY_UP:
        if(bcameraMode)cam.getTarget().boom(-5);
		else {
			cam.tilt(1);
		}
        break;
    case OF_KEY_DOWN:
        if(bcameraMode)cam.getTarget().boom(5);
		else {
			cam.tilt(-1);
		}
        break;
    case OF_KEY_LEFT:
        if(bcameraMode)cam.getTarget().truck(-5);
		else {
			cam.pan(1);
		}
        break;
    case OF_KEY_RIGHT:
        if(bcameraMode)cam.getTarget().truck(5);
		else {
			cam.pan(-1);
		}
        break;
	case 'M':
		bcameraMode = !bcameraMode;
		break;
	case OF_KEY_RETURN:
		//sequence of movements animated with timer
		animationTimer.reset();
		//animationTimer.setup(1000, false);
		animationTimer.startTimer();
		bactionTimer = true;
		//animationTimer.resumeTimer();
		//Save clip position
		last_clipPlaneDepth = clipPlaneDepth;
		break;
	}
		
}