Exemplo n.º 1
0
//--------------------------------------------------------------
void emptyApp::setup(){
  
  // Disable the of setupScreen because now each scene has a custom renderer.
  ofDisableSetupScreen();
  
  scene = new ofxScene(ofGetWidth(), ofGetHeight());
	scene->setBackgroundColor(10, 10, 10);
  // Enable onTop drawing for the sake of the grid lines, which are set up to always render on top.
  scene->enableOnTopDrawing(true);

  
  root = new ofxObject();
  root->setTrans(-ofGetWidth()/2, -ofGetHeight()/2, 0);
  scene->getRoot()->addChild(root);
  
  
  // Add the grid to the scene to be able to see the grid lines.
  // It is not necessary to be able to use the grid.
  scene->getRoot()->addChild(&grid);
  // The grid references a lower left origin.
  // Align the root of your objects with the origin of the grid.
  grid.setTrans(root->getTrans());
  
  // Show the grid lines.
  // You can show the lines and base lines independently.
  grid.showLines(true);
  grid.showBaselines(true);
  // Press 'g' to hide lines.
  // Press 'G' to show them

  buildLayout(&grid, root);
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void emptyApp::setup(){
  
  // Disable the of setupScreen because now each scene has a custom renderer.
  ofDisableSetupScreen();
  
  //Create a scene.
	//The scene is a scene graph that renders objects added to its root and their children and their children's children and so on.
	//When the render mode of the scene is set to RENDER_ALPHA_DEPTH_SORTED, it handles sorting of both transparent and opaque objects in the z-axis.
  scene = new ofxScene(ofGetWidth(), ofGetHeight());
	scene->setBackgroundColor(10, 10, 10);
  
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void App::setup(){
  
  // Disable the of setupScreen because now each scene has a custom renderer.
  ofDisableSetupScreen();
  
  //Create a scene.
	//The scene is a scene graph that renders objects added to its root and their children and their children's children and so on.
	//When the render mode of the scene is set to RENDER_ALPHA_DEPTH_SORTED, it handles sorting of both transparent and opaque objects in the z-axis.
  scene = new ofxScene(ofGetWidth(), ofGetHeight());
	scene->setBackgroundColor(defaultR, defaultG, defaultB);
  
  //Create Circle Object
  circle = new ofxCircleObject(defaultRes, 50);
  circle->setTrans(xPosition, yPosition, 0);
  circle->setScale(sliderScale/100);
  scene->getRoot()->addChild(circle);
  
  //Smile
  eye1 = new ofxCircleObject(30, 6);
  eye2 = new ofxCircleObject(30, 6);
  arcSmile = new ofxArcObject(28,26, 200, 340);
  eye1->setColor(255, 255, 255, 0);
  eye1->setTrans(-15, 15, 1);
  eye2->setColor(255, 255, 255, 0);
  eye2->setTrans(15, 15, 1);
  arcSmile->setColor(255, 255, 255, 0);
  arcSmile->setTrans(0, 0, 1);
  circle->addChild(eye1);
  circle->addChild(eye2);
  circle->addChild(arcSmile);
  
  
  // Build UIObject
  UIObject = new exampleUIObject();
  UIObject->setup();
  scene->getRoot()->addChild(UIObject);
  UIObject->setVisible(true);
  
  int cornerOffset = 20;
  
  int UI_x = -ofGetWindowWidth()/2 + cornerOffset;
  int UI_y = ofGetWindowHeight()/2 - cornerOffset;
  UIObject->setTrans(UI_x, UI_y, 0);
  
  // Add Event Listeners
  ofAddListener(UIObject->UI->newGUIEvent, this, &App::UIEvent);
  
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void kinectApp::update(){
    
    //-- disable the user to resize the window --//
    ofDisableSetupScreen();
    int w = ofGetWidth();
    int h = ofGetHeight();
    if (w != 905 || h != 730) ofSetWindowShape(905, 730);
    
    //-- update status --//
    if(camOptions->mMouseIsDown || trackOptions->mMouseIsDown || sendigViaOSC->mMouseIsDown || oscConfig->mMouseIsDown)
    { statusConfig = "new"; }
    
    
    //-- update tracking nodes --//
    if (isLive) {
        openNIDevices.update();
        
        
        //-- calculate FrameRate of camera --//
        frames++;
        float time = ofGetElapsedTimeMillis();
        if (time > (lastFPSlog + 1000)) {
            fps = frames;
            frames = 0;
            lastFPSlog = time;
        }
        
        
        //-- update hand tracking --//
        if (hands){
            openNIDevices.g_bIsHandsOn = true;	
            if(openNIDevices.currentTrackedHands.size() >= nrHand){
                openNIDevices.currentTrackedHands.clear();
                openNIDevices.currentTrackedHandIDs.clear();
            }
        }
        else if (!hands){ openNIDevices.g_bIsHandsOn = false; }
        
        
        //-- update skeleton tracking --//
        if (skel){
            openNIDevices.g_bIsUserOn = true;	
            for (int i = 0; i < openNIDevices.getNumTrackedUsers(); i++){	
                userImg[i].getTextureReference() = openNIDevices.getTrackedUser(i).getMaskTextureReference();
            }	
        }
        else if (!skel){	
            for (int i = 0; i < openNIDevices.getNumTrackedUsers(); i++){
                if(openNIDevices.g_bIsUserOn == true) {
                    openNIDevices.stopPoseDetection(openNIDevices.getTrackedUser(i).getXnID());
                    openNIDevices.stopTrackingUser(openNIDevices.getTrackedUser(i).getXnID());
                }
            }
            openNIDevices.g_bIsUserOn = false;
        }
        
        
        //-- update object tracking --//
        if (objects){
            if(objectTrackingOptions->mMouseIsDown || backgProcessingOptions->mMouseIsDown || imageProcessingOptions->mMouseIsDown){ statusConfig = "new"; }
            unsigned char * sourcePixels = getDepthPixels(nearThreshold, farThreshold);
            kinectImage.setFromPixels(sourcePixels, width, height);
            
            processedImg = kinectImage;	
            filters->apply(processedImg);
            
            contourFinder.findContours(processedImg, minBlobSize, maxBlobSize, nrObjects, false);
            
            objectGenerator();	
        }
        
        
        //-- communicate via OSC --//
        communicateViaOsc();
    }
}