Exemplo n.º 1
0
void RibbonModule::updateMousePoints(float deltaTime)
{
	for(int i = 0; i < pointsMouse.size(); i++){
        pointsMouse[i].z += 0.18 * deltaTime;
    }
		
	ofVec3f sumOfAllPoints(0,0,0);
	vector<ofVec3f>::iterator iter = pointsMouse.begin();
	vector<ofColor>::iterator colorIter = pointsMouseColors.begin();
	while (iter != pointsMouse.end())
	{
		if(iter->z > leftCamera.getFarClip() && iter->z > rightCamera.getFarClip())
		{
			iter = pointsMouse.erase(iter);
			colorIter = pointsMouseColors.erase(colorIter);
		}
		else
		{
			sumOfAllPoints += *iter;
			++iter;
			++colorIter;
		}
	}

    center = sumOfAllPoints / pointsMouse.size();
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void ofApp::update() {
    //don't move the points if we are using the camera
    if(!usecamera) {
        ofVec3f sumOfAllPoints(0,0,0);
        for(unsigned int i = 0; i < points.size(); i++) {
            points[i].z -= 4;
            sumOfAllPoints += points[i];
        }
        center = sumOfAllPoints / points.size();
    }
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::update(){
    
    //----ribbon
    //don't move the points if we are using the camera
    if(!usecamera){
        ofVec3f sumOfAllPoints(0,0,0);
        for(int i = 0; i < points.size(); i++){
            points[i].z -= 4;
            sumOfAllPoints += points[i];
        }
        center = sumOfAllPoints / points.size();
    }
    
    //----tracking
	ofBackground(100,100,100);

    bool bNewFrame = false;

	#ifdef _USE_LIVE_VIDEO
       vidGrabber.update();
	   bNewFrame = vidGrabber.isFrameNew();
    #else
        vidPlayer.update();
        bNewFrame = vidPlayer.isFrameNew();
	#endif

	if (bNewFrame){

		#ifdef _USE_LIVE_VIDEO
            colorImg.setFromPixels(vidGrabber.getPixels(), 320,240);
	    #else
            colorImg.setFromPixels(vidPlayer.getPixels(), 320,240);
        #endif

        grayImage = colorImg;
		if (bLearnBakground == true){
			grayBg = grayImage;		// the = sign copys the pixels from grayImage into grayBg (operator overloading)
			bLearnBakground = false;
		}

		// take the abs value of the difference between background and incoming and then threshold:
		grayDiff.absDiff(grayBg, grayImage);
		grayDiff.threshold(threshold);

		// find contours which are between the size of 20 pixels and 1/3 the w*h pixels.
		// also, find holes is set to true so we will get interior contours as well....
		contourFinder.findContours(grayDiff, 20, (340*240)/3, 10, true);	// find holes
	}

}
Exemplo n.º 4
0
//--------------------------------------------------------------
void ofApp::update(){
	//don't move the points if we are using the camera
    if(!usecamera){
        ofVec3f sumOfAllPoints(0,0,0);
        for(unsigned int i = 0; i < points.size(); i++){
            points[i].z -= 50;
            sumOfAllPoints += points[i];
        }
        while (points.size()>100) {
            points.erase(points.begin());
        }
        center = sumOfAllPoints / points.size();
        camera.setPosition(mouseX,mouseY,0);
        camera.lookAt(ofVec3f(mouseX,mouseY,0));

        
        light.setPosition(ofVec3f(mouseX,mouseY,0));
    }
}