Beispiel #1
0
//----------------------------------------------------------------------
void game::draw(){  
	////////////////////////////////Draw game steps////////////////////////////////////
	if(step == -1){
		//waiting for initializing touch
	}
	if(step == 0){
		//is waiting for a shape to be selected
		//object menuu is showing
		//it can load an object from menu
		//or from puzzle menu in the middle
	}
	if (step == 1){
		//show selected object
		objectDisplayed->draw();
		//myCutter->draw();
	}
	if(step == 2){
		//waiting for armature to be selected
		//show selected object
		objectDisplayed->draw();
	}
	if(step == 3){
		//armature has been selected
		curRotA.getRotate(angleA, axistbA);
		ofPushMatrix();
		ofTranslate(posP.x,posP.y,posP.z);

		//euler
		ofRotateX(rotateSlicer.x);
		ofRotateY(rotateSlicer.y);
		ofRotateZ(rotateSlicer.z);

		//new trackball
		ofRotate(angleA, axistbA.x, axistbA.y, axistbA.z);

		glGetDoublev(GL_MODELVIEW_MATRIX, model);// here I have the current matrix with the rotations that I need, after rotation has been applied 
		//model has the current model view matrix
		//with it we create an ofMatrix4x4
		ofMatrix4x4 armRotTB = ofMatrix4x4(model[0],model[1],model[2],model[3],model[4],model[5],model[6],model[7],model[8],model[9],model[10],model[11],model[12],model[12],model[14],model[15]);
		//invert matrix
		ofMatrix4x4 inverseArmRotation = ofMatrix4x4::getInverseOf(armRotTB);
		//use inverse matrix to apply rotations
		invRotA = inverseArmRotation.getRotate();
		//now I have a new quaternion with the inverse rotations.. to rotate puzzle back
		invRotA.getRotate(angleAinv, axistbAinv);
		//now I have an angle and a vector to rotate


		ofTranslate(-posP.x,-posP.y,-posP.z);
		myArmature->draw();
		ofPopMatrix();
		//show selected object
		objectDisplayed->draw();
	}
	if(step == 4 ){
		//made the cuts
		//show color palette
		//show puzzle

		curRot.getRotate(angle, axistb);

		ofPushMatrix();
		ofTranslate(posP.x,posP.y,posP.z);
		//new trackball
		ofRotate(angle, axistb.x, axistb.y, axistb.z);
		ofTranslate(-posP.x,-posP.y,-posP.z);
		myPuzzle->draw();
		ofPopMatrix();
	}
	if(step == 5){
		//show puzzle
		curRot.getRotate(angle, axistb);

		ofPushMatrix();
		ofTranslate(posP.x,posP.y,posP.z);
		//new trackball
		ofRotate(angle, axistb.x, axistb.y, axistb.z);


		ofTranslate(-posP.x,-posP.y,-posP.z);
		myPuzzle->draw();

		ofPopMatrix();
	}
	if(step == 6){
		//show drawing area
		myCanvas->draw();
		myCanvasImage.draw(posCanvas.x-500/2,posCanvas.y-500/2,posCanvas.z,500,500);
	}
	if(step == 7){
		//show puzzle
		curRot.getRotate(angle, axistb);

		ofPushMatrix();
		ofTranslate(posP.x,posP.y,posP.z);
		//new trackball
		ofRotate(angle, axistb.x, axistb.y, axistb.z);


		ofTranslate(-posP.x,-posP.y,-posP.z);
		myPuzzle->draw();
		ofPopMatrix();
	}
}
Beispiel #2
0
//--------------------------------------------------------------
void testApp::draw(){
	ofEnableAlphaBlending();
	ofEnableLighting();
	sun.enable();

	vector<ofVec3f>::iterator it = stars.begin(), end = stars.end();

	ofSetColor(255);
	for(; it != end; ++it) {
		it->set(it->x + ofRandom(-0.01,0.01), it->y + ofRandom(-0.01,0.01), 0);
		ofCircle(it->x,it->y, 0.8);
	}


	ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);

	//rotate sphere over time
	ofRotateY(ofGetFrameNum()*-0.3); // super idee das mached mir so :D

	glEnable(GL_DEPTH_TEST); //enable depth comparisons and update the depth buffer


	ofSetColor(28, 220, 255);
	ofSphere(70);

	//bind and draw texture
	glMatrixMode(GL_TEXTURE);
	glPushMatrix();
	ofScale(fbo.getWidth(), fbo.getHeight());
	glMatrixMode(GL_MODELVIEW);

		ofSetColor(255); // IMPORTANT!!!
		fbo.getTextureReference().bind();
		ofRotateY(-20);
		ofSphere(71);
		fbo.getTextureReference().unbind();

		fbo1.getTextureReference().bind();
		ofRotateY(180);
		ofSphere(72);
		fbo1.getTextureReference().unbind();

		fbo2.getTextureReference().bind();
		ofRotateY(25);
		ofSphere(75);
		fbo2.getTextureReference().unbind();

		fbo3.getTextureReference().bind();
		ofRotateY(-10.2);
		ofSphere(77);
		fbo3.getTextureReference().unbind();

		fbo4.getTextureReference().bind();
		ofRotateY(-45);
		ofSphere(80);
		fbo4.getTextureReference().unbind();

	glMatrixMode(GL_TEXTURE);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glDisable(GL_DEPTH_TEST);


	ofDisableAlphaBlending();
	ofDisableLighting();

	ofImage screen;
	screen.grabScreen(0,0,ofGetWindowWidth(), ofGetWindowHeight());
	string frame = ofToString(ofGetFrameNum());
	if(frame.length() < 6) {
		int add = 6 - frame.length();
		for(int i = 0; i < add; i++) {
			frame = ofToString(0) + frame;
		}
	}
	screen.saveImage("pod2_" + frame + ".png");
	cout << "saved " << "pod2_" << frame << ".png" << endl;
}
Beispiel #3
0
bool Orb:: draw() { 
	// orbSize =0.3f; 
	
	ofPushMatrix(); 
	ofTranslate(pos); 
	//orbSize = 0.5; 

	//cout << orbSize << "\n";
	
	ofScale(orbSize,orbSize,orbSize); 
	
	
	
	ofEnableSmoothing(); 
	//ofSetColor(255,50); 
	//ofFill();
	//ofCircle(0,0,22); 
	
	ofSetColor(200);
	ofSetLineWidth(1);
	
	ofPushMatrix(); 
	ofRotateY(30);
	ofRotateX(rot1); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	ofPushMatrix(); 
	ofRotateZ(120);
	ofRotateX(rot2); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	ofPushMatrix(); 
	ofRotateZ(240);
	ofRotateX(rot3); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	
	ofPopMatrix(); 
	
	
	ofDisableSmoothing(); 
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	
	Effect::draw(); 

	
	ofPushMatrix(); 
	ofTranslate(pos); 
	ofScale(orbSize,orbSize,orbSize); 
	
	
	//ofSetColor(255,50); 
	//ofFill();
	//ofCircle(0,0,22); 
	
	ofSetColor(20);
	ofSetLineWidth(5);
	
	ofPushMatrix(); 
	ofRotateY(30);
	ofRotateX(rot1); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	ofPushMatrix(); 
	ofRotateZ(120);
	ofRotateX(rot2); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	ofPushMatrix(); 
	ofRotateZ(240);
	ofRotateX(rot3); 
	ofNoFill(); 
	ofCircle(0, 0, 10, 20);
	ofPopMatrix(); 
	
	
	ofPopMatrix(); 

}
Beispiel #4
0
void testApp::draw(){	
	ofSetColor(255, 255, 255);
	
	// draw the debug screens
	ofPushMatrix();
	ofScale(0.5, 0.5);
							
	if (isLive) {
		recordDepth.draw(0, 0, 640, 480);
		recordImage.draw(640, 0, 640, 480);
		if (panel.getValueB("isTracking")) {
			recordUser.draw();
			
			if(panel.getValueB("isMasking")) {
				glEnable(GL_BLEND);
				glBlendFunc(GL_DST_COLOR, GL_ZERO);
				recordUser.drawUserMasks(640, 0);
				glDisable(GL_BLEND);
			}
		}
	}
	else {
		playDepth.draw(0, 0, 640, 480);
		playImage.draw(640, 0, 640, 480);
		if (panel.getValueB("isTracking")) {
			
			playUser.draw();
			
			if(panel.getValueB("isMasking")) {
				glEnable(GL_BLEND);
				glBlendFunc(GL_DST_COLOR, GL_ZERO);
				playUser.drawUserMasks(640, 0);
				glDisable(GL_BLEND);
			}
		}
	}
	
	// draw rectangles to ground the debug screens
	ofNoFill();
	ofRect(0, 0, 640, 480);
	ofRect(640, 0, 640, 480);							
	ofFill();	
	
	ofPopMatrix();
	
	// draw the point cloud
	//glMatrixMode(GL_MODELVIEW);	
	
	
//	glPushMatrix();
//	glTranslatef(320, 240, 0);
//	glRotatef(panel.getValueF("cloud_rotation"), 0, 1, 0);
//	glTranslatef(-320, -240, 0);	
	
	ofPushMatrix();
	ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, -300);	
	ofRotateY(panel.getValueF("cloud_rotation"));
	ofTranslate(-320, -240, 0);

