Beispiel #1
0
//--------------------------------------------------------------
void testApp::setup(){

	w = ofGetWidth();
	h = ofGetHeight();
    fbfbo.allocate(w,h);
    fbfbo.getTextureReference().setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);
    fbo.allocate(w,h);
	fbo.getTextureReference().setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);    
    //settings
    ofSetMinMagFilters(GL_NEAREST, GL_NEAREST); 
    
    // Clear the FBO's
    // otherwise it will bring some junk with it from the memory
    fbfbo.begin();
    ofClear(0,0,0,255);
    fbfbo.end();
    
    fbo.begin();
    ofClear(0,0,0,255);
    fbo.end();

    tritimer = 0;
    tritimer2 = 0;
    tritimerlimit=30;
    tritimer2limit=45;
    
}
Beispiel #2
0
void testApp::maskedDraw(ofBaseHasTexture& tex) {
	ofTexture& texture = tex.getTextureReference();
	ofEnableAlphaBlending();
	maskShader.begin();
	maskShader.setUniformTexture("tex", texture, 0);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	texture.draw((int) -texture.getWidth() / 2, (int) -texture.getHeight() / 2);
	maskShader.end();
	ofDisableAlphaBlending();
}
void ofApp::draw() {	
	ofPushMatrix();
	ofScale(ofGetWidth(), ofGetHeight());
	ofNoFill();
	
	drawShader.begin();
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	bool usePing = ofGetFrameNum() % 2 == 0;	
	drawShader.setUniformTexture("tex", usePing ? ping : pong, 0);
	mesh.draw();
	drawShader.end();
	ofPopMatrix();
}
void ofApp::update() {
	bool usePing = ofGetFrameNum() % 2 == 0;
	ofFbo& toFbo = usePing ? ping : pong;
	ofFbo& fromFbo = usePing ? pong : ping;
	toFbo.begin();
	updateShader.begin();
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	updateShader.setUniform2f("mouse", (float) mouseX / ofGetWidth(), (float) mouseY / ofGetHeight());
	updateShader.setUniformTexture("tex", fromFbo, 0);
	fromFbo.draw(0, 0);
	updateShader.end();
	toFbo.end();
}
Beispiel #5
0
void ofApp::keyPressed(int key){

    /*
     
            of default settings are
     
            min = GL_LINEAR
            mag = GL_LINEAR
     
     */
    
    switch (key) {
        case '1':
            min = GL_NEAREST_MIPMAP_NEAREST;
            break;
            
        case '2':
            min = GL_LINEAR_MIPMAP_NEAREST;
            break;
        case '3':
            min = GL_NEAREST_MIPMAP_LINEAR;
            break;
        case '4':
            min = GL_LINEAR_MIPMAP_LINEAR;
            break;

        case '5':
            min = GL_NEAREST;
            break;

        case '6':
            min = GL_LINEAR;
            break;
            
        case 'n':
            max = GL_NEAREST;
            break;
            
        case 'l':
            max = GL_LINEAR;
            break;            
            
        default:
            break;
    }
    
    ofSetMinMagFilters( min, max);
    img.getTextureReference().setTextureMinMagFilter( min, max );
    
}
Beispiel #6
0
//--------------------------------------------------------------
void RushMyCube::draw() {
	int i;
	list<Cube*>::iterator it;
	for(it = cubes.begin(), i=0; it != cubes.end(); it++, i++) {
		if(!winner) {
			cam[i]->begin(ofRectangle(camWidth*i,0,camWidth,drawSize));
			(*it)->draw(drawSize*.9);
			cam[i]->end();
			ofPushMatrix();
			ofSetColor(255, 50, 0);
			ofRect(4+camWidth*i, 4, 42, 42);
			ofSetColor(255);
			ofEnableAlphaBlending();
			for(list<SkillManager::Skills>::iterator its= (*it)->skillManager->skills.begin(); its != (*it)->skillManager->skills.end(); ++its) {
				ofImage *toDraw;
				switch(*its) {
					case 0: toDraw = &lag; break;
					case 1: toDraw = &move; break;
					case 2: toDraw = &lock; break;
					case 3: toDraw = &plus1; break;
					case 4: toDraw = &minus2; break;
				}

				toDraw->draw(5+camWidth*i, 5, 40, 40);
				ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
				ofTranslate(45, 0);
			}
			ofDisableAlphaBlending();
			ofPopMatrix();
		}
		else {
			if(winner == i+1) {
				cam[i]->begin(ofRectangle(camWidth*i,0,camWidth,drawSize));
					(*it)->drawAllFaces(drawSize*.9);
				cam[i]->end();
				ofSetColor(120, 120, 255);
				winFont.drawString("YOU WIN", camWidth*i  + (camWidth - 342)/2, 60);
				ofSetColor(255);
			}
		}
	}

	sw.draw(drawSize, ofGetWidth()/2, ofGetHeight()-40);
}
Beispiel #7
0
//--------------------------------------------------------------
void testApp::setup(){
    w = ofGetWidth();
	h = ofGetHeight();
    fbb.allocate(w,h);
    fbb.getTextureReference().setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);
    ffb.allocate(w,h);
	ffb.getTextureReference().setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);
    //settings
    ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
    
    // Clear the FBO's
    // otherwise it will bring some junk with it from the memory
    fbb.begin();
    ofClear(0,0,0,255);
    fbb.end();
    
    ffb.begin();
    ofClear(0,0,0,255);
    ffb.end();
    
    tritimer = 0;
    tritimer2 = 0;
    tritimerlimit=30;
    tritimer2limit=45;

    
    bb = new pxBrush*[BRUSHES];
    for (int i = 0;i<BRUSHES;i++){
        bb[i] = new pxBrush(ofVec3f(ofRandomWidth(),ofRandomHeight(),0));
    }
    cc = new pxConstraint*[CONSTRAINT];
    cc[0] = new pxConstraint(bb[0],bb[1],300,0.01);
        cc[1] = new pxConstraint(bb[1],bb[2],200,0.01);
        cc[2] = new pxConstraint(bb[2],bb[3],250,0.01);
        cc[3] = new pxConstraint(bb[3],bb[4],200,0.01);
        cc[4] = new pxConstraint(bb[4],bb[5],200,0.01);
        cc[5] = new pxConstraint(bb[5],bb[0],200,0.01);
    timer = 0;
    timerthresh = 100;

}
Beispiel #8
0
//--------------------------------------------------------------
void RocketShake::draw(int size) {
	ofEnableAlphaBlending();
	_background.draw(0,0,size,size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	_planet1.draw(_positionPlanet1.x*size, _positionPlanet1.y*size, .15*size, .15*size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	_planet2.draw(_positionPlanet2.x*size, _positionPlanet2.y*size, .1*size, .1*size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	_moon.draw(size/2, size, .5*size, .12*size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	_fire.draw(size/2, (size-.10*size)*(1-_rocketHeight)-.10*size, (_speed < 0 ? 0 : _speed)/2.5*.05*size, (_speed < 0 ? 0 : _speed)/2.5*.17*size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	_rocket.draw(size/2, (size-.10*size)*(1-_rocketHeight), .12*size, .32*size);
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	ofDisableAlphaBlending();
}
Beispiel #9
0
//--------------------------------------------------------------
void testApp::setup()
{
	ofSetLogLevel(OF_LOG_ERROR);
	ofBackground(255, 255, 255);
	//ofSetVerticalSync(false);
	ofSetFrameRate(30);
	//ofDisableArbTex();
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
	glEnable(GL_DEPTH_TEST);
	ofEnableSmoothing();
	
	threshold = 80;
	blur =3;
	maxArea = (imageWidth*imageHeight)/2;
	
	kinect.init();
	kinect.enableDepthNearValueWhite(true);
	kinect.setVerbose(false);
	kinect.open();
	int length = imageWidth*imageHeight;
	rgbaPixels		  		= NULL;
	rgbaPixels = new unsigned char[length*4];
	memset(rgbaPixels, 0, length*4*sizeof(unsigned char));
	
	grayOfImage.allocate(imageWidth, imageHeight, OF_IMAGE_GRAYSCALE);
	grayImage.allocate(imageWidth, imageHeight);
	grayBg.allocate(imageWidth, imageHeight);
	grayDiff.allocate(imageWidth, imageHeight);
	
	kinectRawImage.allocate(imageWidth, imageHeight, OF_IMAGE_COLOR);
	kinectRGBA.allocate(imageWidth, imageHeight, OF_IMAGE_COLOR_ALPHA);

	
	cvColorImage.allocate(imageWidth, imageHeight);
	
	createGUI();
	createBox2D();
  
}
Beispiel #10
0
//--------------------------------------------------------------
void ofApp::setup(){
  ofBackground(34, 34, 34);
  ofSetVerticalSync(true);
  ofSetFrameRate(0);
//  ofDisableAntiAliasing();
  ofDisableLighting();
//  ofDisableAlphaBlending();
//  ofEnableNormalizedTexCoords();
//  ofDisableArbTex();
  ofEnableArbTex();
//  ofDisableNormalizedTexCoords();
  ofDisableTextureEdgeHack();
//  ofDisableSmoothing();
  ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
//  ofEnableAlphaBlending();

  img_size = 4096.;
  fbo_size = 8192.;
  w = img_size;
  h = img_size;
  scale_display = 5.7;
  scale_target = scale_display;

//  colorPixels = new unsigned char [w*h*3];
  doShader = true;
  frame_num = 0;
  record_num = 0;
  time_step = 0;
  pick_step = 1;
  animate = false;
  camera_lock = false;
  camera_home = false;
  record = false;
  showFPS = false;

  font.loadFont("type/verdana.ttf", 10);

  quad.clear();
  quad.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
  quad.addVertex(ofVec3f(0, 0, 0));
  quad.addVertex(ofVec3f(w, 0, 0));
  quad.addVertex(ofVec3f(0, h, 0));
  quad.addVertex(ofVec3f(w, h, 0));

  img_00.loadImage("images/d7f_4k_01.png");
  img_01.loadImage("images/d7f_4k_02.png");
  img_02.loadImage("images/d7f_4k_03.png");
  img_03.loadImage("images/d7f_4k_04.png");
//  img_00.loadImage("images/micro_01.jpg");
//  img_01.loadImage("images/micro_02.jpg");
//  img_02.loadImage("images/micro_03.jpg");
//  img_03.loadImage("images/micro_04.jpg");

  /////////////////////////////////////////////////////////////////////////////
  // Framebuffers, allocation, etc
  /////////////////////////////////////////////////////////////////////////////
//  height.allocate(w,h,GL_RGB);
  height0.allocate(w,h,GL_RGB);
  height1.allocate(w,h,GL_RGB);
  height2.allocate(w,h/2,GL_RGB);
  height3.allocate(w,h/2,GL_RGB);

//  height_old.allocate(w,h,GL_RGB);
//  height_backup.allocate(w,h,GL_RGB);
  display.allocate(ofGetWidth(),ofGetHeight(),GL_RGB);

//  height_FBO.allocate(w,h,GL_RGB);
  height_Fbo0.allocate(w,h,GL_RGB);
  height_Fbo1.allocate(w,h,GL_RGB);
  height_Fbo2.allocate(w,h/2,GL_RGB);
  height_Fbo3.allocate(w,h/2,GL_RGB);
//  height_old_FBO.allocate(w,h,GL_RGB);
  height_old_Fbo0.allocate(w,h,GL_RGB);
  height_old_Fbo1.allocate(w,h,GL_RGB);
  height_old_Fbo2.allocate(w,h/2,GL_RGB);
  height_old_Fbo3.allocate(w,h/2,GL_RGB);
//  height_backup_FBO.allocate(w,h,GL_RGB);
  height_backup_Fbo0.allocate(w,h,GL_RGB);
  height_backup_Fbo1.allocate(w,h,GL_RGB);
  height_backup_Fbo2.allocate(w,h/2,GL_RGB);
  height_backup_Fbo3.allocate(w,h/2,GL_RGB);

  ClearFramebuffers();
  DisableInterpolation();


  /////////////////////////////////////////////////////////////////////////////
  // end framebuffers
  /////////////////////////////////////////////////////////////////////////////


//  #ifdef TARGET_OPENGLES
//    shader.load("shaders_gles/noise.vert","shaders_gles/noise.frag");
//  #else
    if(ofGetGLProgrammableRenderer()){
      shader.load("shaders_gl3/noise.vert", "shaders_gl3/noise.frag");
      waveShader.load("shaders_gl3/wave.vert", "shaders_gl3/wave.frag");
      waveShaderTiled.load("shaders_gl3/wave_tiled.vert", "shaders_gl3/wave_tiled.frag");
      waveShader_display.load("shaders_gl3/wave_DISPLAY.vert",
                              "shaders_gl3/wave_DISPLAY.frag");
      waveShader_displayTiled.load("shaders_gl3/wave_DISPLAY_tiled.vert",
                                    "shaders_gl3/wave_DISPLAY_tiled.frag");
      waveShaderMod.load("shaders_gl3/wave_mod.vert", "shaders_gl3/wave_mod.frag");
    }
    else{
      shader.load("shaders/noise.vert", "shaders/noise.frag");
    }
//  #endif


}
Beispiel #11
0
void testApp::draw(){
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
		
	ofBackground(0);
	ofSetColor(255);
	
	if(playerCount == 0) {
		float rescale = ofMap(sin(ofGetElapsedTimef() * 5), -1, 1, .8, 1.2);
		ofSetColor(magenta);
		drawTitle("WAITING FOR PLAYER", rescale);
	} else if(playerCount == 1) {
		ofVec2f offset(ofRandomf(), ofRandomf());
		offset *= 5;
		ofSetColor(cyan);
		ofPushMatrix();
		ofTranslate(offset.x, offset.y);
		drawTitle("AWAITING CHALLENGER");
		ofPopMatrix();
	} else if(playerCount == 2) {
		for(int i = 0; i < projectiles.size(); i++) {
			projectiles[i].draw();
		}
		
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			if(players[i].life > 0) {
				ofPushMatrix();
				ofTranslate((int) players[i].position.x, (int) players[i].position.y);
				ofScale(2, 2);
				if(players[i].position.x > ofGetWidth() / 2) {
					ofScale(-1, 1);
				}
				if(i == 0) {
					maskedDraw(ryu);
				} else {
					maskedDraw(ken);
				}
				ofPopMatrix();
			}
		}
	}
	
	int winner = 0;
	if(playerCount == 2) {
		bool done = false;
		for(int i = 0; i < players.size(); i++) {
			drawLife(i);
			if(players[i].life <= 0) {
				done = true;
			} else {
				winner = i;
			}
		}
		if(done && !lastDone) {
			youWin.play();
		}
		lastDone = done;
	}
	
	if(playerCount == 2 && lastDone) {
		bool flash = sin(2. * ofGetElapsedTimef() * TWO_PI) > 0;
		ofSetColor(flash ? yellow : 0);
		drawTitle("PLAYER " + ofToString(winner + 1) + " WINS");
	}
	
	if(panel.getValueB("debug")) {
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			ofCircle(players[i].position, 32);
		}
	}
}
//---------------------------------
void GeneratedMesh::setup(ofxBulletWorldRigid &world, ofVec3f position, string url, ofVec3f ModelScale){
    type = ShapeTypeAnimatedMesh;
    collisionTime = -120;
    ModelPath = url;
    this->position = position;
    this->world = &world;
	
    //rotation = btQuaternion(btVector3(0,1,0), ofDegToRad(-90));
    
    //TODO to try with ofBtGetCylinderCollisionShape, for improve collision detection
    
    
    anisotropy = 4.;
    
    float fboDiv = 4.f;
    //    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    fbo.allocate( (float)ofGetWidth() / fboDiv, (float)ofGetWidth() / fboDiv, GL_RGB, 4 );
    fbo.begin(); {
        ofClear(0, 0, 0, 255 );
        ofSetColor( 11,90,121, 255);
        ofRect(0, 0, ofGetWidth(), ofGetHeight() );
        ofSetColor(120, 140, 150, 255);
        
        int numIterations = 4;
        float inc = (float)fbo.getWidth() / ((float)numIterations);
        for( int i = 0; i < numIterations; i++ ) {
            float tx = (float)i*inc + inc;
            float ty = (float)i*inc + inc;
            
            ofSetColor(152,197,190, 255);
            ofSetLineWidth( 1.5 );
            if( i % 2 == 0 ) ofSetLineWidth( 0.5 );
            
            ofLine( tx, 0, tx, fbo.getHeight() );
            ofLine( 0, ty, fbo.getWidth(), ty );
        }
        
    } fbo.end();
    
    ofSetLineWidth( 1 );
    
    fbo.getTextureReference().bind();
    glGenerateMipmap( fbo.getTextureReference().texData.textureTarget);
    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
    //    glSamplerParameterf( fbo.getTextureReference().texData.textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2 );
    fbo.getTextureReference().unbind();

    
    omesh = ofMesh::plane( 70, 70, 14, 14, OF_PRIMITIVE_TRIANGLES );
    ofQuaternion rquat;
    rquat.makeRotate( 90, 1, 0, 0);
    ofSeedRandom();
    float rseed = ofRandom(0, 10000);
    vector< ofVec3f >& verts = omesh.getVertices();
    for( int i = 0; i < verts.size(); i++ ) {
        verts[i] = rquat * verts[i];
        verts[i].y = ofSignedNoise( verts[i].x*0.02, verts[i].y*0.02 + verts[i].z*0.02, ofGetElapsedTimef() * 0.1 + rseed ) * 3;
    }
    
    vector< ofVec2f >& tcoords = omesh.getTexCoords();
    for( int i = 0; i < tcoords.size(); i++ ) {
        tcoords[i].x *= 4.f;
        tcoords[i].y *= 4.f;
    }
    mesh = omesh;
    
    
    //ofEnableSeparateSpecularLight();
    
	//save init values
	initScale = scale;
    // create ofxBullet shape
    //body.create(world.world, position, 0); // we set m=0 for kinematic body
    body.create( world.world, mesh, position, 0.f, ofVec3f(-10000, -10000, -10000), ofVec3f(10000,10000,10000) );
    body.add();
    body.enableKinematic();
    body.setActivationState( DISABLE_DEACTIVATION );
    
    
    bAnimate = true;

    body.add();
    
	
    //body.setProperties(1., 0.); // .25 (more restituition means more energy) , .95 ( friction )
    // to add force to the ball on collision set restitution to > 1
	
	body.setProperties(3, .95); // restitution, friction
	body.setDamping( .25 );
    
	
	//Set Rotation Objects
	setupRot();
	
    body.activate();
	
	setDefaultZ();
    

    
    
    
}