Ejemplo n.º 1
0
void faces::update(float f){
    switch(status){
        case LOADINGFACE:
            if(ofGetElapsedTimeMillis()-timeStatusChanged>LOADINGFACE_TIME){
                status = FACE_FINISHED;
                timeStatusChanged=ofGetElapsedTimeMillis();
            }
            break;
        case FACE_FINISHED:
            if(ofGetElapsedTimeMillis()-timeStatusChanged>LOADEDFACE_TIME){
                status = PREPARE_NEW_FACE;
                if(currentFace<NCARAS-1) {
                    currentFace++;
                }
                else{
                    status=ALL_FACES_LOADED;
                }
                timeStatusChanged=ofGetElapsedTimeMillis();
            }
        break;
        case PREPARE_NEW_FACE:
            status = LOADINGFACE;
            break;
        case ALL_FACES_LOADED:
            if(ofGetElapsedTimeMillis()-timeStatusChanged>ALL_FACES_LOADED_TIME){
                if(end_of_scene_sent==false){
                    ofSendMessage("endOfScene");
                    end_of_scene_sent=true;
                }
            }
            break;
            
    }
    
}
Ejemplo n.º 2
0
void SceneStaffRoll::update() {
    if (ofGetFrameNum() == 0) {
        return;
    }
    float dt = ofGetLastFrameTime();
    current->updateAnimation(dt);
    if (!isLastImage) {
        next->updateAnimation(dt);
    }

    if (current->shouldStartNext()) {
        next->startAnimation();
    }

    if (!current->getAnimating()) {
        if (isLastImage) {
            ofSendMessage(ofMessage("StaffRollEnd"));
        }
        current = next;
        next++;
        if (next == images.end()) {
            isLastImage = true;
            next = images.begin();
//            ofSendMessage(ofMessage("StaffRollEnd"));
        }
    }

    if (useNameList) {
        staffRoll.update();
    }
}
Ejemplo n.º 3
0
void ofxTextInputField::disable() {
    if(isEnabled){
        ofRemoveListener(ofEvents().keyPressed, this, &ofxTextInputField::keyPressed);
        ofSendMessage(TEXTFIELD_IS_INACTIVE);
        isEnabled = false;
        drawCursor = false;
    }
}
Ejemplo n.º 4
0
void ofxTextInputField::enable() {
    if(!isEnabled){
        ofAddListener(ofEvents().keyPressed, this, &ofxTextInputField::keyPressed);
        ofSendMessage(TEXTFIELD_IS_ACTIVE);
        isEnabled = true;
        drawCursor = true;
    }
}
void ofxTextInputField::endEditing() {
    if(isEditing){
        ofRemoveListener(ofEvents().keyPressed, this, &ofxTextInputField::keyPressed);
        ofSendMessage(TEXTFIELD_IS_INACTIVE);
        ofNotifyEvent(textChanged, text, this);
        isEditing = false;
        drawCursor = false;
    }
}
Ejemplo n.º 6
0
BaseSurface * SurfaceManager::selectSurface(int index){
	if(index >= _surfaces.size()){
		throw runtime_error("Surface index out of bounds.");
	}

	selectedSurface = _surfaces[index];
	ofSendMessage("surfaceSelected");
	return selectedSurface;
}
Ejemplo n.º 7
0
void trackManager::playItem(int index){
	//cout << "play track" << index << endl;
	currentItem=index;
	bTimerReached = false;
    startTime = ofGetElapsedTimeMillis();  // get the start time
    endTime = track[index].time*1000/speed; // in milliseconds;
	
	ofMessage msg(ofToString(track[currentItem].frequency));
	ofSendMessage(msg);
}
Ejemplo n.º 8
0
BaseSurface * SurfaceManager::selectSurface(BaseSurface * surface){
	for(int i = 0; i < _surfaces.size(); i++){
		if(_surfaces[i] == surface){
			selectedSurface = surface;
			ofSendMessage("surfaceSelected");
			return selectedSurface;
		}
	}
	
	deselectSurface();
	return 0;
}
Ejemplo n.º 9
0
void testApp::update(){
    
	tuioClient.getMessage();
	float dt = 0.016666666;
	sceneManager->update( dt );

	//
	// sceneManager->goToScene(SCENE_1, true); /* true >> regardless of curtain state (so u can change state while curtain is moving)*/	
	//
	if(timeToEndScene !=-1 && timeToEndScene<ofGetElapsedTimeMillis()){
        ofSendMessage("changeScene" +ofToString(SCENE_MENU));
    }
}
Ejemplo n.º 10
0
void TextBox::beginEditing() {
    if(!isEditing){
        ofAddListener(ofEvents().keyPressed, this, &TextBox::keyPressed);
        ofSendMessage(TEXTFIELD_IS_ACTIVE);
        isEditing = true;
        drawCursor = true;
		if(autoClear){
			clear();
		} else {
			cursory = 0;
			cursorPosition = cursorx = text.size();
		}
    }
}
Ejemplo n.º 11
0
void Tracker::update() {
	if (!AcquireFrame(false)) return;
	if (!labelMap) return;

	PXCImage *image;
	if (QueryGesture()->QueryBlobImage(PXCGesture::Blob::LABEL_SCENE, 0, &image) >= PXC_STATUS_NO_ERROR) {
		PXCImage::ImageData data;
		if (image->AcquireAccess(PXCImage::ACCESS_READ, &data) >= PXC_STATUS_NO_ERROR) {
			tex.loadData(data.planes[0], tex.getWidth(), tex.getHeight(), GL_LUMINANCE);
			image->ReleaseAccess(&data);
		}
	}

	PXCGesture::Gesture *gesture = new PXCGesture::Gesture();
	if (QueryGesture()->QueryGestureData(0, PXCGesture::GeoNode::LABEL_BODY_HAND_PRIMARY, 0, gesture) >= PXC_STATUS_NO_ERROR) {
		string name = "";
		switch (gesture->label) {
			case PXCGesture::Gesture::LABEL_HAND_CIRCLE: name = "CIRCLE"; break;
			case PXCGesture::Gesture::LABEL_HAND_WAVE: name = "WAVE"; break;
			case PXCGesture::Gesture::LABEL_POSE_BIG5: name = "HIGH5"; break;
			case PXCGesture::Gesture::LABEL_POSE_THUMB_UP: name = "THUMBUP"; break;
			case PXCGesture::Gesture::LABEL_POSE_THUMB_DOWN: name = "THUMBDOWN"; break;
			case PXCGesture::Gesture::LABEL_NAV_SWIPE_DOWN: name = "SWIPEDOWN"; break;
			case PXCGesture::Gesture::LABEL_NAV_SWIPE_LEFT: name = "SWIPELEFT"; break;
			case PXCGesture::Gesture::LABEL_NAV_SWIPE_RIGHT: name = "SWIPERIGHT"; break;
			case PXCGesture::Gesture::LABEL_NAV_SWIPE_UP: name = "SWIPEUP"; break;
		}

		if (name != "") {
			if (!timeout.isRunning()) {
				timeout.setParameters(easing, ofxTween::easeIn, 0, 1, 1000, 0); // ONLY SEND ONCE PER SECOND
				ofSendMessage("GESTURE_" + name);
			} 
		}
	}

	if (timeout.isRunning()) timeout.update();

	PXCGesture::GeoNode indexData;
	QueryGesture()->QueryNodeData(0, PXCGesture::GeoNode::LABEL_BODY_HAND_PRIMARY|PXCGesture::GeoNode::LABEL_FINGER_THUMB, &indexData);
	ofPoint p;
	p.x = ofMap(indexData.positionImage.x, 0, 320, ofGetWidth(), 0, true);
	p.y = ofMap(indexData.positionImage.y, 0, 240, 0, ofGetHeight(), true);
	p.z = indexData.radiusImage;
	ofNotifyEvent(GEONODE_POSITION_CHANGE, p);

	ReleaseFrame();
}
void ofxTextInputField::beginEditing() {
    if(!isEditing){
        ofAddListener(ofEvents().keyPressed, this, &ofxTextInputField::keyPressed);
        ofAddListener(ofEvents().keyReleased, this, &ofxTextInputField::keyReleased);
        ofSendMessage(TEXTFIELD_IS_ACTIVE);
        isEditing = true;
        drawCursor = true;
		if(autoClear){
			clear();
		}
		else{


		}
    }
}
Ejemplo n.º 13
0
void trackManager::update(){
	float timer = ofGetElapsedTimeMillis() - startTime;
    
    if(timer >= endTime && !bTimerReached) {
        bTimerReached = true; 
		
		currentItem++;
		if(currentItem<track.size()){
			playItem(currentItem);
		} else {
            ofMessage msg("end");
            ofSendMessage(msg);

        }
    }
}
Ejemplo n.º 14
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){

  KeysState[key] = true; // 记录按键状态

  if(!MouseKeyState[0]) // 未拖动时才可以改变角色大小
  {
    switch (key) // 依据key的取值来选择执行的内容
    {
    case '1':// 若key为1,设半径为25
      pPlayer->setSize(25.0f);    
      playSoundAtVolumeSpeed(Sounds["ChangeSize"], 0.3f, 1.5f);
      break;
    case '2':// 若key为2,设半径为50
      pPlayer->setSize(50.0f);		
      playSoundAtVolumeSpeed(Sounds["ChangeSize"], 0.5f, 1.0f);
      break;
    case '3':// 若key为3,设半径为75
      pPlayer->setSize(75.0f);		
      playSoundAtVolumeSpeed(Sounds["ChangeSize"], 1.0f, 0.5f);
      break;	
    }
  }
  else
  {
    if(key=='1'||key=='2'||key=='3')
    {
      playSoundAtVolumeSpeed(Sounds["Error"]);
    }
  }

  switch (key) // 依据key的取值来选择执行的内容
  {	
  case OF_KEY_F1: // 若key为F1:切换调试信息的可见性
    ofSendMessage("ToggleShowDebug");
    break;
  case OF_KEY_F2: // F2: 保存图片
    saveCanvasImage();
    break;
  case OF_KEY_F5: // F5: 启动游戏
    startGame();
    break;
  default:// 默认逻辑为空
    break;
  }
}
Ejemplo n.º 15
0
//--------------------------------------------------------------
void ofApp::draw(){

    float barWidth = 500;
		
    // update the timer this frame
    float timer = ofGetElapsedTimeMillis() - startTime;
    
    if(timer >= endTime && !bTimerReached) {
        bTimerReached = true;        
        ofMessage msg("Timer Reached");
        ofSendMessage(msg);
    }
    
    // the background to the progress bar
    ofSetColor(100);
    ofRect((ofGetWidth()-barWidth)/2, ofGetHeight()/2, barWidth, 30);
    
    // get the percantage of the timer
    float pct = ofMap(timer, 0.0, endTime, 0.0, 1.0, true);
    ofSetHexColor(0xf02589);
    ofRect((ofGetWidth()-barWidth)/2, ofGetHeight()/2, barWidth*pct, 30);

    // draw the percantage
    ofSetColor(20);
    ofDrawBitmapString(ofToString(pct*100, 0)+"%", ((ofGetWidth()-barWidth)/2)+barWidth+10, (ofGetHeight()/2)+20);
    
    // the timer was reached :)
    if(bTimerReached) {
        ofSetColor(20);
        ofDrawBitmapString("Timer Reached!", (ofGetWidth()-100)/2, (ofGetHeight()/2)+70);
    }
    
    // some information about the timer
    string  info  = "FPS:        "+ofToString(ofGetFrameRate(),0)+"\n";
            info += "Start Time: "+ofToString(startTime, 1)+"\n";
            info += "End Time:   "+ofToString(endTime/1000.0, 1)+" seconds\n";
            info += "Timer:      "+ofToString(timer/1000.0, 1)+" seconds\n";
            info += "Percentage: "+ofToString(pct*100, 1)+"%\n";
            info += "\nPress ' ' to get a new random end time\n";
    ofSetColor(0);
    ofDrawBitmapString(info, 20, 20);
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
void ClientOSCManager::_update(ofEventArgs &e)
{
	// check for waiting messages
	while( receiver.hasWaitingMessages() )
	{
		// get the next message
		ofxOscMessage m;
		receiver.getNextMessage(&m);
		
		//cout << "Got message: " << m.getAddress() << endl;
		
		if( m.getAddress() == "/hello" )
		{
			// if we get a hello message and we haven't set up our sender, get the Ip and port from the hello message
			if( !haveSetupSender )
			{
				int sendPort = m.getArgAsInt32(0);
				sender.setup( m.getRemoteIp(), sendPort );
				commonTimeOsc.senderIsSetup( true );
				haveSetupSender = true;
			}
		}
		else if( m.getAddress() == "/pong" )
		{
			// pong messages come in as: /pong, receiving computer ID (int), server timestamp (int), timestamp when remote computer sent (int)
			
			if( m.getArgAsInt32(0) == uniqueComputerID )  	// if the message is for us
			{
				int serverTime = m.getArgAsInt32(1);
				int originalTimeStamp = m.getArgAsInt32(2);
				
				commonTimeOsc.newReading( serverTime, commonTimeOsc.getInternalTimeMillis() - originalTimeStamp );
			}
		}
		else if( m.getAddress() == "/change_scene" )
		{
			int sceneIndex = m.getArgAsInt32(0);
			ofSendMessage("change_scene " + ofToString(sceneIndex) );
		}
	}
	
}
Ejemplo n.º 17
0
//--------------------------------------------------------------
void Player::setChooseModel() {
    ofSendMessage("SETMODEL,PLAYER,"+ofToString(ID));
}
Ejemplo n.º 18
0
//------------------------------------------------------------------------------
void ofApp::onCalendarWatcherError(const Poco::Exception& exception)
{
    ofSendMessage("ERROR: " + exception.displayText());
}
Ejemplo n.º 19
0
//------------------------------------------------------------------------------
void ofApp::onCalendarWatcherEventEnded(const ICalendarEventInstance& instance)
{
    ofSendMessage("ENDED: " + instance.getEvent().getSummary() );
}
Ejemplo n.º 20
0
//------------------------------------------------------------------------------
void ofApp::onCalendarWatcherEventStarted(const ICalendarEventInstance& instance)
{
    ofSendMessage("STARTED: " + instance.getEvent().getSummary() );

    processInstance(instance);
}
Ejemplo n.º 21
0
//------------------------------------------------------------------------------
void ofApp::onCalendarWatcherEventModified(const ICalendarEventInstance& instance)
{
    ofSendMessage("MODIFIED: " + instance.getEvent().getSummary() );

    processInstance(instance);
}
Ejemplo n.º 22
0
//------------------------------------------
bool ofSendMessage(string messageString){
	ofMessage msg(messageString);
	return ofSendMessage(msg);
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
void Player::setChooseTexture() {
    ofSendMessage("SETTEXTURE,PLAYER,"+ofToString(ID));
}
Ejemplo n.º 24
0
void trackManager::stop(){
	bTimerReached=true;
	ofMessage msg(ofToString(0));
	ofSendMessage(msg);
}
Ejemplo n.º 25
0
//--------------------------------------------------------------
void Tunnel::draw(float alph){
    if (!isPaused) {
        camera.enableMove();
    }
    camera.begin();
    if (!camTargSet) {
        camera.target(ofVec3f(0,0,1));
        camTargSet = true;
    }
    
    camPos = camera.getPosition();
	hallLight.enable();

    if (!secondTime) {
        hallLight.setPosition(camera.getPosition());
        float attenuationFactor = 0.008 * (2560.0/ofGetScreenWidth());
        hallLight.setAttenuation(0,attenuationFactor,0);
    } else {
        hallLight.setPosition(0,0,0);
        hallLight.setAttenuation(1,0,0);
    }
    
    ofPushMatrix();
    ofSetColor(255,255-alph);
    glLineWidth(1);
    
    ofxAssimpMeshHelper & meshHelper = hallModel.getMeshHelper(0);
    ofMultMatrix(hallModel.getModelMatrix());
    ofMultMatrix(meshHelper.matrix);


    //*
    
    if (isClipping) {
    
        ofVec3f testPos = camPos;                       //Hacky-ass clipping
        
        
        if (testPos.x < goal2.x + hallWidth) {
            if (testPos.x < goal2.x-hallWidth) {
                testPos.x = goal2.x-hallWidth;
            }
        }
        
        if ((testPos.z >= goal1.z && testPos.x > goal2.x+hallWidth*1.5) || (testPos.z <= goal1.z-hallWidth && abs(testPos.x) >= hallWidth*1.5)) {
            if (testPos.z > goal1.z+(hallWidth*0.8)) {
                testPos.z = goal1.z+(hallWidth*0.8);
            } else if (testPos.z < goal1.z-(hallWidth)) {
                testPos.z = goal1.z-(hallWidth);
            }
        }
        
        if (testPos.x > goal2.x+hallWidth && testPos.z >= goal1.z+hallWidth*1.5){
            testPos.x = goal2.x+hallWidth;
        }
        
        if (testPos.z < goal1.z-hallWidth && abs(testPos.x) < hallWidth*1.5) {
            if (testPos.x > hallWidth){
                testPos.x = hallWidth;
            } else if (camPos.x < -hallWidth) {
                testPos.x = -hallWidth;
            }
            
            if (testPos.z < -53 * distFactor) {
                testPos.z = -53 * distFactor;
            }
        }
        
        if (testPos != camPos) {
            camera.clip(testPos);
        }
    }
    //cout << "camPos.z: " << camPos.z << " | camPos.z: " << camPos.z/distFactor << endl;

    //*/
    
    if (!secondTime) {
        if (camera.getPosition().squareDistance(goal1) < (4900.0 * distFactor)) {
            ofSendMessage("TunnelA:1:3");
        }
        
        if (camera.getPosition().squareDistance(goal2) < (4900.0 * distFactor)) {
            ofSendMessage("TunnelA:2:3");
        }
    }
    
    if (secondTime) {
        if (camera.getPosition().squareDistance(goal1) < (250000.0 * distFactor) || camera.getPosition().squareDistance(goal2) < (250000.0 * distFactor)) {
            ofSendMessage("TunnelB:0:7");
        }
    }
    
    //hallMesh.drawFaces();
    hallMesh.drawWireframe();
    
    
    
    ofPopMatrix();
    
    hallLight.disable();
    ofDisableLighting();
    
    camera.end();
}
Ejemplo n.º 26
0
//------------------------------------------
void ofSendMessage(string messageString){
	ofMessage msg(messageString);
	ofSendMessage(msg);
}
Ejemplo n.º 27
0
//------------------------------------------------------------------------------
void ofApp::onCalendarWatcherEventRemoved(const ICalendarEventInstance& instance)
{
    // note, there is a good chance this event will be invalid
    ofSendMessage("REMOVED: " + instance.getEvent().getUID());
}
Ejemplo n.º 28
0
//--------------------------
void Ancient::threadedFunction()
{
    while( isThreadRunning() != 0 )
    {
        if( lock() )
        {
            std::vector<DTrack>::iterator track;
            if(m_tasks.size())
            {
                string task = m_tasks.at(0);
                m_tasks.erase(m_tasks.begin());
                // update variation for all tracks
                
                for(track = m_tracks.begin(); track != m_tracks.end(); ++track) 
                {
                    if(task == "jacc_var")
                    {    
                        track->set_jaccard_variation(m_jacc_variation);
                    }
                    else if(task == "xor_var")
                    {
                        track->set_xor_variation(m_xor_variation);
                    }
                    else if(task == "swing")
                    {
                        m_groove =Seq::classic_swing(m_swing);
                    }
                    else if(task == "evolve")
                    {
                        track->evolve(m_level, m_variat);
                    }
                    else if (task == "reset_variation")
                    {
                        track->set_xor_variation(0);
                        track->set_jaccard_variation(0);
                    }
                    else if (task == "load")
                    {
                        track->load_preset(m_preset);
                    }
                }
                if (task == "load")
                {
                    m_preset->popTag();
                    m_preset->pushTag("global");
                    m_preset->pushTag("seq_groove");
                    int ct = m_preset->getNumTags("i");
                    vector<float> groove;
                    for(int i = 0; i < ct; ++i)
                    {
                        groove.push_back(m_preset->getValue("i", 0., i));
                    }
                    m_groove = groove;
                    ofSendMessage("preset_loaded");
                }
            }
            
            // generate
            if(m_generations.size())
            {
                ConfTrack conf = m_generations.at(0);
                m_generations.erase(m_generations.begin());
                m_tracks.at(conf.track_id).generate(conf);
            }
        }
        map< string, vector<int> > pitches;
        int max_ticks;
        if(m_seq->lock())
        {
            pitches = m_seq->get_pitches();
            max_ticks = m_seq->get_max_ticks();
            m_seq->unlock();
        }
        vector< vector<Evt> > result = Seq::generate_events(&m_tracks, m_groove, pitches, max_ticks);
        m_seq->update(result);
        
        notify(m_seq->get_quav());
        unlock();
        ofSleepMillis(20);
    } 
}
Ejemplo n.º 29
0
void GButton::mouseClick(int x, int y) {
	ofSendMessage(message);	
}