//	if (panel->getValueB("autoRotate")){
//		ofRotateY(ofGetElapsedTimef()*5);
//	}

	
	
	//glCallList(SCENE); /* draw the scene */
	
	if (isLive) {
		//recordUser.drawPointCloud(!panel.getValueB("cloudMasking"), panel.getValueI("cloud_point_size"));		
		recordUser.drawOrthogonalPointCloud(panel.getValueF("ppm"), false, panel.getValueB("show_scene_box"), panel.getValueI("cloud_point_size"));
		recordUser.drawOrthogonal(panel.getValueF("ppm"));
	}
	else {
		//playUser.drawPointCloud(!panel.getValueB("cloudMasking"), panel.getValueI("cloud_point_size"));
	}


	ofPopMatrix();		
	
	
	ofSetColor(255, 255, 0);
	
	string msg1, msg2, msg3;	//drawBitmapString is limited to some numebr of characters -> is this a bug in 007 or always the case?
	
	msg1 += "Press 's' to start/stop recording\n";
	msg1 += "Press 'p' to toggle playback/live streams\n";
	msg3 += (string)(isLive ? "LIVE STREAM\n" : "PLAY STREAM\n");
	msg3 += (string)(!isRecording ? "READY\n" : "RECORDING\n");

	
	ofDrawBitmapString(msg1, 20, 500);
	ofDrawBitmapString(msg3, 20, 600);
	ofDrawBitmapString(currentFileName, 20, 700);
	
	
}
Beispiel #5
0
void Voro3D::draw(int _surfaceId) {
    
    
    
    ofBackground(0);
    
    light.enable();
    dirLight.enable();
    
    if(_surfaceId == 1) {
    
        /*for (int i = 0; i < cellCentroids.size(); i++){
            ofSetColor(255,0,0);
            //ofDrawSphere(cellCentroids[i], cellRadius[i]*0.15);
         }*/
        
        
        ofPushMatrix(); {
        ofTranslate(0.15, 0);
        
        ofRotateX(ofGetElapsedTimef()*6);
        ofRotateY(ofGetElapsedTimef()*7);
        ofRotateZ(ofGetElapsedTimef()*8);
        
        for(int i = 0; i < wallCube->cellMeshes.size(); i++){
            ofPushMatrix(); {
            
            ofScale(1.65,1.65,1.65);
            ofSetColor(255,255,255,255);
            
            float explode = ofMap(ofSignedNoise(ofGetElapsedTimef()), 0, 1, 0.8, 1);
            
            ofTranslate(wallCube->cellMeshes[i].getCentroid().x, wallCube->cellMeshes[i].getCentroid().y, wallCube->cellMeshes[i].getCentroid().z);
            ofScale(explode,explode,explode);
            ofTranslate(-wallCube->cellMeshes[i].getCentroid().x, -wallCube->cellMeshes[i].getCentroid().y, -wallCube->cellMeshes[i].getCentroid().z);
            
            wallCube->cellMeshes[i].drawFaces();
            } ofPopMatrix();

        }
        } ofPopMatrix();
        
        
        ofPushMatrix(); {
        ofTranslate(-0.5,-0.1,0.08);
        
        ofTranslate(0,1,0);
        ofRotateX(-90);
        
        for(int i=0; i<12; i++) {
            ofPushMatrix(); {
            
            ofTranslate(0, ofMap(i,0,12,0,-3),0);
                ofSetColor(ofMap(i,0,12,180,10));
            ofDrawBox(0.6,0.02,0.02);
            
            } ofPopMatrix();
        }
        
        } ofPopMatrix();
        
        ofPushMatrix(); {
            
            ofTranslate(0.1, 0.5, -0.2);
            
            ofRotateY(ofMap(ofSignedNoise(ofGetElapsedTimef()/10), 0, 1, 4, -4));
            ofSetColor(255);
            logo.draw(0,0, 0.43, 0.2);
            
        } ofPopMatrix();
        
    }
    
    if(_surfaceId == 0) {
    
        
        ofSetColor(255);
        // Draw Logo

        
        // Draw "In Stereo"
        ofSetColor(255,255,255, 230);
        ofPushMatrix(); {
            ofTranslate(-0.9, -0.9, 0.65);
            ofRotateZ(180);
            ofRotateY(180);
            ofPushMatrix();{
                
                ofScale(0.005,0.005,0.005);
                
                ofPushMatrix(); {
                    
                    ofRotateX(70);
                    ofRotateY(33);
                    ofPushMatrix();
                    ofTranslate(0, 0, -0.1);
                    ofSetColor(255, 255, 255,200);
                    //ofRect(-10,-80,140,125);
                    ofPopMatrix();
                    ofSetColor(255);
                    //font.drawString(" Cool", 0,0);
                    //font.drawString(" Glasses! ", 0,-24);
                    font.drawString("\\o-o/", 0,-28);
                    //font.drawString(" \\o-o/ ", 0,-60);
                }ofPopMatrix();
                
                /*ofPushMatrix();{
                 //ofRotateY(8);
                 ofScale(3, 3);
                 font.drawString("\\o-o/", 12,0);
                 }ofPopMatrix();*/
                
            }ofPopMatrix();
            
        } ofPopMatrix();
        
        
        ofPushMatrix(); {
            
            ofTranslate(0.26, 0.3, -0.25);
            
            ofRotateX(ofGetElapsedTimef()*6);
            ofRotateY(ofGetElapsedTimef()*7);
            ofRotateZ(ofGetElapsedTimef()*8);
            
            for(int c=0;c<3;c++) {
                
                ofPushMatrix(); {
                if(c==1) {
                    
                    ofTranslate(0.2, 0.2, 0.2);
                    ofRotateX(ofGetElapsedTimef()*8);
                    ofRotateY(ofGetElapsedTimef()*9);
                    ofRotateZ(ofGetElapsedTimef()*7);
                }
                if(c==2) {
                    
                    ofTranslate(-0.2, -0.2, 0.2);
                    ofRotateX(ofGetElapsedTimef()*6);
                    ofRotateY(ofGetElapsedTimef()*5);
                    ofRotateZ(ofGetElapsedTimef()*3);
                }
                
            ofScale(0.6,0.6,0.6);
            ofSetColor(255,255,255,200);
            for(int i = 0; i < floorCube->cellMeshes.size(); i++){
                ofPushMatrix(); {
                    
                    
                    
                    floorCube->cellMeshes[i].drawFaces();
                } ofPopMatrix();
            }
            }ofPopMatrix();
            }
        } ofPopMatrix();
        
        ofPushMatrix(); {
            ofTranslate(0.8, 0.8, 0.08);
            
            //ofRotateX(-90);
            
            for(int i=0; i<12; i++) {
                ofPushMatrix(); {
                    
                    ofTranslate(0, 0, ofMap(i,0,12,0,3));
                    ofSetColor(ofMap(i,0,12,180,10));
                    ofDrawBox(0.02,0.4,0.02);
                    
                } ofPopMatrix();
            }
            
        } ofPopMatrix();
        

    
    }
    
    dirLight.disable();
    light.disable();
        
        
    
    
}
	void rotateY(float degrees) {
#ifdef APOLLO_OPENFRAMEWORKS
		ofRotateY(degrees);
#endif
	}
