Exemple #1
0
//--------------------------------------------------------------
void testApp::setup() {
  
  screen.loadImage("bg.png");
  death.loadImage("death.png");
  ofSetVerticalSync(true);
  ofSetLogLevel(OF_LOG_NOTICE);
  ofBackground(0);
  ofSetColor(255);
	
  //SVG
  svg.load("lay.svg");
  for (int i = 0; i < svg.getNumPath(); i++){
    ofPath p = svg.getPathAt(i);
    p.setPolyWindingMode(OF_POLY_WINDING_ODD);
    vector<ofPolyline>& lines = p.getOutline();
    for(int j=0;j<(int)lines.size();j++){
      outlines.push_back(lines[j].getResampledBySpacing(1));
    }
  }
  
  shoot.loadSound("shoot.wav");
  start.loadSound("boot.wav");
  win.loadSound("startup.wav");
  
	bMouseForce = false;
	
	box2d.init();
    box2d.enableEvents();   // <-- turn on the event listener
	box2d.setGravity(0, 10);
	box2d.createGround();
	box2d.setFPS(30.0);
	box2d.registerGrabbing();
  
  ofAddListener(box2d.contactStartEvents, this, &testApp::contactStart);
  ofAddListener(box2d.contactEndEvents, this, &testApp::contactEnd);
  
  for (int i=0; i<N_SOUNDS; i++) {
    sound[i].loadSound(ofToString(i)+".mp3");
    sound[i].setMultiPlay(true);
    sound[i].setLoop(false);
  }
  
  edgeLine.addVertex(ofGetWidth(), 0);
  edgeLine.addVertex(0, 0);
  edgeLine.addVertex(0, ofGetHeight()-30);
  edgeLine.addVertex(ofGetWidth(), ofGetHeight()-30);
  
  

  edgeLine.setPhysics(0.0, 0.5, 0.5);
  edgeLine.create(box2d.getWorld());
  
  
  
	
}
Exemple #2
0
    void setup() {
        ofEnableDepthTest();
        ofDisableArbTex();

        img.loadImage("img1.jpg");
        env.loadImage("env.jpg");
        env1.loadImage("env1.jpg");


        shader.load("material.vert","material.frag");
	model.loadModel("wolf.dae", true);
    }
Exemple #3
0
		void setup(float x, float y, string path, string videoPath){
			img.loadImage(path);
			r.set(x,y,img.getWidth(),img.getHeight());
			video = videoPath;
			thumbPath = path;
			loadPos();
		}
Exemple #4
0
//--------------------------------------------------------------
void testApp::setup()
{
	// setup pointsprite texture
	// NOTES: the texture size must be Power of Two,
	// and turn off arb texture option while loading
	ofDisableArbTex();
	sprite.loadImage("image.jpg");
	ofEnableArbTex();
	
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofBackground(0);
	
	sys.setup();
	
	group.setup(sys);
	group.setColor(ofxSPK::RangeC(ofColor(255, 255), ofColor(255, 255)),
				   ofxSPK::RangeC(ofColor(0, 0), ofColor(255, 0)));
	
	group.setLifeTime(0.5, 5);
	group.setFriction(0.1);
	group.setSize(0, ofxSPK::RangeF(30, 250));
	
	group.setGravity(ofVec3f(0, -10, 0));
	group.setMass(0.1, 1);
	
	rot.setup(SPK::Vortex::create(SPK::Vector3D(ofGetWidth()/2, ofGetHeight()/2),
								  SPK::Vector3D(0, 1, 0),
								  200,
								  10), group);
	
	group.reserve(10000);
}
//--------------------------------------------------------------
void testApp::setup(){


  img.loadImage("image.jpg");
    w = img.width;
    h = img.height;
    imgPos.x = (ofGetWidth()-w)/2;
    imgPos.y = (ofGetHeight()-h)/2;
}
//--------------------------------------------------------------
void testApp::setup(){

	quadmesh.create(150, 50, 400, 300, 8);

	quadimage.loadImage("1.jpg");
	quadtexture = genTex(quadimage.getWidth(), quadimage.getHeight(), quadimage.getPixels());

	// if use GL_TEXTURE_RECTANGLE, change texture coord from [1,1] to [width, height]
	//quadmesh.ResetTextureCoords(quadimage.getWidth(), quadimage.getHeight());
}
Exemple #7
0
    void setup()
	{
        ofSetLogLevel(OF_LOG_VERBOSE);
		
        testImage.loadImage("of.png");
        fbo.allocate(ofGetWidth(), ofGetHeight());
		fbo.begin();
			ofClear(0, 0, 0, 0);
		fbo.end();
    }
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetWindowShape(1024,1024);
    ofSetBackgroundAuto(true);
    //ofBackground(0,0,0); // background
    ofBackground(128,128,128); // background
    
    imageCrystal.loadImage("crystal.jpg");  //load initial image
    
    
    point.set(10,10);
    ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
}
Exemple #9
0
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    
    //load image file
    string path = ofToDataPath("logo.png");
    of_image.loadImage( path );
    ci_surface = ci::loadImage( path );
    
    //convert images
    ci_texture = ci::gl::Texture( ofxCi::toCi(of_image), GL_RGBA, of_image.getWidth(), of_image.getHeight() );
    of_image.setFromPixels(ofxCi::toOf(ci_surface), ci_surface.getWidth(), ci_surface.getHeight(), OF_IMAGE_COLOR_ALPHA);
    
}
Exemple #10
0
//--------------------------------------------------------------
void testApp::setup(){
    vidGrabber.setVerbose(true);
    vidGrabber.initGrabber(640, 480);
    
    colorImg.allocate(vidGrabber.getWidth(), vidGrabber.getHeight());
    greyImage.allocate(vidGrabber.getWidth(), vidGrabber.getHeight());
    greyImageSmall.allocate(120, 90);

    haarFinder.setup("haarcascade_frontalface_alt2.xml");
    
    img.loadImage("stevejobs.png");
    img.setAnchorPercent(0.5, 0.5);
                    
    ofEnableAlphaBlending();
}
Exemple #11
0
	void loadImage(string filePath)
	{
		vector<string>hierarchy = ofSplitString(filePath, "/");
		
		if (hierarchy.size() > 1)
			cur_file = hierarchy.back();
		else
			cur_file = filePath;
		
		img1.loadImage(filePath);
		img1.resize(w, h);
		img1.setImageType(OF_IMAGE_GRAYSCALE);
		
		synthImage();
	}
