Exemplo n.º 1
0
//--------------------------------------------------------------
void testApp::updateApp(){
	
	ofPoint * pos;
	Trail *trail;
	
	bool bInsideLetter;
	
	vector<ofPoint> growings;
	
	for(int i=0; i<trails.size(); i++){
		
		trail = &trails[i];
		pos = &trail->position;
		
		// If trail isn't in a letter yet
		if(trail->letterId == -1) {
			
			trail->update(screenBounds);
			
			if(!ofInsidePoly( trail->position, screenBounds.getVertices() )){
				trails.erase(trails.begin()+i);
				i--;
				continue;
			}
			
			// look if it has found a letter now
			for(int j=0; j<letters.size(); j++){
				if( ofInsidePoly( *pos, letters[j].getVertices() ) ) {
					trail->letterId = j;
				}
			}
		}
		else {
			
			trail->update(letters[trail->letterId]);
			
			if (trails[i].bActive) {
				growings.push_back(trails[i].position);
			}
		}
	}
	
	triangle.clear();
	if(growings.size()>=3)
		triangle.triangulate( growings, growings.size() );
}
Exemplo n.º 2
0
void Choreo3DApp::update()
{
    setFrameRate(frameRate);
    
    //DISABLE CAMERA INTERACTION IF MOUSE IS OVER UI REGION
    if (getMousePos().x > 3 * getWindowWidth()/4. && camActive)
    {
        camActive = false;
        mCamUi.disconnect();
        mCamUi.disable();
        cout << "disabling camera UI" << endl;
    } else {
        if (!camActive)
        {
            mCamUi.connect(getWindow());
            mCamUi.enable();
        }
        camActive = true;
        cout << "enabling camera UI" << endl;
    }
    
    mGlsl->uniform("uColor", markerColour );
    
    if (!paused)
    {
        
        
        //UPDATE POSITIONS
        //MAP INSTANCE DATA TO VBO
        //WRITE NEW POSITIONS
        //UNMAP
        
        glm::vec3 *newPositions = (glm::vec3*)mInstanceDataVbo->mapReplace();
        
        for( int i = 0; i < jointList.size(); ++i )
        {
            
            float instanceX = jointList[i].jointPositions[FRAME_COUNT].x;
            float instanceY = jointList[i].jointPositions[FRAME_COUNT].y;
            float instanceZ = jointList[i].jointPositions[FRAME_COUNT].z;
            
            vec3 newPos(vec3(instanceX,instanceY, instanceZ)); //CREATE A NEW VEC3 FOR UPDATING THE VBO
            
            framePositions[i] = newPos;
            
        }
        
        //REPLACE VEC3s IN VBO BY INCREMENTING THE POINTER
        for (int i = 0; i < framePositions.size(); i++){
            *newPositions++ = framePositions[i];
        }
        
        handTrail.update(framePositions[26], dancerColor);
        
        //    std::cout << framePositions[17] << std::endl;
        
        
        skeleton.update(framePositions);

        
        mInstanceDataVbo->unmap();
        // std::cout << "position: " << positions[0] << std::endl;
        
        if (ribbonsActive)updateRibbons();
        
        //MANUALLY INCREMENT THE FRAME, IF THE FRAME_COUNT EXCEEDS TOTAL FRAMES, RESET THE COUNTER
        if (FRAME_COUNT < TOTAL_FRAMES)
        {
            FRAME_COUNT += 1;
        } else {
            FRAME_COUNT = 0;
        }
        
        //std::cout << getAverageFps() << std:: endl;
        // std::cout << "frame rate: " << getAverageFps() << ", frame count: " << FRAME_COUNT << std::endl;
        
        //define changed color
      //  Color temp = Color(dancerColor[0],dancerColor[1],dancerColor[2]);
        
        
        mCurrentFrame++; //MANUALLY ADVANCE THE CURRENT FRAME - WITH RESPECT TO THE DANCERS
    
    }
    
    updateGui();
}