//--------------------------------------------------------------
void ofApp::draw(){
    //ofDisableDepthTest();
    ofEnableDepthTest();
    nearPosMesh.enableColors();
    
    positonVbo.bind();
    positonVbo.updateVertexData(particle_pos, PARTICLE_NUM);
    positonVbo.unbind();
    
    
    //ofColor centerColor = ofColor(85, 78, 68);
    ofColor edgeColor(0, 0, 0);
    ofBackgroundGradient(bgColor, edgeColor, OF_GRADIENT_CIRCULAR);
    
    
    ofPushStyle();
    easyCam.begin();
    
    if(drawMesh){
        ofPushMatrix();
        ofTranslate(-ofGetWidth()/2+cameraX, -ofGetHeight()/2+cameraY,cameraZ);
        mesh.draw();
         ofPopMatrix();
    }
   
    
    ofTranslate(cameraX, cameraY,cameraZ);
    nearPosMesh.addColor(ofFloatColor(1.0, 0.0, 0.0, 0.5));
    if(drawSphere){
        nearPosMesh.draw();
        //ofSetColor(255);
        
    }
    if (drawParticle) {
        positonVbo.draw(GL_POINTS, vol_num, PARTICLE_NUM);
    }
    ofPushMatrix();
    //ofTranslate(-ofGetWidth()/2+cameraX, -ofGetHeight()/2+cameraY,cameraZ);
    if(drawTotems){
        for (int i = 0; i < totems.size(); i++) {
            totems[i]->draw();
        }
    }
    
    ofPopMatrix();
    
    ofPushMatrix();
    //ofTranslate(-ofGetWidth()/2+cameraX, -ofGetHeight()/2+cameraY,cameraZ);
    if(drawAttackInteraction) {
        for (int i = 0; i < cubes.size(); i++) {
            
            cubes[i]->draw();
        }
    }
    ofPopMatrix();
    
    
    
/***************** SoundLine *****************/
    if(drawSoundLine) {
    ofPushStyle();
    ofSetLineWidth(1);
    ofBeginShape();
    ofPushMatrix();
    //ofRotateX(rotate_time_x++);
    ofRotateY(rotate_time_y+=r_line_y);
    ofRotateZ(rotate_time_z+=r_line_z);
    for (unsigned int i = 0; i < left.size(); i++) {
        ofSetColor(167,107,223);
        ofNoFill();
        ofVertex(-400+i*7, left[i]*180.0f);
    }
    ofPopStyle();
    ofEndShape(false);
    ofPopMatrix();
    
    ofSetLineWidth(1);
    ofBeginShape();
    ofPushMatrix();
    //ofRotateX(rotate_time_x2++);
    ofRotateY(rotate_time_y2+=r_line_y2);
    ofRotateZ(rotate_time_z2+=r_line_z2);
    for (unsigned int i = 0; i < left2.size(); i++) {
        ofSetColor(167,107,223);
        ofVertex(-200+i*7, left2[i]*180.0f);
    }
    ofPopStyle();
    ofEndShape(false);
    ofPopMatrix();
    
    
    
    ofPushStyle();
    ofPushMatrix();
    ofSetColor(245, 58, 135);
    ofSetLineWidth(1);
    
    //ofRotateX(rotate_time_x3++);
    ofRotateY(rotate_time_y3+=r_line_y3);
    ofRotateZ(rotate_time_z3+=r_line_z3);
     
    ofBeginShape();
    for (unsigned int i = 0; i < right.size(); i++){
        ofVertex(-200+i*7, -right[i]*180.0f);
    }
    ofEndShape(false);
    ofPopMatrix();
    ofPopStyle();
    
    ofPushStyle();
    ofPushMatrix();
    ofSetColor(245, 58, 135);
    ofSetLineWidth(1);
    
    //ofRotateX(rotate_time_x4++);
    ofRotateY(rotate_time_y4+=r_line_y4);
    ofRotateZ(rotate_time_z4+=r_line_z4);
    
    ofBeginShape();
    for (unsigned int i = 0; i < right2.size(); i++){
        ofVertex(-400+i*7, -right2[i]*180.0f);
    }
    ofEndShape(false);
    ofPopMatrix();
    ofPopStyle();
    }
    

    
    easyCam.end();
    ofPopStyle();
    ofDisableDepthTest();
    
    if( bHide ){
        gui.draw();
        line_gui.draw();
        bg_gui.draw();
        
    }
    
    
    
    
}
Beispiel #8
0
void Cinema::draw(){
        
                ofTranslate(0,HEIGHT);
               ofScale(1,-1);
        
        videoMutex.lock();
        
        ofSetColor(ofColor::black);
        ofDrawRectangle(0,0,WIDTH,HEIGHT2);
        ofSetColor(ofColor::white);
        
        ofTranslate(WIDTH/2, HEIGHT2/2 + (HEIGHT2 - HEIGHT)/2);
        if(!sleep){ //not background
            ofScale(1+app->parameterMap[mediaZ], 1+app->parameterMap[mediaZ]);
            ofTranslate(app->parameterMap[mediaX]*WIDTH, -app->parameterMap[mediaY]*HEIGHT);
            ofRotateX(app->parameterMap[mediaRotX]);
            ofRotateY(app->parameterMap[mediaRotY]);
            ofRotateZ(app->parameterMap[mediaRotZ]);
        }
        
        
        ofTranslate(-WIDTH/2, -HEIGHT2/2);
        
        ofScale(app->parameterMap[mediaScaleX], app->parameterMap[mediaScaleY]);
    
    
        bool first = true;
        int pred = 0;
        ofEnableBlendMode(OF_BLENDMODE_ALPHA);
        fbo.begin();
        
        ofSetColor(ofColor::black); //180308
        ofDrawRectangle(0,0,WIDTH,HEIGHT);
        ofSetColor(ofColor::white);
        
        for(int i=0;i<playerIntensities.size();i++){
            
            if(playerIntensities[i]>0){
                if(app->parameterMap[blendType]==SCREEN && !first){
                    alphaScreenShader.begin();
                    players[pred]->update();
                    alphaScreenShader.setUniformTexture("tex1", players[pred]->getTextureReference(), 1);
                    alphaScreenShader.setUniform1f("thresh", 1 - playerIntensities[i]);
                    alphaScreenShader.setUniform1f("WIDTH", WIDTH);
                    alphaScreenShader.setUniform1f("xRatio", players[i]->getWidth()/(float)players[pred]->getWidth());
                    alphaScreenShader.setUniform1f("yRatio", players[i]->getHeight()/(float)players[pred]->getHeight());
                }
                
                if(app->parameterMap[blendType]==ALPHABLACK && playerIntensities[i]<1){
                    alphaShader.begin();
                    alphaShader.setUniform1f("thresh", 1 - playerIntensities[i]);
                }
                
                if(!first && app->parameterMap[blendType]==TRUED){
                    //                    alphaWhiteShader.load("shaders/alphawhite");
                    alphaWhiteShader.begin();
                    players[pred]->update();
                    alphaWhiteShader.setUniformTexture("tex1", players[pred]->getTextureReference(), 1);
                    //alphaWhiteShader.setUniformTexture("tex1", fbo.getTextureReference(), 1);
                    alphaWhiteShader.setUniform1f("thresh", playerIntensities[i]);
                    alphaWhiteShader.setUniform1f("thresh_pred", playerIntensities[pred]);
                    alphaWhiteShader.setUniform1f("WIDTH", WIDTH);
                    alphaWhiteShader.setUniform1f("xRatio", players[i]->getWidth()/(float)players[pred]->getWidth());
                    alphaWhiteShader.setUniform1f("yRatio", players[i]->getHeight()/(float)players[pred]->getHeight());
                }
                
                
                if(first && app->parameterMap[blendType]!=ALPHABLACK){
                    ofSetColor(playerIntensities[i]*255);
                }
                if(app->parameterMap[resize]){
                    players[i]->draw(app->parameterMap[hMirror]?WIDTH:0,app->parameterMap[vMirror]?HEIGHT:0, app->parameterMap[hMirror]?-WIDTH:WIDTH, app->parameterMap[vMirror]?-HEIGHT:HEIGHT);
                }else{
                    ofPushMatrix();
                    ofTranslate(WIDTH/2, HEIGHT/2);
                    int w = players[i]->getWidth();
                    int h = players[i]->getHeight();
                    players[i]->draw(app->parameterMap[hMirror] ? w/2 : -w/2,
                                     app->parameterMap[vMirror] ? h/2 : -h/2,
                                     app->parameterMap[hMirror] ? -w : w,
                                     app->parameterMap[vMirror] ? -h : h);
                    ofPopMatrix();
                }
                
                if(first && app->parameterMap[blendType]!=ALPHABLACK){
                    ofSetColor(ofColor::white);
                }
                
                if(app->parameterMap[blendType]==ALPHABLACK && playerIntensities[i]<1)
                    alphaShader.end();
                if(!first && app->parameterMap[blendType]==TRUED)
                    alphaWhiteShader.end();
                if(app->parameterMap[blendType]==SCREEN && !first)
                    alphaScreenShader.end();
                
                
                first = false;
                pred = i;
            }
        }
        fbo.end();
    
//    if(app->parameterMap[user5]==1){
//        stillFbo->begin();
//        fbo.draw(0,0);
//        stillFbo->end();
//    }
    
        if(app->parameterMap[circle]>0){
            copyFbo.begin();
            fbo.draw(0,0);
            copyFbo.end();
            pastFbos.push_back(copyFbo);
            if(pastFbos.size()>nbPastFbos)
                pastFbos.erase(pastFbos.begin());
        }
        
        
        /** POST TRAITEMENT **/
        ofPushMatrix();
        ofTranslate(WIDTH/2, HEIGHT/2);
        float max = 50;
        
        if(app->parameterMap[circle]){
            vector<float> pos;
            int zMax = 15;
            for(float s=max;s>=1;s--){
                float sc = fmod(-(s-2) + ofGetFrameNum()*app->parameterMap[circleSpeed], zMax);
                pos.push_back(sc);
            }
            std::sort(pos.begin(), pos.end());
            for(int i=0;i<max;i++){
                ofPushMatrix();
                ofTranslate(0,0,(pos[i]*250 - 3250)*app->parameterMap[circleDist]);
                ofRotate(-app->parameterMap[circleRotation]*(ofGetFrameNum()+pos[i]/(float)zMax*360));
                
                circleShader.begin();
                circleShader.setUniform1f("WIDTH", WIDTH);
                circleShader.setUniform1f("HEIGHT", HEIGHT);
                float alphaRatio = 20;
                circleShader.setUniform1f("alpha", ofMap(pos[i], 0, zMax/alphaRatio, 0, 1, true)*ofMap(pos[i], zMax, zMax-zMax/alphaRatio, 0, 1, true));
                if(pastFbos.size()>i)
                    pastFbos[pastFbos.size()-i-1].draw(-WIDTH/2,-HEIGHT/2);
                else
                    fbo.draw(-WIDTH/2,-HEIGHT/2);
                circleShader.end();
                //                circleMask.draw(-WIDTH/2,-HEIGHT/2, WIDTH, HEIGHT);
                ofPopMatrix();
            }
        }else{
            float  s = (ofGetFrameNum() % 500) / 500.0;
            float ss = s*10;
            ofPushMatrix();
            
            ofBackground(0);

            
            if(app->parameterMap[user5]>0){
                ofEnableBlendMode(OF_BLENDMODE_SCREEN);
                ofSetColor(255*app->parameterMap[user5]);
                stillFbo->draw(-WIDTH/2,-HEIGHT/2);
                app->deltaMap[user5] -= 1 / 25.0;
                
                ofSetColor(255 * std::min(1.0, (1.5-app->parameterMap[user5])));
                fbo.draw(-WIDTH/2,-HEIGHT/2);
                ofEnableBlendMode(OF_BLENDMODE_ALPHA);

            }else{
                fbo.draw(-WIDTH/2,-HEIGHT/2);
            }
            
            ofPopMatrix();
        }
        
        first = false;
        ofPopMatrix();
        ofEnableBlendMode(OF_BLENDMODE_ALPHA);
        
        /** POOP **/
        if(app->parameterMap[supZoom]!=1 || app->parameterMap[supRot]!=0){
            ofTranslate(WIDTH/2, HEIGHT2/2);
            int i = 1;
            ofPushMatrix();
            ofScale(app->parameterMap[supZoom]/i, app->parameterMap[supZoom]/i);
            ofRotateZ(app->parameterMap[supRot]/i);
            //            vidPlayer->draw(-WIDTH/2,-HEIGHT/2, WIDTH, HEIGHT);
            ofPopMatrix();
        }
        
        videoMutex.unlock();
    }