Exemple #12
0
//--------------------------------------------------------------
void testApp::setup(){
	site.loadImage("site.png");
	site.setAnchorPercent(0.5, 0.5);
	//	zg.load("patches/mouth1.pd", 0, 2, 44100, 256);
	
	
	ofSetVerticalSync(true);
	ofSetFrameRate(60.f);
	play = false;
	WIDTH = 320;
	HEIGHT = 240;
	useLiveVideo = false;
	int sourceWidth = 320;
	int sourceHeight = 240;

	vidGrabber.setVerbose(true);

	sourceWidth = WIDTH;
	sourceHeight = HEIGHT;

	vidGrabber.initGrabber(WIDTH, HEIGHT);
	/*
	
	vidPlayer.loadMovie("mouth0.mov");
	vidPlayer.play();
	vidPlayer.setLoopState(OF_LOOP_NORMAL);
	
	sourceWidth = vidPlayer.width;
	sourceHeight = vidPlayer.height;
	*/
    colorImg.allocate(sourceWidth, sourceHeight);
	bigGrayImage.allocate(sourceWidth, sourceHeight);
		
	grayImage.allocate(WIDTH, HEIGHT);
	grayBg.allocate(WIDTH, HEIGHT);
	grayDiff.allocate(WIDTH, HEIGHT);
	mouths.setup();

	threshold = 80;
	gui.addButton("rewind", rewind);
	gui.addButton("pause", paused);
	gui.addButton("play", play);
	gui.addToggle("Use Camera", useLiveVideo);
	gui.addContent("Source Image", colorImg);
	gui.loadFromXML();
	gui.setAutoSave(true);
	ofSoundStreamSetup(2,0,this, 44100,256, 1);
}
Exemple #13
0
//--------------------------------------------------------------
void ofApp::setup(){

    arraySounds = new ofSoundPlayer[numberOfSounds];
    for(int i=0;i<numberOfSounds;++i){
        arraySounds[i].loadSound("sounds/TheWhole"+ofToString(i+1)+".mp3");
        arraySounds[i].setVolume(0.9f);
    }
    currentSoundIndex = 0;

  ofSetWindowShape(1000, 1000);
    image.loadImage("output_croped.png");
    image.resize(700, 600);
    zoomFactor = 2.0;
    radius = 180;
    imgPos.x = 100;
    imgPos.y = 30;

}
Exemple #14
0
void gameOfLife::setup() {
  fullScreen = false;
  highlight = false;
  active = false;
  
  ofSetFullscreen(false);
  ofSetWindowShape(WIDTH, HEIGHT);
  
  init(WIDTH, HEIGHT, CELLSIZE);
  
	ofBackground(ofColor::white);
	ofSetBackgroundAuto(true);
	ofSetWindowTitle("Conway's Game of Life");
	ofSetFrameRate(FRAMERATE);
  
  myImage.loadImage("circleAlpha.tif");
  
  sender.setup(HOST, PORT);
  
}
//--------------------------------------------------------------
void testApp::setup(){	
	ofBackground(0,0,0);
	
	for(int i=0; i<MAX_PARTICLES; i++) {
		pos[i][0] = ofRandom(-ofGetWidth(), ofGetWidth());
		pos[i][1] = ofRandom(-ofGetHeight(), 2 * ofGetHeight());
		pos[i][2] = ofRandom(-ofGetWidth(), ofGetWidth());
		
		vel[i][0] = ofRandom(-1, 1); 
		vel[i][1] = ofRandom(-1, 1); 
		vel[i][2] = ofRandom(-1, 1); 
		
		col[i][0] = 1;//ofRandom(0, 1);
		col[i][1] = 1;//ofRandom(0, 1);
		col[i][2] = 1;//ofRandom(0, 1);
		col[i][3] = 1;//ofRandom(0, 1);
	}
	
	ofDisableArbTex();				// new in OF006, force any texture created from this point on, to be GL_TEXTURE_2D (normalized uv coords)
	image.loadImage("grad.png");
}
Exemple #16
0
//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(255, 255, 255);
	ofSetVerticalSync(true);
	ofSetFrameRate(60);
	
	ballImage.loadImage("ball.png");
	
	width = ofGetWidth();
	height = ofGetHeight();
	
	//	physics.verbose = true;			// dump activity to log
	physics.setGravity(ofPoint(0, GRAVITY, 0));
	
	// set world dimensions, not essential, but speeds up collision
	physics.setWorldSize(ofPoint(-width/2, -height, -width/2), ofPoint(width/2, height, width/2));
	physics.setSectorCount(SECTOR_COUNT);
    physics.setDrag(0.97f);
	physics.setDrag(1);		// FIXTHIS
	physics.enableCollision();
	
	initScene();
	
	// setup lighting
	GLfloat mat_shininess[] = { 50.0 };
	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat light_position[] = { 0, height/2, 0.0, 0.0 };
	glShadeModel(GL_SMOOTH);
	
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
	
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_LIGHT0);
	
	// enable back-face culling (so we can see through the walls)
	glCullFace(GL_BACK);
	glEnable(GL_CULL_FACE);
}
Exemple #17
0
 void setup(){
     ofSetLogLevel(OF_LOG_VERBOSE);
     testImage.loadImage("of.png");
     fbo.allocate(ofGetWidth(), ofGetHeight());
 }