Beispiel #9
0
//--------------------------------------------------------------
void testApp::draw() {
	
	ofBackground(0, 0, 0);
	
	// draw debug or non debug
	
	if (panel.getValueB("drawDebug")){
		input.drawDebug();
		
	} else {
		ofPushMatrix();
		
			// center everything
			ofTranslate(ofGetWidth()/2, ofGetWidth()/2, -500);
			ofSetColor(255, 255, 255);
			ofRotateY(180 + panel.getValueF("rotateY"));
			if (panel.getValueB("autoRotate")){
				ofRotateY(ofGetElapsedTimef()*5);
			}
			
			float scale = panel.getValueF("scale");
			ofScale(scale, scale, scale);


			int w = input.camWidth;
			int h = input.camHeight;
			
			int vertexStep = panel.getValueI("vertexStep");
			
			int xMax = w - vertexStep;
			int yMax = h - vertexStep;
			
			glEnable(GL_LIGHTING);
			glEnable(GL_DEPTH_TEST);
			glEnable(GL_LIGHT0);
			glEnable(GL_NORMALIZE);
			
			glBegin(GL_QUADS);
			ofxVec3f zero(0, 0, 0);
			for(int y = 0; y < yMax; y += vertexStep) {
				for(int x = 0; x < xMax; x += vertexStep) {
				
					ofxVec3f& nw = input.pointGrid[y][x];
					ofxVec3f& ne = input.pointGrid[y][x + vertexStep];
					ofxVec3f& se = input.pointGrid[y + vertexStep][x + vertexStep];
					ofxVec3f& sw = input.pointGrid[y + vertexStep][x];
					
					if(nw != zero && ne != zero && sw != zero && se != zero) {
					
						ofxVec3f right = ne - nw;
						ofxVec3f down = sw - nw;
						ofxVec3f out = down.cross(right);
												
						glNormal3f(out.x, out.y, out.z);						
						glVertex3f(nw.x, nw.y, nw.z);
						glVertex3f(ne.x, ne.y, ne.z);
						glVertex3f(se.x, se.y, se.z);
						glVertex3f(sw.x, sw.y, sw.z);
						
					}
				}
			}
			glEnd();
			
			glDisable(GL_LIGHTING);
			glDisable(GL_DEPTH_TEST);
			
		ofPopMatrix();
		
	}
	
}
Beispiel #10
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    //we don't want to capture every frame
    //so we only capture one frame when capture
    //is set to true
    //    if(capture){
    //        output.beginEPS("test.ps");
    //    }
    //
    //    output.noFill();
    
    //ofBackground(0);
    
    
    ofPushMatrix();
    ofTranslate(ofGetWidth()/2,ofGetHeight()/2,zPos);
    
    
    ofRotateY((float)mouseX);
    ofRotateX((float)mouseY);
    
    ofTranslate(-150,-150,0);
    
    ofPoint pt = curve->plot3d(t);
    
    // ofDrawEllipse(pt.x,pt.y,pt.z,10,10);
    
    
    
    ofNoFill();
    ofSetColor(0);
    // curve->draw();
    
    
    ofMesh mesh;
    ofMesh mesh2;
    ofMesh mesh3;
    mesh.setMode(OF_PRIMITIVE_TRIANGLES);
    mesh2.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
     mesh3.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    //mesh.setupIndicesAuto();
    
    for(int i=0;i<curves.size();i++){
        ofxCurve * c = curves.at(i);
        ofSetColor(0);
        
        ofNoFill();
        // c->draw();
        
       // int numSections = 256;
        
        for(int j=0;j<numSections;j++){
            
     
            
            for(int k=0;k<res;k++){
                // do something here.
                ofVec3f p =c->plot3d((float)j/(float)numSections);
                ofVec3f d = c->getDirection((float)j/(float)numSections);
                ofVec3f a = ofVec3f(0,0,1.0f);
                ofQuaternion q;
                q.makeRotate(a,d);
                ofVec3f myPoint = ofVec3f(cos((float)k/(float)res*TWO_PI)*radius,sin((float)k/(float)res*TWO_PI)*radius,0);
                mesh.addVertex(p+myPoint*q);
                ofColor thisColor = colorB;
                if(k%2==0) thisColor = colorA;
                
                mesh.addColor(thisColor);
                
            }
            
            float t2 = (float)j/(float)numSections;
            float t3 = t2* 360.0f*(float)twists;
            while(t2>1.0f) t2-= 1.0f;
            ofVec3f p =c->plot3d(t2);
            ofVec3f d = c->getDirection(t2);
            ofVec3f a = ofVec3f(0,0,1.0f);
            
            ofQuaternion q;
            q.makeRotate(a,d);
            
              ofVec3f myPoint = ofVec3f(cos((t3+t)*PI/180.0f)*radius,sin((t3+t)*PI/180.0f)*radius,0);
            
            ofVec3f rightVec = myPoint*q;
            myPoint = ofVec3f(cos((t3+t+angleThickness)*PI/180.0f)*radius,sin((t3+t+angleThickness)*PI/180.0f)*radius,0);

            ofVec3f leftVec = myPoint*q;
            
//            mesh.addVertex(p+rightVec);
//            mesh.addColor(ofColor(colorB));
//            mesh.addVertex(p+leftVec);
//            mesh.addColor(ofColor(colorA));
            

        }
        
        for(int j=0;j<numSections;j++){
            float t2 = (float)j/(float)numSections;
            //while(t2>1.0f) t2-= 1.0f;
             float t3 = t2* 360.0f*(float)twists;
            ofVec3f p =c->plot3d(t2);
            ofVec3f d = c->getDirection(t2);
            ofVec3f a = ofVec3f(0,0,1.0f);
            
            ofQuaternion q;
            q.makeRotate(a,d);
            
            ofVec3f myPoint = ofVec3f(cos((t3+t+offset)*PI/180.0f)*radius,sin((t3+t+offset)*PI/180.0f)*radius,0);
            
            ofVec3f rightVec = myPoint*q;
            myPoint = ofVec3f(cos((t3+t+angleThickness+offset)*PI/180.0f)*radius,sin((t3+t+offset+angleThickness)*PI/180.0f)*radius,0);
            
            ofVec3f leftVec = myPoint*q;
            
            mesh2.addVertex(p+rightVec);
            mesh2.addColor(ofColor(colorC));
            mesh2.addVertex(p+leftVec);
            mesh2.addColor(ofColor(colorA));
            
        }
    
        
        for(int j=0;j<numSections;j++){
            float t2 = (float)j/(float)numSections;
            while(t2>1.0f) t2-= 1.0f;
             float t3 = t2* 360.0f*(float)twists;
            ofVec3f p =c->plot3d(t2);
            ofVec3f d = c->getDirection(t2);
            ofVec3f a = ofVec3f(0,0,1.0f);
            
            ofQuaternion q;
            q.makeRotate(a,d);
            
            ofVec3f myPoint = ofVec3f(cos((t3+t+offset*2.0f)*PI/180.0f)*radius,sin((t3+t+offset*2.0f)*PI/180.0f)*radius,0);
            
            ofVec3f rightVec = myPoint*q;
            myPoint = ofVec3f(cos((t3+t+angleThickness+offset*2.0f)*PI/180.0f)*radius,sin((t3+t+angleThickness+offset*2.0f)*PI/180.0f)*radius,0);
            
            ofVec3f leftVec = myPoint*q;
            
            
            mesh3.addVertex(p+rightVec);
            mesh3.addColor(ofColor(colorD));
            mesh3.addVertex(p+leftVec);
            mesh3.addColor(ofColor(colorA));
            
        }
      
        
    }
    
  
    for(int i=0;i<mesh.getNumVertices()-res-1;i+=1){
        mesh.addIndex(i);
        mesh.addIndex(i+res);
        mesh.addIndex(i+1);
        
        mesh.addIndex(i+1);
        mesh.addIndex(i+res);
        mesh.addIndex(i+res+1);
    }
    
//            mesh.addIndex(mesh.getNumVertices()-2);
//            mesh.addIndex(mesh.getNumVertices()-1);
//            mesh.addIndex(0);
//    
//    mesh.addIndex(0);
//    mesh.addIndex(1);
//    mesh.addIndex(mesh.getNumVertices()-1);

    for(int i=0;i<mesh2.getNumVertices()-3;i+=2){
        mesh2.addIndex(i);
        mesh2.addIndex(i+1);
        mesh2.addIndex(i+2);
        
        mesh2.addIndex(i+2);
        mesh2.addIndex(i+3);
        mesh2.addIndex(i+1);
    }
    
//    mesh2.addIndex(mesh.getNumVertices()-2);
//    mesh2.addIndex(mesh.getNumVertices()-1);
//    mesh2.addIndex(0);
//    
//    mesh2.addIndex(0);
//    mesh2.addIndex(1);
//    mesh2.addIndex(mesh.getNumVertices()-1);

    for(int i=0;i<mesh3.getNumVertices()-3;i+=2){
        mesh3.addIndex(i);
        mesh3.addIndex(i+1);
        mesh3.addIndex(i+2);
        
        mesh3.addIndex(i+2);
        mesh3.addIndex(i+3);
        mesh3.addIndex(i+1);
    }
    