Exemple #18
0
	void update() {
#ifdef INSTALL
		if(cam.update()) {
			ofPixels& pixels = cam.getColorPixels();
#else
		cam.update();
		if(cam.isFrameNew()) {
			ofPixels& pixels = cam.getPixelsRef();
#endif
			// next two could be replaced with one line
			ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0);
			ofxCv:flip(rotated, rotated, 1);
			Mat rotatedMat = toCv(rotated);
			if(tracker.update(rotatedMat))  {
				ofVec2f position = tracker.getPosition();
				vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount);
				FaceTrackerData curData;
				curData.load(tracker);
				if(!neighbors.empty()) {
					nearestData = *faceCompare.nearest(curData, neighbors);
					if(nearestData.label != lastLabel) {
						similar.loadImage(nearestData.getImageFilename());
#ifdef INSTALL
						whitePoint = getWhitePoint(similar);
#else
						whitePoint.set(1, 1, 1);
#endif
					}
					lastLabel = nearestData.label;
				}
				if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) {
					saveFace(curData, rotated);
					currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData));
				}
			}
			presence.update(tracker.getFound());
			if(presence.wasTriggered()) {
				presenceFade.stop();
			}
			if(presence.wasUntriggered()) {
				for(int i = 0; i < currentData.size(); i++) {
					data.add(currentData[i].first, currentData[i].second);
				}
				currentData.clear();
				presenceFade.start();
			}
		}
	}
	void draw() {
		ofBackground(255);
		CGDisplayHideCursor(NULL);
		ofSetColor(255);
		if(similar.isAllocated()) {
			shader.begin();
			shader.setUniformTexture("tex", similar, 0);
			shader.setUniform3fv("whitePoint", (float*) &whitePoint);
			similar.draw(0, 0);
			shader.end();
		}
		ofPushStyle();
		if(presenceFade.getActive()) {
			ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128));
			ofFill();
			ofRect(0, 0, ofGetWidth(), ofGetHeight());
			ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32));
			data.drawBins();
			ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64));
			data.drawData();
		}
		ofSetColor(255, 64);
		ofNoFill();
		if(!tracker.getFound()) {
			ofCircle(tracker.getPosition(), 10);
		}
		tracker.draw();
		ofPopStyle();
		
#ifndef INSTALL
		drawFramerate();
#endif
	}
Exemple #19
0
//--------------------------------------------------------------
void testApp::setup(){
    img.loadImage("fill.png");
    ktex.setTexture(img.getTextureReference());

}
Exemple #20
0
//--------------------------------------------------------------
void ofApp::setup(){
	//Load image file
	image.loadImage("../../../Images/sunflower.png");	
}
//--------------------------------------------------------------
void ofApp::keyPressed(int a){
    imageCrystal.loadImage("crystal.png"); //Load image with alpha
    cout<<imageCrystal.bpp;
}
//--------------------------------------------------------------
void ofApp::keyReleased(int a){
    imageCrystal.loadImage("crystal.jpg"); //load image with no alpha
    cout<<imageCrystal.bpp;

}