//    mesh3.addIndex(mesh.getNumVertices()-2);
//    mesh3.addIndex(mesh.getNumVertices()-1);
//    mesh3.addIndex(0);
//    
//    mesh3.addIndex(0);
//    mesh3.addIndex(1);
//    mesh3.addIndex(mesh.getNumVertices()-1);
    
    
    
    ofSetColor(255);
    
    if(drawFaces == 0){
       if(bDrawCurve1) mesh.drawFaces();
       if(bDrawCurve2) mesh2.drawFaces();
       if(bDrawCurve3) mesh3.drawFaces();
    } else if(drawFaces == 1) {
       if(bDrawCurve1) mesh.drawVertices();
       if(bDrawCurve2) mesh2.drawVertices();
       if(bDrawCurve3) mesh3.drawVertices();
    } else if(drawFaces == 2){
       if(bDrawCurve1) mesh.drawWireframe();
       if(bDrawCurve2) mesh2.drawWireframe();
       if(bDrawCurve3)  mesh3.drawWireframe();
    }
    ofPopMatrix();
    
    ofDisableDepthTest();
    if(!bHide){
        gui.draw();
    }
    
   
}
void CloudsVisualSystem3DModelLoader::drawSceneGeometry( ofCamera* cam)
{
	
	//rotation velocity
	float t = ofGetElapsedTimef();
	accumulatedRotation += globalRotationVelocity * 1. / ofGetFrameRate();
	
	//draw infinite grid by positioning it infront of the camera
	if(bDrawGrid)
	{
		//	ofVec3f camPos;
		//	camPos = cam->getPosition();
		//	camPos += cam->getUpDir().cross(cam->getSideDir()).normalize() * gridDim * gridScale * .5;
		
		ofSetColor(255,255, 255, 150 );// make this an adjustable color in th GUI
		
		gridShader.begin();
		gridShader.setUniform1f("halfGridDim", gridDim * .5 );
		gridShader.setUniform1f("falloffDist", fogFalloffDistance );
		gridShader.setUniform1f("falloffExpo", fogFalloffExpo );
		gridShader.setUniform1f("falloffScl", fogFalloffScale );
		gridShader.setUniform1f("alphaScale", gridAlphaScale );
		
		//draw  minor grid
		ofPushMatrix();
		ofScale( gridScale, gridScale, gridScale );
		
		ofSetLineWidth( gridLineWidth );
		ofSetColor( gridColor.r*gridBrightness, gridColor.g*gridBrightness, gridColor.b*gridBrightness, gridAlpha );
		grid.draw(GL_LINES, 0, numGridVertices );
		
		ofPopMatrix();
		
		//draw  major grid
		ofPushMatrix();
		int gms = gridMajorScale;
		ofTranslate( getCameraRef().getLookAtDir() * -gridLineWidth / gridScale );
		ofScale( gridScale * gms,gridScale * gms, gridScale * gms );
		
		ofSetLineWidth( majorGridLineWidth );
		ofSetColor( gridMajorColor.r*gridMajorBrightness, gridMajorColor.g*gridMajorBrightness, gridMajorColor.b*gridMajorBrightness, gridMajorAlpha );
		grid.draw(GL_LINES, 0, numGridVertices );
		
		ofPopMatrix();
		
		gridShader.end();
	}
	
	//draw wireframe view cameras to the scene
	if(bDrawCameras)
	{
		drawMultipleViewCameras( cameraLineScale, cam );
	}
	
	if(bDrawArrows)
	{
		//draw arrows at model's min bound
		ofPushMatrix();
		ofTranslate( minBound * modelTransform.getGlobalTransformMatrix() );
		ofMultMatrix( modelTransform.getGlobalOrientation() );
		
		ofSetColor(0, 255, 0);
		ofPushMatrix();
		ofScale( arrowScale.x, arrowScale.y, arrowScale.z );
		arrowMesh.draw();
		ofPopMatrix();
		
		ofSetColor(255, 0, 0);
		ofPushMatrix();
		ofRotate(90, 1, 0, 0);
		ofScale( arrowScale.x, arrowScale.y, arrowScale.z );
		arrowMesh.draw();
		ofPopMatrix();
		
		ofSetColor(0, 0, 255);
		ofPushMatrix();
		ofRotate(90, 1, 0, 0);
		ofRotate(90, 0, 0, -1);
		ofScale( arrowScale.x, arrowScale.y, arrowScale.z );
		arrowMesh.draw();
		ofPopMatrix();
		
		ofPopMatrix();
	}
	
	
	//draw our model
	ofPushMatrix();
	
//	ofTranslate(-boundCenter);
	
	ofMultMatrix( modelTransform.getGlobalTransformMatrix() );
	
	if(currentSingleCam != &pathCamera)
	{
		ofTranslate( positionOffset - boundCenter );
		ofRotateX( globalRotation.x + accumulatedRotation.x );
		ofRotateY( globalRotation.y + accumulatedRotation.y );
		ofRotateZ( globalRotation.z + accumulatedRotation.z );
	}
	
	//draw bounding box
	if(bDrawBoundingBox)
	{
		ofSetColor(255, 255, 255, 255);
		drawBoundingBox();
	}
	
	if(bDrawCameraPath)
	{
		ofSetLineWidth(majorGridLineWidth);
		simpleShader.begin();
		pathCamera.drawPaths();
		simpleShader.end();
	}
	
	ofSetColor(modelColor);
	if(activeShader != NULL )
	{
		
		activeShader->begin();
		activeShader->setUniform1f( "discardThreshold", discardThreshold );
		activeShader->setUniform1f( "specularExpo", specularExpo );
		activeShader->setUniform1f( "specularScale", specularScale );
		activeShader->setUniform1f("falloffDist", fogFalloffDistance );
		activeShader->setUniform1f("falloffExpo", fogFalloffExpo );
		activeShader->setUniform1f("falloffScl", fogFalloffScale );
		
		if(activeShader == &XRayShader){
			/*
			 sfactor
			 Specifies how the red, green, blue, and alpha source blending factors are computed. The following symbolic constants are accepted: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE. The initial value is GL_ONE.
			 
			 dfactor
			 Specifies how the red, green, blue, and alpha destination blending factors are computed. The following symbolic constants are accepted: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA. GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. The initial value is GL_ZERO.
			 */
			
			//GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
			glDisable( GL_DEPTH_TEST );
			glBlendFunc(GL_ONE, GL_ONE);
			
//			modelMesh.draw();
			bWireframe?	modelMesh.drawWireframe() : modelMesh.draw();
			
			ofBlendMode( OF_BLENDMODE_ADD );
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		}
		else{
			if(bWireframe)	ofSetLineWidth( wireframeLinewidth );
			bWireframe?	modelMesh.drawWireframe() : modelMesh.draw();
		}
		
		activeShader->end();
	}
	
	ofPopMatrix();
}