Exemplo n.º 1
0
void JagSkillsApp::setup()
{
	frameRate = 30;
    ofSetFrameRate(frameRate);

	ofSetLogLevel(OF_LOG_VERBOSE);

	receiver.setup(12345);

	//ofEnableArbTex();
    ofDisableArbTex();
    ofSetWindowPosition(10, 10);
    ofSetWindowShape(1600, 1000);
    
    scene.setup();
    
	jointPosOffset = ofVec3f(0, 0, 0);

	gui.app = (JagSkillsApp*)this;
    gui.setup();
    
	isPaused = false;
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void Winch::draw() {
    ofPushMatrix();
    ofTranslate(winchXzPosi.x, curPosition, winchXzPosi.y);
    ofSetColor(200);

    
	//bottle.setPosition(0, curPosition, 0);
    //bottle.draw();
	//model.setPosition(0,curPosition,0);
	//model.draw();
	//bottle.drawWireframe();

	ofDisableArbTex();
	material.begin();
	//texMetal.bind();
	for(int i=0;i<3;i++){
		sphere[i].setPosition(0,i*3.5+2.0,0);
		sphere[i].draw();
	}
	//texMetal.unbind();
	material.end();
    ofPopMatrix();
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::setup() {
	
	ofBackgroundHex(0xfdefc2);
	ofSetLogLevel(OF_LOG_NOTICE);
	ofSetVerticalSync(true);
	ofDisableAntiAliasing();
	
	// find all the texture files and load them
	ofDirectory dir;
	ofDisableArbTex();
	int n = dir.listDir("textures");
	for (int i=0; i<n; i++) {
		textures.push_back(ofImage(dir.getPath(i)));
	}
	printf("%i Textures Loaded\n", (int)textures.size());
	
	// Box2d
	box2d.init();
	box2d.setGravity(0, 10);
	box2d.createGround();
	box2d.setFPS(60.0);
	box2d.registerGrabbing();
}
Exemplo n.º 4
0
ksYangsu::ksYangsu()
{

	ofDisableArbTex(); 

	ysMesh.addVertex(
		ofPoint(-1.0f,0.5f*sin(PI/3.0f)));
	ysMesh.addVertex(
		ofPoint(1.0f,1.5f*sin(PI/3.0f)));

	ysMesh.addTexCoord(ofVec2f(0,1));
	ysMesh.addTexCoord(ofVec2f(1,1));

	ofIndexType ids[6] =
	{
		6,0,1,
		6,1,2
	};
	ysMesh.addIndices(ids,6);


	T =0;
}
Exemplo n.º 5
0
ParticleSystem::ParticleSystem()
{
	currentImage = 0;
	curIndex = 0;
	useGravity = true;
	maxSpriteSize = 96.0;
	//setWindowSize( ofVec2f( 1, 1 ) );
	
	shader.setup("shader/pointShader.vs", "shader/pointShader.fs" );
	
	ofDisableArbTex();
	//dustParticle.loadImage("shader/pointSpriteImg.png");
	interviewPointSprite.loadImage("shader/InterviewSpriteImg_001.png");
	buzzPointSprite.loadImage("shader/BuzzSpriteImg_001.png");
	votePointSprite.loadImage("shader/VoteSpriteImg_002.png");
	performancePointSprite.loadImage("shader/PerformanceSpriteImg_001.png");
	inspirationPointSprite.loadImage("shader/InspirationSpriteImg_002.png");
	
	ofEnableArbTex();
	
	drawingType = SHADED_POINT_SPRITE;
	setInteractionMode(MODE_INTERVIEW);
}
Exemplo n.º 6
0
//--------------------------------------------------------------
void testApp::setup(){



    gui.setup("fog control"); // most of the time you don't need a name

	gui.add(density.setup( "density", 0.0035f, 0.0f , 0.5f ));
	gui.add(fog_start.setup( "fog start", 10.0f, 0.0f, 255.0f ));
	gui.add(fog_end.setup( "fog end", 50.0f, 0.0f, 255.0f ));
	gui.add(r.setup( "redColor", 0.1f, 0, 1 ));
	gui.add(g.setup( "greenColor", 0.2f, 0, 1 ));
	gui.add(b.setup( "blueColor", 0.5f, 0, 1 ));
	gui.add(fogFilter.setup( "switch fog",1, 0,2));


    ofDisableArbTex();

    ofEnableLighting();

    fogShader.load("shaders/FogShaderTex");

    color.loadImage("textures/pond1.jpg");

    fogShader.begin();


    fogShader.setUniformTexture( "baseMap", color, color.getTextureReference().getTextureData().textureID );

    fogShader.end();


    bHide = true;
    fog.setup();



}
Exemplo n.º 7
0
//--------------------------------------------------------------
void testApp::setup() {

	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
	ofSetLineWidth(3.0);

	cameraRotation = 0;
	zoom		   = -500;
	zoomTarget     = 200;

	// ------------------------- billboard particles
	for (int i=0; i<NUM_BILLBOARDS; i++) {

		billboardVels[i].set(ofRandomf(), -1.0, ofRandomf());
		billboardVerts[i].set(ofRandom(-500, 500),
							  ofRandom(-500, 500),
							  ofRandom(-500, 500));

		billboardColor[i].set(1, 0, 0, ofRandomuf());

		billboardSize[i]	    = 0;
		billboardSizeTarget[i]  = ofNextPow2(ofRandom(4, 24));	// faster to have a power of 2
	}

	billboardVbo.setVertexData(billboardVerts, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);
	billboardVbo.setColorData(billboardColor, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);

	// load the bilboard shader
	// this is used to change the
	// size of the particle
	billboardShader.load("shaders/BillboardExample");

	// we need to disable ARB textures
	// because we are binding ourselfs
	ofDisableArbTex();
	texture.loadImage("images/dot.png");
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetLogLevel(OF_LOG_VERBOSE);    
	
    // we need GL_TEXTURE_2D for our models coords.
    ofDisableArbTex();

    if(model.loadModel("astroBoy_walk.dae",true)){
    	model.setAnimation(0);
    	model.setPosition(ofGetWidth()/2, (float)ofGetHeight() * 0.75 , 0);
    	//model.createLightsFromAiModel();
    	//model.disableTextures();
    	//model.disableMaterials();

    	mesh = model.getMesh(0);
    	position = model.getPosition();
    	normScale = model.getNormalizedScale();
    	scale = model.getScale();
    	sceneCenter = model.getSceneCenter();
    	material = model.getMaterialForMesh(0);
        tex = model.getTextureForMesh(0);
    }

    ofEnableBlendMode(OF_BLENDMODE_ALPHA);

	glEnable(GL_DEPTH_TEST);

    //some model / light stuff
    glShadeModel(GL_SMOOTH);
    light.enable();
    ofEnableSeparateSpecularLight();

	
	bAnimate		= false;
	bAnimateMouse 	= false;
	animationTime	= 0.0;
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void ofApp::setup(){
	
	// initialize variables:
	
	isShaderDirty = true;  // this flag will tell us whether to reload our shader from disk.
						   // this allows you to change your shaders without having to restart
						   // your app. we'll set it up so that pressing the SPACE key on your
						   // keyboard will reload the shader.
	
	// initialize screen, lock framerate to vsync:

	ofSetFrameRate(0);
	ofSetVerticalSync(true);

	
	// generate a box vboMesh from a primitive.
	
	ofBoxPrimitive tmpBox;
	// set the size to be 2 units.
	tmpBox.set(2);
	
	mVboBox = tmpBox.getMesh();
	
	// load depth image
	ofDisableArbTex();
	// note that we disable arb tex, meaning we will use normalized texture coordinates,
	// where a texture's x and y coordinate are each expressed as a normalized float.
	// this makes things slightly easier in the shader.
	
	// load the depth image into our texture
	ofLoadImage(mTexDepth, "depth_image.png");
	ofEnableArbTex();

	mCamMain.setupPerspective(false,60,0,10000);
	
}
Exemplo n.º 10
0
void ofApp::setup(){
    ofSetFrameRate(60);
    ofBackground(215,160,0);

    w=ofGetScreenWidth();
    h=ofGetScreenHeight();

    post.init(w,h);
    post.createPass<FxaaPass>()->setEnabled(true);
    post.createPass<DofPass>()->setEnabled(true);
    post.createPass<SSAOPass>()->setEnabled(true);

    imgcapsule="images/10-tessellation.jpg";/* image base shader */
    model.loadModel("models/omino.dae",true);
    model.setLoopStateForAllAnimations(OF_LOOP_NORMAL);
    model.playAllAnimations();
    model.setPausedForAllAnimations(true);

    materiale.initMaterial(21,materiale.GENERIC,imgcapsule,"");
    materiale1.initMaterial(21,materiale.GENERIC,imgcapsule,"");
    materiale2.initMaterial(21,materiale.GENERIC,imgcapsule,"");

    ofDisableArbTex();
    ofFbo::Settings settings;
    settings.numSamples = 8;
    settings.useDepth = true;
    settings.width = w;
    settings.height = h;
    fboscene.allocate(settings);

    gui.setup();
    gui.add(speedAnim.set("speed anim",20,1,100));
    gui.setPosition(ofVec3f(420,10,0));

    bg.loadImage("images/img1.jpg");
}
Exemplo n.º 11
0
void TankClass::setup(){

    tankParam.add(xPos.set("xPos",0.0,-1000000.0,1000000.0));
    tankParam.add(yPos.set("yPos",0.0,-1000000.0,1000000.0));
    tankParam.add(zPos.set("zPos",0.0,-1000000.0,1000000.0));
    tankParam.add(xSpeed.set("xSpeed",0.0,-1000000.0,1000000.0));
    tankParam.add(ySpeed.set("ySpeed",0.0,-1000000.0,1000000.0));
    tankParam.add(zSpeed.set("zSpeed",0.0,-1000000.0,1000000.0));
    tankParam.add(rSpeed.set("rSpeed",1.8,-1000000.0,1000000.0));
    tankParam.add(rotation.set("rotation",0.0,-1000000.0,1000000.0));
    tankParam.add(up.set("up",false));
    tankParam.add(down.set("down",false));
    tankParam.add(left.set("left",false));
    tankParam.add(right.set("right",false));
    tankParam.add(upk.set("upk",0,0,1000));
    tankParam.add(downk.set("downk",0,0,1000));
    tankParam.add(leftk.set("leftk",0,0,1000));
    tankParam.add(rightk.set("rightk",0,0,1000));
    tankParam.add(red.set("red",0,0,255));
    tankParam.add(green.set("green",0,0,255));
    tankParam.add(blue.set("blue",0,0,255));

    Tank.loadModel("Tank.3ds");
    Tank.setScale(.15,.15,.15);

    ofEnableLighting(); //== glEnable(GL_LIGHTING);
    glShadeModel(GL_SMOOTH);
    ofEnableSeparateSpecularLight();
    ofEnableNormalizedTexCoords();
    ofDisableArbTex();

    light.setSpotlight();
    light.setSpotConcentration(64);
    light.setSpotlightCutOff(30);

}
Exemplo n.º 12
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetVerticalSync(true);
    ofSetFrameRate(60);
    
    gui.setup("panel"); // most of the time you don't need a name but don't forget to call setup
    gui.add(speed.set( "speed", 200, 10, 300 ));
    gui.add(cameraXRadius.set( "cameraXRadius", 150, 0, 5000 ));
    gui.add(cameraZRadius.set( "cameraZRadius", 1000, 0, 5000 ));
    
    // GL_REPEAT for texture wrap only works with NON-ARB textures //
    ofDisableArbTex();
    texture.loadImage("Meat0016_thumbhuge.jpg"); // texture: http://www.cgtextures.com/
    texture.getTextureReference().setTextureWrap( GL_REPEAT, GL_REPEAT );
    ofEnableArbTex();
    
    for (int i = 0; i < NUM; i++)
    {
        boxes[i].set( w, h, d );
        boxes[i].setPosition(0, (h * hMargin) * i - (h * hMargin) * NUM / 2, 0);
    }
    
    ofSetSmoothLighting(true);
    pointLight.setDiffuseColor( ofFloatColor(.85, .85, .55) );
    pointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f));
    
    pointLight2.setDiffuseColor( ofFloatColor( 238.f/255.f, 57.f/255.f, 135.f/255.f ));
    pointLight2.setSpecularColor(ofFloatColor(.8f, .8f, .9f));
    
    pointLight3.setDiffuseColor( ofFloatColor(19.f/255.f,94.f/255.f,77.f/255.f) );
    pointLight3.setSpecularColor( ofFloatColor(18.f/255.f,150.f/255.f,135.f/255.f) );
    
    // shininess is a value between 0 - 128, 128 being the most shiny //
    material.setShininess( 120 );
    // the light highlight of the material //
    material.setSpecularColor(ofColor(255, 255, 255, 255));
}
Exemplo n.º 13
0
void ofApp::setup(){
    
    // General setup
    cam.setDistance(100);
    sphere.set(30, UV_SPHERE_RES);
    sphereBase.set(30, UV_SPHERE_RES);
    
    // Shaders
    phongShader.load("Shaders/Phong/Phong.vert", "Shaders/Phong/Phong.frag");
    toonShader.load("Shaders/Toon/Toon.vert", "Shaders/Toon/Toon.frag");
    depthOfField.setup(ofGetWidth(), ofGetHeight());
    
    // icosphere
    icoSphere.set(30, 4);
    icoSphereBase.set(30, 4);
    
    // Lights
    ofSetSmoothLighting(true);
    spotLight.setDiffuseColor( ofColor(250.f, 250.f, 250.f));
    spotLight.setSpecularColor( ofColor(255.f, 255.f, 255.f));
    spotLight.setSpotlight();
    // angle range between 0 - 90 in degrees
    spotLight.setSpotlightCutOff( 50 );
    // range 0 - 128, zero is even illumination, 128 is max falloff
    spotLight.setSpotConcentration( 45 );
    
    // Material
    // 0 - 128
    material.setShininess( 30 );
    material.setSpecularColor(ofColor(255, 255, 255, 255));
    ofDisableArbTex();
    
    // FFT
    audioMirror = false;
    fftLive.setMirrorData(audioMirror);
    fftLive.setup();
    fftLive.soundStream->start();
    numLevels = 4;
    levels.assign(numLevels, 0.0);
    
    // GUI
    isGuiVisible = true;
    gui.setup();
    
    noiseParams.setName("noise");
    noiseParams.add(isNoiseAnimated.set("animated", false));
    noiseParams.add(noiseIn.set("input", ofVec3f(0), ofVec3f(-100), ofVec3f(100)));
    noiseParams.add(noiseInDiv.set("divide in", 500, 1, 1000));
    noiseParams.add(noiseOutMult.set("mult out", 10, 1, 100));
    noiseParams.add(isNoiseFromNormal.set("from normals", false));
    noiseParams.add(noiseVertMod.set("vert mod", 30, 1, 241));
    gui.add(noiseParams);
    
    dofParams.setName("DOF");
    dofParams.add(isDofEnabled.set("enabled", false));
    dofParams.add(focalDistance.set("focal distance", 23, 0, 150));
    dofParams.add(focalRange.set("focal range", 4, 0, 10));
    dofParams.add(blurAmount.set("blur amount", 0.7, 0, 3));
    gui.add(dofParams);
    
    sphereParams.setName("Sphere");
    sphereParams.add(isPhongShaderOn.set("phong shader", false));
    sphereParams.add(isToonShaderOn.set("toon shader", true));
    sphereParams.add(isIcoSphere.set("ico sphere", false));
    gui.add(sphereParams);
    
    lightParams.setName("Light");
    lightParams.add( globalAmbient.set("Global Ambient", ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    //lightParams.add( lightPosition.set("Light Position",   ofVec3f( 60, 60, 200 ), ofVec3f( -200, -200, -200), ofVec3f( 200, 200, 200)) );
    lightParams.add( lightDiffuse.set("Light Diffuse",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    lightParams.add( lightAmbient.set("Light Ambient",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    lightParams.add( lightSpecular.set("Light Specular", ofColor(255,255,255), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    gui.add(lightParams);
    
    matParams.setName("Mat");
    matParams.add( matDiffuse.set("Mat Diffuse",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    matParams.add( matAmbient.set("Mat Ambient",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    matParams.add( matEmissive.set("Mat Emissive", ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    matParams.add( matSpecular.set("Mat Specular", ofColor(255,255,255), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    matParams.add( matShiny.set("Mat Shiny", 30, 1, 128));
    gui.add(matParams);
    
    bgParams.setName("BG");
    bgParams.add( bgColourIn.set("Colour In",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    bgParams.add( bgColourOut.set("Colour Out",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
    gui.add(bgParams);
    
    gui.minimizeAll();
    gui.loadFromFile("settings.xml");
}
Exemplo n.º 14
0
void ParticleManager::draw() {
	ofSetColor(255, 255, 255);
	//motionCVGrayscaleImage->draw(0, 0, ofGetWidth(), ofGetHeight());
	//glEnable( GL_BLEND );
	// Define the blend mode
	//glBlendFunc( GL_SRC_ALPHA, GL_ONE );
	
	//ofEnableAlphaBlending();
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//glClear(GL_COLOR_BUFFER_BIT);
	
	
	//glDisable(GL_DEPTH_TEST);
	glDepthMask(GL_FALSE);
	
	glEnable(GL_TEXTURE_2D);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	
	// bind tex coords
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[2]);
	glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, (NUM_PARTICLES*4)*2*sizeof(float), texcords);
	glTexCoordPointer(2, GL_FLOAT, 0, 0);
	
	
	// bind color
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[0]);
	glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, (NUM_PARTICLES*4)*4*sizeof(float), colors);
	glColorPointer(4, GL_FLOAT, 0, 0);
	
	
	// bind vertices [these are quads]
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[1]);
	glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, (NUM_PARTICLES*4)*3*sizeof(float), posQuads);
	glVertexPointer(3, GL_FLOAT, 0, 0);
	
	
	// draw the vbo
	//glDisable(GL_DEPTH_TEST);
	ofEnableArbTex();	
	
	
	texture.getTextureReference().bind();
	
	glDrawArrays(GL_QUADS, 0, NUM_PARTICLES * 4);
	
	texture.getTextureReference().unbind();
	//ofDisableAlphaBlending();
	
	ofDisableArbTex();
	//glEnable(GL_DEPTH_TEST);
	//glDisable( GL_BLEND );
	//glutSwapBuffers();
	glDepthMask(GL_TRUE);
	
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	
	glDisable(GL_TEXTURE_2D);
	
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
	
	
	ofSetColor(100, 100, 100);
	//ofDrawBitmapString(ofToString(mouseX, 0)+", "+ofToString(mouseY, 0), mouseX + 2, mouseY - 2);
	/*
	ofSetColor(255, 255, 255);
	for(int i = 0; i < NUM_PARTICLES; i++) {
		if (visibles[i]) {
			ofSetColor(0, 255, 0);
		} else {
			ofSetColor(255, 0, 0);
		}
		//ofSetColor(visibles[i] * 250, 255, colors[i] * 250);
		ofCircle(pos[i].x, pos[i].y, 5);
	}
	 */
	//for (int i = 0; i < NUM_PARTICLES; i++) {
	//	ofDrawBitmapString( ofToString(screenLocs[i * 3], 0) +", "+ofToString(screenLocs[i * 3 + 1], 0),
	//					   screenLocs[i * 3] + 2, screenLocs[i * 3 + 1] + 2);
	//}
}
Exemplo n.º 15
0
void ParticleManager::initiate( int $numParticles, float $minX, float $maxX, float $minY, float $maxY, float $minZ, float $maxZ ) {
	// panel is set by RenderCreatureScene in setPanel function //
	cout << "ParticleManager :: initiate : numParticles = " << $numParticles << endl;
	NUM_PARTICLES = $numParticles;
	
	ofDisableArbTex();
	texture.loadImage("particle.png");
	ofEnableArbTex();
	//texture.setImageType(OF_IMAGE_COLOR_ALPHA);
	
	texW = 30;
	texH = texW;
	
	float r, g, b, a;
	r = g = b = a = 1.f;
	r = 1.f;
	g = 1.f;
	b = 1;
	a = 1.f;
	
	pos			= new PVert[NUM_PARTICLES];
	posQuads	= new PVert[NUM_PARTICLES * 4];
	dim			= new float[NUM_PARTICLES];
	texcords	= new PTexture[NUM_PARTICLES * 4];
	colors		= new PColor[NUM_PARTICLES * 4];
	screenLocs	= new double[NUM_PARTICLES * 3];
	
	visibles = new bool[NUM_PARTICLES];
	
	float px, py, pz;
	for (int i = 0; i < NUM_PARTICLES; i++) {
		
		//pt.x = 200.f;
		px = ofRandom($minX, $maxX);
		py = ofRandom($minY, $maxY);
		pz = ofRandom($minZ, $maxZ);
		
		//px = ofRandom(0, ofGetWidth());
		//py = ofRandom(0, ofGetHeight());
		//pz = ofRandom(0, 1);
		
		//px = 100;
		//py = 100;
		//pz = 0;
		
		dim[i] = texW * ofRandom(.5, 1.f);
		
		setParticleColor( i, r, g, b, a);
		
		pos[i].x = px;
		pos[i].y = py;
		pos[i].z = pz;
		
		setParticlePosition( i, px, py, pz, dim[i]);
		
		// P1
		texcords[(i*4)+0].u = 0;//(cellWidth * row)		/ texW;
		texcords[(i*4)+0].v = 0;//(cellHeight * col)	/ texH;
		
		// P2
		texcords[(i*4)+1].u = .9;//((cellWidth * row)	+ cellWidth)	/ texW;
		texcords[(i*4)+1].v = 0;//(cellHeight * col)	/ texH;
		
		// P2
		texcords[(i*4)+2].u = .9;//((cellWidth * row) + cellWidth)		/ texW;
		texcords[(i*4)+2].v = .9;//((cellHeight * col) + cellHeight)	/ texH;	
		
		// P2
		texcords[(i*4)+3].u = 0;//(cellWidth * row)		/ texW;
		texcords[(i*4)+3].v = .9;//((cellHeight * col)+cellHeight)	/ texH;	
		
		
		
	}
	
	glGenBuffersARB(3, &particleVBO[0]);
	
	// color
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[0]);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, (NUM_PARTICLES*4)*4*sizeof(float), colors, GL_STREAM_DRAW_ARB);
	
	// vertices
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[1]);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, (NUM_PARTICLES*4)*3*sizeof(float), posQuads, GL_STREAM_DRAW_ARB);
	
	// texture coords
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, particleVBO[2]);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, (NUM_PARTICLES*4)*2*sizeof(float), texcords, GL_STREAM_DRAW_ARB);
	
	
}
// selfSetup is called when the visual system is first instantiated
// This will be called during a "loading" screen, so any big images or
// geometry should be loaded here
void CloudsVisualSystemFireworks::selfSetup()
{
	//defaults
	bAnimateCamera = true;
	minLifeSpan = .5;
	maxLifeSpan = 1.5;
	
	minExplosionTime = .75;
	maxExplosionTime = 1.25;
	
	speed = .25;
	explosionFrequencey = .1;
	emissonRate = 2;
	particleSpread = 10;
	particleSize = 10;
	spawnDistance = 250;
	
	camSpeed = .7;
	cameraMotionScl = .25;
	
	gravity.set( 0, 0, 0);
	
	minVel = .75;
	maxVel = 1.25;
	
	maxFWVel = 200;
	
	fogDistance = 800;
	fogAttenuation = 1;
	fogColor.set(0,1,0,1);
	
	bUseCircle = bUseSquare = bUseTriangle = bUseDot = true;
	
	bBurst = bOctahedron = bTetrahedron = bDodecagedron = true;
	
	startColorSaturation = endColorSaturation = fogSaturation = 1;
	
	for (int i=0; i<3; i++) {
		string key = "C" + ofToString(i) + "_birth";
		fwColors[key];
		fwSaturations[key];
		
		key = "C" + ofToString(i) + "_death";
		fwDeathColors[key];
		fwDeathSaturations[key];
	}
	
	//setupParticles
	FIREWORKS_NUM_PARTICLES = 200000;
	
	//positions = new ofVec3f[ FIREWORKS_NUM_PARTICLES ];
	//velocities = new ofVec3f[ FIREWORKS_NUM_PARTICLES ];
	//lifeData = new ofFloatColor[ FIREWORKS_NUM_PARTICLES ];
	//indices = new ofIndexType[ FIREWORKS_NUM_PARTICLES ];
	positions.resize( FIREWORKS_NUM_PARTICLES );
	velocities.resize( FIREWORKS_NUM_PARTICLES );
	lifeData.resize( FIREWORKS_NUM_PARTICLES );
	indices.resize( FIREWORKS_NUM_PARTICLES );
	
	float lifespan;
	float t = ofGetElapsedTimef();
	
	vbo.setVertexData( &positions[0], FIREWORKS_NUM_PARTICLES, GL_DYNAMIC_DRAW );
	vbo.setNormalData( &velocities[0], FIREWORKS_NUM_PARTICLES, GL_DYNAMIC_DRAW );
	vbo.setIndexData( &indices[0], FIREWORKS_NUM_PARTICLES, GL_DYNAMIC_DRAW );
	
	
	vbo.setColorData( &lifeData[0], FIREWORKS_NUM_PARTICLES, GL_DYNAMIC_DRAW );
	
	//TODO: mention to james that we might need a getCloudsData method
	colorSampleImage.loadImage( GetCloudsDataPath() + "colors/defaultColorPalette.png" );
	
	loadFileToGeometry( getVisualSystemDataPath() +  "animationTargets/dodecahedron.txt", dodecagedronPoints );
	loadFileToGeometry( getVisualSystemDataPath() +  "animationTargets/octahedron.txt", octahedronPoints );
	loadFileToGeometry( getVisualSystemDataPath() +  "animationTargets/tetrahedron.txt", tetrahedronPoints );
	loadFileToGeometry( getVisualSystemDataPath() + "animationTargets/icosahedron.txt", icosahedronPoints );
	
	//shader
	shader.load(getVisualSystemDataPath() + "shaders/base.vert", getVisualSystemDataPath() + "shaders/base.frag");
	
	shader.begin();
	shader.setUniform3f( "gravity", gravity.x, gravity.y, gravity.z );
	shader.end();
	startColor.set( .9, .95, 1.95, 1 );
	endColor.set( .6, 1.3, .2, 1 );
	
	spriteImage.loadImage(getVisualSystemDataPath() + "images/sphereNormal.png");
		
	//particle rendering
	bUpdateVbo = true;
	indexCount = 0;
	nextIndex = 0;
	numSprites = 0;
	
	nextFireworkExplosionTime = ofGetElapsedTimef() + 1;
	
	
	
	ofDisableArbTex();
	
	dotImage.loadImage(  getVisualSystemDataPath() + "images/sphereNormal.png" );
	triangleImage.loadImage(  getVisualSystemDataPath() + "images/triangle-sprite.png" );
	squareImage.loadImage(  getVisualSystemDataPath() + "images/square-sprite.png" );
	circleImage.loadImage(  getVisualSystemDataPath() + "images/circle-sprite.png" );
	
	ofEnableArbTex();
	
	getCameraRef().setPosition(0, 0, 0);
	camTarget.set( 0,0,spawnDistance);
	
    //MA: changed ofGetWidth() to getCanvasWidth() and ofGetHeight() to getCanvasHeight()
//	glowFbo0.allocate( getCanvasWidth(), getCanvasHeight(), GL_RGB );
//	glowFbo1.allocate( glowFbo0.getWidth()/2, glowFbo0.getHeight()/2, GL_RGB );;
//	glowFbo2.allocate( glowFbo1.getWidth()/2, glowFbo1.getHeight()/2, GL_RGB );;
//	glowFbo3.allocate( glowFbo2.getWidth()/2, glowFbo2.getHeight()/2, GL_RGB );;
//	glowFbo4.allocate( glowFbo3.getWidth()/2, glowFbo3.getHeight()/2, GL_RGB );;
//	glowFbo5.allocate( glowFbo4.getWidth()/2, glowFbo4.getHeight()/2, GL_RGB );;
//	glowFbo6.allocate( glowFbo5.getWidth()/2, glowFbo5.getHeight()/2, GL_RGB );;
	
	glowShader.load(getVisualSystemDataPath() + "shaders/post");
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void ofApp::setup() {
    ofSetFrameRate(60);

    scene = bind(&ofApp::renderScene, this);

    gui.setup();

    ofDisableArbTex();
    pbr.setup(1024);
    ofxPBRFiles::getInstance()->setup("ofxPBRAssets");
    pbrHelper.setup(&pbr, ofxPBRFiles::getInstance()->getPath() + "/settings", true);
    pbrHelper.addLight(&pbrLight1, "light1");
    pbrHelper.addMaterial(&jointMaterial, "joint");
    pbrHelper.addMaterial(&material1, "material1");
    pbrHelper.addMaterial(&floorMaterial, "floor");
    pbrHelper.addCubeMap(&cubemap, "cubeMap1");

    particlesShader.load("shaders/particles");
    postEffect.load("shaders/tonemap");

    resizeFbos();

    cam.setupPerspective(false, 60, 1, 12000);

    float * position = new float[numParticles * 3];
    for (int i = 0; i < numParticles; i++) {
        position[i * 3 + 0] = ofRandom(-1, 1);
        position[i * 3 + 1] = ofRandom(-1, 1);
        position[i * 3 + 2] = ofRandom(-1, 1);
    }

    float * velocity = new float[numParticles * 3];
    for (int i = 0; i < numParticles; i++) {
        velocity[i * 3 + 0] = ofRandom(-1, 1);
        velocity[i * 3 + 1] = ofRandom(-1, 1);
        velocity[i * 3 + 2] = ofRandom(-1, 1);
    }

    float * age = new float[numParticles];
    for (int i = 0; i < numParticles; i++) {
        age[i] = 0;
    }

    float * lifetime = new float[numParticles];
    for (int i = 0; i < numParticles; i++) {
        lifetime[i] = 1;
    }

    tf.setup(numParticles, "shaders/tf.vert");
    tf.addBufferObject("inPosition", "outPosition", 3, GL_RGB32F, position);
    tf.addBufferObject("inVelocity", "outVelocity", 3, GL_RGB32F, velocity);
    tf.addBufferObject("inAge", "outAge", 1, GL_R32F, age);
    tf.addBufferObject("inLifetime", "outLifetime", 1, GL_R32F, lifetime);
    tf.generate();

    fileName = "05_05.bvh";
    bvh.load(fileName);
    bvh.setLoop(true);
    bvh.play();

    ofBoxPrimitive box;
    box.set(1, 1, 1, 1, 1, 1);
    mesh = box.getMesh();

    setupJoints();
}
Exemplo n.º 18
0
//--------------------------------------------------------------
void testApp::setup(){

	ofSetDataPathRoot("../Resources/");
	ofDisableArbTex();
	ofEnableAlphaBlending();
	ofEnableSmoothing();
	ofBackground(255, 255, 255);
	
	
//	defaultShader.setup("default");
//	showDepthShader.setup("showdepth");
	ssaoShader.load("ssao");	
	dofShader.load("dof");
	
	depthFBO.setup(ofGetWidth(), ofGetHeight());
	colorFBO.setup(ofGetWidth(), ofGetHeight());
	ssaoFBO.setup(ofGetWidth(), ofGetHeight());
	
	ofSetSphereResolution(100);
	numObj = 200;
	for (int i = 0; i < numObj; i++) {
		float x = ofRandom(ofGetWidth()/2-200, ofGetWidth()/2+200);
		float y = ofRandom(ofGetHeight()/2-200, ofGetHeight()/2+200);
		float z = ofRandom(-100, 500);
		ofVec3f pos = ofVec3f(x,y,z);
		float r = ofRandom(0.0, 255.0);
		float g = ofRandom(0.0, 255.0);
		float b = ofRandom(0.0, 255.0);
		float a = ofRandom(200.0, 255.0);
		ofVec4f col = ofVec4f(r,g,b,a);
		int size = ofRandom(10, 50);
		ofQuaternion qua = ofQuaternion(ofRandomf(), ofRandomf(), ofRandomf(), ofRandomf());
		int typ = ofRandom(1, 3);
		objPos.push_back(pos);
		objRot.push_back(qua);
		objCol.push_back(col);
		objSize.push_back(size);
		objType.push_back(typ);
	}		
	
	//.setNewColumn(true);
	gui.addTitle("SSAO Setting");
	gui.addSlider("camerarangex", camerarangex, 0, 10000);
	gui.addSlider("camerarangey", camerarangey, 0, 10000);
	gui.addSlider("aoCap", aoCap, 0.0, 2.0);
	gui.addSlider("aoMultiplier", aoMultiplier, 0.0, 20000.0);
	gui.addSlider("depthTolerance", depthTolerance, 0.000, 0.002);
	gui.addSlider("aorange", aorange, 0.0, 2.0);
	gui.addSlider("readDepthVal", readDepthVal, 0.0, 20.0);
	gui.addTitle("DOF Setting").setNewColumn(true);
	gui.addSlider("focus", focus, 0.0, 2.0);
	gui.addSlider("aspectratiox", aspectratiox, 0.0, ofGetWidth());
	gui.addSlider("aspectratioy", aspectratioy, 0.0, ofGetHeight());
	gui.addSlider("blurclamp", blurclamp, 0.0, 1.0);
	gui.addSlider("bias", bias, 0.0, 1.0);	
	gui.loadFromXML();
	gui.show();		
	camerarangex = 6113.28;
	camerarangey = 4121.09;
	aoCap = 1.8795;
	aoMultiplier = 1523.5625;
	depthTolerance = 0.0001130;
	aorange = 0.285156;
	readDepthVal = 2.0;
	focus = 0.808594;
	aspectratiox = ofGetWidth();
	aspectratioy = ofGetHeight();	
	blurclamp = 0.0253910;
	bias = 0.041016;
	
}
//--------------------------------------------------------------
void testApp::setup(){
	
	ofBackground(0, 0, 0);
	ofSetFrameRate(60);
	glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
	
	ofDisableArbTex();
    neheTexture.loadImage("images/crate.gif");
	
	shader.loadShader("shaders/shader");
	
	
    glGenBuffersARB(2, &vboId[0]);
    
	
    //GET ATTRIBUTE AND UNIFORMS
	shader.setShaderActive(true);
	
	locationID[VERTEX_POSITION_ATTRIBUTE] = glGetAttribLocationARB(shader.shader, "aVertexPosition");
	locationID[TEXTURE_COORD_ATTRIBUTE] = glGetAttribLocationARB(shader.shader, "aTextureCoord");
	locationID[VERTEX_NORMAL_ATTRIBUTE] = glGetAttribLocationARB(shader.shader, "aVertexNormal");
    glEnableVertexAttribArray(locationID[VERTEX_POSITION_ATTRIBUTE]);
	glEnableVertexAttribArray(locationID[TEXTURE_COORD_ATTRIBUTE]);
	glEnableVertexAttribArray(locationID[VERTEX_NORMAL_ATTRIBUTE]);
	locationID[P_MATRIX_UNIFORM] = glGetUniformLocationARB(shader.shader, "uPMatrix");
	locationID[MV_MATRIX_UNIFORM] = glGetUniformLocationARB(shader.shader, "uMVMatrix");
	locationID[NORMAL_MATRIX_UNIFORM] = glGetUniformLocationARB(shader.shader, "uNMatrix");
	
	
	
	shader.setUniformVariable1i((char*)"uUseLighting", use_lighting=!use_lighting);
	
	shader.setUniformVariable3f((char*)"uAmbientColor",ambient_red_value=0.2,ambient_green_value=0.2,ambient_blue_value=0.2);
	
	lightDirection.set(0.0,0.0,1.0);
	shader.setUniformVariable3f((char*)"uLightingDirection", lightDirection.x,lightDirection.y,lightDirection.z);
	
   	shader.setUniformVariable3f((char*)"uDirectionalColor", direct_red_value=0.8,direct_green_value=0.8,direct_blue_value=0.8);
	
	shader.setShaderActive(false);
	
   
	//SQUARE BUFFER 	
	glBindBuffer(GL_ARRAY_BUFFER, vboId[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertexPosition)+sizeof(cubeVertexTextureCoord)+sizeof(cubeVertexNormal), 0, GL_STATIC_DRAW);
	glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(cubeVertexPosition), cubeVertexPosition);                            
	glBufferSubData(GL_ARRAY_BUFFER, sizeof(cubeVertexPosition), sizeof(cubeVertexTextureCoord), cubeVertexTextureCoord);
	glBufferSubData(GL_ARRAY_BUFFER, sizeof(cubeVertexPosition)+sizeof(cubeVertexTextureCoord), sizeof(cubeVertexNormal), cubeVertexNormal);
	
	//INDEX BUFFERS
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId[1]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(cubeVertexIndices), cubeVertexIndices, GL_STATIC_DRAW);
	
	
	//SETUP ROTATION AND Z VARS
	z=-7;
	xSpeed=ySpeed=0;
	
	//KEYS
	of_key_backspace_pressed=false;
	of_key_page_up_pressed=false;
	of_key_page_down_pressed=false;
	of_key_left_pressed=false;
	of_key_right_pressed=false;
	of_key_up_pressed=false;
	of_key_down_pressed=false;
	
	verdana.loadFont("fonts/verdana.ttf",8, false, true);
	verdana.setLineHeight(14.0f);
	
	
	

	
}
void Dimentions::selfDraw(){
    
    if (!bDebug){
        ofEnableAlphaBlending();
        
        ofPushMatrix();
        ofPushStyle();
        materials["MATERIAL 1"]->begin();
        
        //  Labels
        //
        if(categoriesTintColor.a > 0.0 ){
            for(int i = 0; i < categories.size(); i++){
                ofSetColor(categoriesTintColor);
                drawBrakets(categories[i], 15, 10);
                
                categories[i].draw(bDebug);
            }
        }
        
        for (int i = 0; i < booksWithTags.size(); i++) {
            drawLabel( *booksWithTags[i], booksWithTags[i]->text );
        }
        
        if(categoriesNodesTintColor.a > 0.0){
            for(int i = 0; i < categories.size(); i++){
                for(int j = 0; j < categories[i].nodes.size(); j++){
                    ofPushMatrix();
                    ofTranslate(categories[i].nodes[j]->x,
                                categories[i].nodes[j]->y,
                                categories[i].nodes[j]->z);
                    ofSetColor(categoriesNodesTintColor);
                    float scale = 0.4;
                    ofScale(scale,scale,scale);
                    //orientBillBoard();
                    ofRectangle box = font.getStringBoundingBox(categories[i].nodesText[j], 0, 0);
                    font.drawStringAsShapes(categories[i].nodesText[j], -box.width*0.5,0);
                    ofPopMatrix();
                }
            }
        }
    
        
        {
            ofSetColor(255);
            ofDisableArbTex();
            glDepthMask(GL_FALSE);
            glEnable(GL_NORMALIZE);
            ofEnablePointSprites();
            
            spriteShader.begin();
            spriteTexture.bind();
            
            spriteShader.setUniformTexture("tex", spriteTexture, 0);
            spriteShader.setUniform1f("nearClip", getCameraRef().getNearClip());
            spriteShader.setUniform1f("farClip", getCameraRef().getFarClip());
            spriteShader.setUniform1f("size",spriteSize);
            spriteShader.setUniform1f("minPointSize", 1.0);//spriteSizeMin);
            spriteShader.setUniform1f("maxPointSize", spriteSizeMax);
            spriteShader.setUniform1f("focusDistance", spriteFocusDistance);
            spriteShader.setUniform1f("focusAperture", spriteFocusAperture*0.01);
            
            spriteVBO.draw(GL_POINTS, 0, TOTAL_OF_BOOKS );
            
            spriteTexture.unbind();
            spriteShader.end();
            
            ofDisablePointSprites();
            glDisable(GL_NORMALIZE);
            glDepthMask(GL_TRUE);
            ofEnableArbTex();
        }

        materials["MATERIAL 1"]->end();
        ofPopStyle();
        ofPopMatrix();
    }
}
void Dimentions::selfSetup(){
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    
    font.loadFont("GUI/NewMedia Fett.ttf", 14, false, false, true);

    spriteShader.load(getDataPath()+"shaders/sprites");
    ofDisableArbTex();
    ofLoadImage( spriteTexture , getDataPath()+"images/square-sprite.png");
    ofEnableArbTex();
    
    mapImage.loadImage(getDataPath()+"images/map.jpg");
    colorSampleImage.loadImage("GUI/defaultColorPalette.png");
    
    
    //  Categories
    //
    categories.clear();
    for (int i = 0; i < 13; i++) {
        Category cat;
        cat.loadSettings(i,getDataPath()+"categories.xml");
        cat.font = &font;
        cat.color.a = 0.0;
        cat.borderColor.a = 0.0;
        
        //  Add the nodes to our subjects list ( subcategories )
        //
        for(int j = 0; j < cat.nodes.size(); j++){
            subjects.push_back(cat.nodes[j]);
        }
        
        categories.push_back(cat);
    }
    
    debugTranslation = 0.5;
    debugScale = 1.25;
    float networkRadio = 500;
    
    //  Books
    //
    globalOffset.set(0,0,0);
    
    TOTAL_OF_BOOKS = 50000;
    for(int i = 0; i < TOTAL_OF_BOOKS; i++){
        BookParticle *p = new BookParticle();
        p->init( ofPoint(ofRandom(-10,10),ofRandom(-10,10), -500), ofPoint(ofRandom(-0.1,0.1),ofRandom(-0.1,0.1),0.0) );
        p->destiny = ofPoint(0,0,0);
        p->color.set(ofRandom(0.5,1.0));
        
        ofQuaternion xRot,yRot;
        xRot.makeRotate(ofRandom(-180,180), 1, 0, 0);
        yRot.makeRotate(ofRandom(-180,180), 0, 1, 0);
        p->networkPos = xRot * yRot * ofPoint(0,0,ofRandom(-networkRadio,networkRadio) );
        
        p->text = ofToString(i);
        books.push_back(p);
    }
       
    assignDataToBooks();
    
    //  Devide the particles in 4 subgroups
    //
    updateIndexMap.clear();
    int numberOfSubgroups = 4;
    int jump = books.size()/4;
    for( int i = 0; i < numberOfSubgroups ; i++ ){
        vector<int> beginEnd;
        beginEnd.push_back(i*jump);
        beginEnd.push_back((i+1)*jump);
        updateIndexMap.push_back( beginEnd );
    }
    
    updateIndex = 0.0;
    updateCycle = true;

    //  Setup VBO for fast rendering
    //
    spritePositions = new ofVec3f[ TOTAL_OF_BOOKS ];
    spriteColors    = new ofFloatColor[ TOTAL_OF_BOOKS ];
    spriteVBO.setVertexData( &spritePositions[0], TOTAL_OF_BOOKS, GL_DYNAMIC_DRAW );
    spriteVBO.setColorData( &spriteColors[0], TOTAL_OF_BOOKS, GL_DYNAMIC_DRAW );
    
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void PartyCLApp::setup()
{
    ofBackground(ofColor::black);
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(false);
    ofDisableArbTex();

    // Load presets.
    presets.push_back(Preset(0.016f, 1.54f, 8.0f, 0.1f, 1.0f));
    presets.push_back(Preset(0.016f, 1.54f, 8.0f, 0.1f, 1.0f));
    presets.push_back(Preset(0.016f, 0.68f, 20.0f, 0.1f, 1.0f));
    presets.push_back(Preset(0.0006f, 0.16f, 1000.0f, 1.0f, 1.0f));
    presets.push_back(Preset(0.0006f, 0.16f, 1000.0f, 1.0f, 1.0f));
    presets.push_back(Preset(0.0019f, 0.32f, 276.0f, 1.0f, 1.0f));
    presets.push_back(Preset(0.0016f, 0.32f, 272.0f, 0.145f, 1.0f));
    presets.push_back(Preset(0.016f, 6.04f, 0.0f, 1.0f, 1.0f));

    params.setName("PartyCL");
    params.add(bPaused.set("paused", false));
    params.add(bReset.set("reset", false));
    params.add(timestep.set("timestep", 0.016, 0.0, 1.0));
    params.add(clusterScale.set("cluster scale", 1.54, 0.0, 10.0));
    params.add(velocityScale.set("velocity scale", 8.0, 4.0, 1000.0));
    params.add(softening.set("softening factor", 0.1, 0.001, 1.0));
    params.add(damping.set("velocity damping", 1.0, 0.5, 1.0));
    params.add(pointSize.set("point size", 16.0f, 1.0f, 64.0f));
    params.add(bExportFrames.set("export frames", false));
    ofAddListener(params.parameterChangedE(), this, &PartyCLApp::paramsChanged);

    camera.setDistance(32.0f);

    // Set Gui.
    guiPanel.setup(params, "partycl.xml");
    guiPanel.loadFromFile("partycl.xml");

    bGuiVisible = true;

    // Load the first preset.
    presetIndex = 0;
    loadPreset();

#ifdef LOAD_TIPSY
    filename = "galaxy_20K.bin";
#else
    filename = "";
#endif

    if (filename.length()) {
        // Clear host memory.
        hPos.clear();
        hVel.clear();
        hColor.clear();

        // Load the data file.
        int numDark;
        int numStar;
        vector<int> hIDs;
        ofxLoadTipsyFile(filename, numBodies, numDark, numStar, hPos, hVel, hIDs);
    }
    else {
        // Set the number of bodies and configure appropriately.
        numBodies = 1024 * 12;

        // Allocate host memory.
        hPos.resize(numBodies);
        hVel.resize(numBodies);
        hColor.resize(numBodies);
    }

    ofLogNotice("PartyCLApp", "Number of Bodies = %d", numBodies);

    switch (numBodies)
    {
    case 1024:
        clusterScale = 1.52f;
        velocityScale = 2.f;
        break;

    case 2048:
        clusterScale = 1.56f;
        velocityScale = 2.64f;
        break;

    case 4096:
        clusterScale = 1.68f;
        velocityScale = 2.98f;
        break;

    case 8192:
        clusterScale = 1.98f;
        velocityScale = 2.9f;
        break;

    default:
    case 16384:
        clusterScale = 1.54f;
        velocityScale = 8.f;
        break;

    case 32768:
        clusterScale = 1.44f;
        velocityScale = 11.f;
        break;
    }

    int p = 256;  // workgroup X dimension
    int q = 1;    // workgroup Y dimension

    if ((q * p) > 256) {
        p = 256 / q;
        ofLogNotice("PartyCLApp::setup", "Setting p=%d to maintain %d threads per block", p, 256);
    }

    if ((q == 1) && (numBodies < p)) {
        p = numBodies;
        ofLogNotice("PartyCLApp::setup", "Setting p=%d because # of bodies < p", p);
    }
    ofLogNotice("PartyCLApp::setup", "Workgroup Dims = (%d x %d)", p, q);

    // Init system.
#ifdef USE_OPENCL
    system = new NBodySystemOpenCL(numBodies, p, q);
#else
    system = new NBodySystemCPU(numBodies);
#endif

    // Init renderer.
    renderer = new ParticleRenderer();
    displayMode = ParticleRenderer::PARTICLE_SPRITES;

    // Start the show.
    bPaused = false;
    bReset = true;
}
Exemplo n.º 23
0
//--------------------------------------------------------------
void testApp::draw(){
	
	updateParticleSystem();
	updatePerlinLuminosity();

	renderTarget.begin();
	ofClear(0,0,0,255);
	cam.begin(ofRectangle(0,0,renderTarget.getWidth(), renderTarget.getHeight()));
			
    if(player.isLoaded()){
		drawGeometry();
	}

	ofPushMatrix();
//	ofScale(1,-1,1);
	ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset"));
	glEnable(GL_DEPTH_TEST);
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	
	ofSetColor(0);
	ofPushMatrix();
	ofScale(1, -1, 1);
	meshBuilder.getMesh().disableColors();
	meshBuilder.getMesh().draw();
	meshBuilder.getMesh().enableColors();
	ofPopMatrix();
	ofSetColor(255);
	
	ambientShader.begin();
	ofEnablePointSprites();
	ofDisableArbTex();
	crossSprite.getTextureReference().bind();
	
	ambientShader.setUniform1f("maxDisance", particleMaxDistance) ;
	ambientShader.setUniform1f("maxSize", particeMaxSize) ;

	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	ofPushStyle();
	glPointSize(3.0);
	ofSetColor(particleFade*255);
	ambientParticles.drawVertices();
	ofPopStyle();
	ambientShader.end();

	crossSprite.getTextureReference().unbind();
	
	glDisable(GL_DEPTH_TEST);
	ofDisablePointSprites();
	ofEnableArbTex();

	ofPopMatrix();
	
//	randomUnits.drawVertices();
//	clusters.drawVertices();

	cam.end();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	ofPushStyle();
	ofSetColor(0);
	ofRect(fboRect);
	ofPopStyle();

	
	renderTarget.getTextureReference().draw(fboRect.x,fboRect.getBottom(),fboRect.width,-fboRect.height);
	
	if(rendering){

		saveImage.setUseTexture(false);
		renderTarget.readToPixels(saveImage.getPixelsRef());
		saveImage.mirror(true, false);
		char filename[1024];
		sprintf(filename, "%sframe_%05d.png",renderFolder.c_str(), currentFrameNumber);
		saveImage.saveImage(filename);
		currentFrameNumber++;
		
	}
	timeline.draw();
    gui.draw();
}
Exemplo n.º 24
0
//--------------------------------------------------------------
void testApp::setup(){
	ofDisableArbTex();
	ofSetTextureWrap();
	//configure FBO
	initFrameBuffer();
	
	//camera config
#ifdef KINECT
	
	context.setupUsingXMLFile();
	image.setup(&context);
	depth.setup(&context);
	xn::DepthGenerator& depthGen = depth.getXnDepthGenerator();
	xn::ImageGenerator& imageGen = image.getXnImageGenerator();
	
	
	XnStatus ret = xnSetViewPoint(depthGen, imageGen);
	cout << "Using kinect" << endl;

#else
	//ofSetLogLevel(OF_LOG_VERBOSE);
	//grabber.listDevices();
	//grabber.setDeviceID(7);
	if(grabber.initGrabber(640, 480)){
		
	
		cout << "Using grabber" << endl;
		
	} else {
		cout << "MASSIVE FAIL" <<endl;
		
	}
	
#endif
	
	
	convert.allocate(640, 480);				//conversion of camera image to grayscale
	gray.allocate(640, 480);				//grayscale tracking image
	kinectImage.allocate(640, 480);			//image from kinect
	kinectDepthImage.allocate(640, 480);	//Depth image from kinect
	finalMaskImage.allocate(640, 480);;		//final composition mask
	sceneDepthImage.allocate(640, 480);;	//scenes depthmap image
	finalImage.allocate(640, 480);
	sceneImage.allocate(640,480);
	
	pixelBuf = new unsigned char[640*480];			//temp buffer for kinect depth strea
	colorPixelBuf = new unsigned char[640*480*3];	//temp buffer for kinect image
	sceneDepthBuf = new unsigned short[640 * 480];	//depth buffer from our rendered scene
	kinectDepthBuf = new unsigned short[640 * 480];	//camera image buffer
	finalBuf = new unsigned char[640 * 480];		//final mask buffer
	finalImageBuf = new unsigned char[640 * 480 * 3];	//final Image buffer
	sceneBuffer = new unsigned char[640 * 480 * 3];		//copy of the scene in the FBO	
	
	bDraw = false;
	
	//tracker = new ARToolKitPlus::TrackerSingleMarkerImpl<6,6,6, 1, 8>(width,height);
	tracker = new ARToolKitPlus::TrackerMultiMarkerImpl<6,6,6, 1, 64>(width,height);
	
	tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM);	
	//markerboard_480-499.cfg
    if( !tracker->init( (const char *)ofToDataPath("bluedot.cfg").c_str(), (const char *)ofToDataPath("conf.cfg").c_str(), 1.0f, 1000.0f) )            // load std. ARToolKit camera file
	{
		printf("ERROR: init() failed\n");
		delete tracker;
		return;
	}
	// the marker in the BCH test image has a thin border...
    tracker->setBorderWidth(0.125f);	
    // set a threshold. alternatively we could also activate automatic thresholding
    //tracker->setThreshold(150);	
	tracker->activateAutoThreshold(true);
    // let's use lookup-table undistortion for high-speed
    // note: LUT only works with images up to 1024x1024
    tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);
	
    // RPP is more robust than ARToolKit's standard pose estimator
    tracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP);
	
	tracker->setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES);
	
    // switch to simple ID based markers
    // use the tool in tools/IdPatGen to generate markers
    tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_SIMPLE);
	
	
	netThread = new NetworkThread(this);
	netThread->start();
	
	//load textures
	ofDisableArbTex();
	ofSetTextureWrap();
	textures[0].loadImage("grass.png");
	textures[1].loadImage("cobble.png");	
	textures[2].loadImage("dirt.png");	
	textures[3].loadImage("lava.png");	
	textures[4].loadImage("rock.png");	
	textures[5].loadImage("sand.png");	
	textures[6].loadImage("snow.png");	
	textures[7].loadImage("tree.png");
	textures[8].loadImage("leaves.png");
	
	
	mapWidth = 20;
	mapHeight = 20;
	mapDepth = 20;
	mapLocked = false;
	
	//fill our 3d vector with 20x20x20
	mapLocked = true;
	array3D.resize(mapWidth);
	for (int i = 0; i < mapWidth; ++i) {
		array3D[i].resize(mapHeight);
		
		for (int j = 0; j < mapHeight; ++j)
			array3D[i][j].resize(mapDepth);
	}
	
	//create block face data and clear map 
	Block b;	
	
	vList[0] = ofxVec3f(0.0f, 0.0f, -1.0f);
	vList[1] = ofxVec3f(-1.0f, 0.0f, -1.0f);
	vList[2] = ofxVec3f(-1.0f, 0.0f, 0.0f);
	vList[3] = ofxVec3f(0.0f, 0.0f, 0.0f);
	vList[4] = ofxVec3f(-1.0f, -1.0f, 0.0f);
	vList[5] = ofxVec3f(0.0f, -1.0f, 0.0f);
	vList[6] = ofxVec3f(0.0f, -1.0f, -1.0f);
	vList[7] = ofxVec3f(-1.0f, -1.0f, -1.0f);
	
	//vertex indices for faces
	const static int faceVals[6][4] = {
		{2, 1, 0, 3}, //top
		{5, 4, 2, 3}, //front
		{0, 6, 5, 3},//right
		{4, 7, 1, 2},//left
		{5, 6, 7, 5},//bottom
		{0, 1, 7, 6} //back
	};
		
	
	for(int x=0; x < mapWidth; x++){
		for(int y=0; y < mapHeight; y++){
			for(int z=0; z < mapDepth; z++){
				b.type = NONE;
				b.textured = false;
				b.visMask = VIS_TOP;
				
				
				for(int a = 0; a < 6; a++){
					for (int c = 0; c < 4; c++){
						b.faceList[a][c] = faceVals[a][c];
					}
				}
				
				
				array3D[x][y][z] = b;		
				
			}
		}
	}
	
	//add some test blocks to play with when offline
	b.type = GRASS;
	b.textured = true;
	b.textureRef = 0;
	b.visMask = 63;
	array3D[1][1][5] = b;	
	array3D[2][1][5] = b;
	array3D[3][1][5] = b;
	array3D[4][1][5] = b;
	array3D[5][1][5] = b;
	array3D[6][1][5] = b;

	//testBlock = b;
	
	//run the face visibility and normal calculations
	updateVisibility();
	
	//dont draw the gui
	guiDraw = false;
	
	//scale and offset for map
	mapScale = 1.0f;
	offset.x = -100.0f;
	offset.y = 100.0f;
	
	scVal = 1.0f;
	
	//used as light colour (when lights eventually work)
	sceneWhiteLevel = ofColor(255,255,255);
	
	#ifdef SYPHON
	//start up syphon and set framerate
	mainOutputSyphonServer.setName("Minecraft");
	#endif
	
	ofSetFrameRate(60);
	
	//try and set up some lights
	
	light light = {
		{0,50,0,1},  //position (the final 1 means the light is positional)
		{1,1,1,1},    //diffuse
		{0,0,0,1},    //specular
		{0,0,0,1}     //ambient
    };
	
	light0 = light;
	
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	//glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0);  //sets lighting to one-sided
	glLightfv(GL_LIGHT0, GL_POSITION, light0.pos);
	doLights();
	
	
	//turn on backface culling
	glEnable(GL_CULL_FACE);
	
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void testApp::setup(){
    //general
    ofBackground(255);
    
    //switch scene
    scene_one = true;
    //kinect one image rotate parameters
    xangle = 25;
    yangle = -79;
    zangle = -14; //-14
    //kinect two image rotate parameters
    x2angle = 0;
    y2angle = 94;
    z2angle = 0;
    
    //roomRotate
    roomRotateX=270;
    roomRotateY=0;
    roomRotateZ=0;
    
    //3d model
    roomModel.loadModel("APR14.3ds");
    roomModel.setScale(50, 50, 50);
    roomModelPos.set(-90,-270,-930);
    showRoom = true;
    showTV = true;
    
    
    //tv model
    tv.loadModel("tv.3ds");
    tv.setScale(2, 2, 2);
    tv.setPosition(tv_x, tv_y, tv_z);
    tvScreen.loadMovie("tvScreen.gif");
    tvScreen.play();
    
    
    //whole scene position
    beginScnePositions();
    
    //kinect
    kinect.setRegistration();
    kinect.init();
    kinect.open();
    kinectImageScale = 0.3;
#ifdef USE_TWO_KINECTS
    kinect2.init();
    kinect2.open();
#endif
    
    //point cloud translation values:
    px = 170;
    py = 370;
    pz = -560;
    
    //point cloud 2 position values:
    p2x = -280;
    p2y = 400;
    p2z = -260;
    
    step = 10;
    
    //osculus rift
    oculusRift.baseCamera = &cam;
    oculusRift.setup();
    cam.enableMouseInput();
    cam.enableMouseMiddleButton();
    cam.begin();
    cam.end();
    
    //plane
    planeX = 768.f;
    planeY = 0.f;
    planeZ = 0.f;
    //GUI
    gui = new ofxUICanvas();
    //    gui->setTheme();
    gui->addFPS();
    gui->addSlider("Meditation_Level",0.0,100.0,100.0);
    gui->addSlider("background_color", 0.f, 255.f, 0.f);
    gui->addSlider("particle_Size", 0.1, 5.f, 2.f);
    float a = 4000.f;
    gui->addSlider("Whole_Scene_Position_x", -a, a, whole_scene_x);
    gui->addSlider("Whole_Scene_Position_y", -a, a, whole_scene_y);
    gui->addSlider("Whole_Scene_Position_z", -a, a, whole_scene_z);
    
    gui->addSlider("Whole_Scene_Rotate_x", 0.f, 360.f, scene_rx);
    gui->addSlider("Whole_Scene_Rotate_y", 0.f, 360.f, scene_ry);
    gui->addSlider("Whole_Scene_Rotate_z", 0.f, 360.f, scene_rz);
    
    gui->addSlider("whole_scene_scale", -0.01, 20, whole_scene_scale);
    gui->addSlider("PlaneX",-a,a,planeX);
    gui->addSlider("PlaneY",-a,a,planeY);
    gui->addSlider("PlaneZ",-a,a,planeZ);
    
    gui->addSlider("tv_x", -1000, 1000, tv_x);
    gui->addSlider("tv_y", -1000, 1000, tv_y);
    gui->addSlider("tv_z", -1000, 1000, tv_z);
    
    gui->addSlider("gif_x", -1000, 1000, image_x);
    gui->addSlider("gif_y", -1000, 1000, image_y);
    gui->addSlider("gif_z", -1000, 1000, image_z);
    gui->addSlider("gif_scale", -0.1, 1, 1);
    
    
    
    gui->addToggle("FULLSCREEN", false);
    //    gui->addLabel("Point Cloud A-rotate-x, y, z//potition:p(x), o(y), [](z)////Point Cloud B - rotate:j(x), k(y), l(z)//position:h(x), g(y),f(z)");
    gui->autoSizeToFitWidgets();
    ofAddListener(gui->newGUIEvent, this, &testApp::guiEvent);
    //osc
    meditationLevel = 100;
    receiver.setup(PORT);
    
    
    //sound
    bowlSound.loadSound("BOWL.mp3");
    bowlSound.setVolume(0);
    bowlSound.setMultiPlay(false);
    bowlSound.play();
    bowlSound.setLoop(true);
    bowlSoundSwitcher = false;
    
    spaceSound.loadSound("whitenoise.mp3");
    spaceSound.setVolume(0);
    spaceSound.play();
    spaceSound.setLoop(true);
    
    
    aqua.loadSound("Aqua_Syndrome_I.mp3");
    aqua.play();
    aqua.setLoop(true);
    
    
    //LIGHTING
    //ahahahahahahahahahahah
    
    
    
    resetPosition = true;
    
    //shader::
    if(ofGetGLProgrammableRenderer()){
		billboardShader.load("shadersGL3/Billboard");
	}else{
		billboardShader.load("shadersGL2/Billboard");
	}
    ofDisableArbTex();
    texture.loadImage("dot2.png");
    ofEnableAlphaBlending();
    particleSize = 4;
    
    
    //implementation
    blackScreen = true;
    cam.setFarClip(20000);
    
    //Timing:

    raising = true;
    
    //Ambient Cloud
    cloudField  = 3000;
    for (int i=0; i< 2000; i++) {
        cloud.push_back(ofVec3f(ofRandom(-cloudField,cloudField),ofRandom(-cloudField,cloudField),ofRandom(-cloudField,cloudField)));
    }
    
    
    
    //tv room
    tvroom.set(1800);
    tvroomMaterial.setShininess( 10 );
    tvroomMaterial.setDiffuseColor(ofColor(0,0,0));
	tvroomMaterial.setSpecularColor(ofColor(200, 200, 200, 255));
    
    tvCloseUp = false;
    roomCloseUp = false;
    roomFarShot = false;
    
}
Exemplo n.º 26
0
//--------------------------------------------------------------
void testApp::setup(){
    
    state=0;
    ofSetFrameRate(60);
    ofDisableArbTex();
	ofEnableDepthTest();
    ofBackground(31);
    ofEnableLighting();
    light.setPosition(200, 300, 50);
    light.enable();
    //--------------------------------Load Video Clips ------------------------
    pathlist[0]="movies/1.mov";
    pathlist[1]="movies/2.mov";
    pathlist[2]="movies/3.mov";
    pathlist[3]="movies/1.mov";
    pathlist[4]="movies/2.mov";
    pathlist[5]="movies/3.mov";
    pathlist[6]="movies/1.mov";
    pathlist[7]="movies/2.mov";
    pathlist[8]="movies/3.mov";
    pathlist[9]="movies/1.mov";
    pathlist[10]="movies/2.mov";
    pathlist[11]="movies/3.mov";
    pathlist[12]="movies/1.mov";
    pathlist[13]="movies/2.mov";
    pathlist[14]="movies/3.mov";
    pathlist[15]="movies/1.mov";
    myvideo = new ofmyvideo*[numbofvideo];
    cv=0;//count = 0;
    
    //------------------------------- Load 3D Models --------------------------
    model1.loadModel("3dmodel/leaf.obj");
    model2.loadModel("3dmodel/leaf.obj");
    model3.loadModel("3dmodel/leaf.obj");
    model4.loadModel("3dmodel/leaf.obj");
    model5.loadModel("3dmodel/leaf.obj");
    model6.loadModel("3dmodel/leaf.obj");
    model7.loadModel("3dmodel/leaf.obj");
    model8.loadModel("3dmodel/leaf.obj");
    model9.loadModel("3dmodel/leaf.obj");
    model10.loadModel("3dmodel/leaf.obj");
    lotus.loadModel("3dmodel/lotus.obj");
    circle.loadModel("3dmodel/circle.obj");
    model1.setPosition(ofGetWidth()*.5, ofGetHeight() * 0.05, 0);
    model2.setPosition(ofGetWidth()*.4, ofGetHeight() * 0.3, 2);
    model3.setPosition(ofGetWidth()*.3, ofGetHeight() * 0.05, 4);
    model4.setPosition(ofGetWidth()*.8, ofGetHeight() * 0.2, 2);
    model5.setPosition(ofGetWidth()*.2, ofGetHeight() * 0.1, 3);
    model6.setPosition(ofGetWidth()*.75, ofGetHeight() * 0.7, 2);
    model7.setPosition(ofGetWidth()*.5, ofGetHeight() * 0.8, 1);
    model8.setPosition(ofGetWidth()*.7, ofGetHeight() * 0.6, 3);
    model9.setPosition(ofGetWidth()*.55, ofGetHeight() * 0.1, 5);
    model10.setPosition(ofGetWidth()*.65, ofGetHeight() * 0.2, 2);
    lotus.setPosition(ofGetWidth()*.5, ofGetHeight() * 0.5, 0);
    circle.setPosition(ofGetWidth()*.5, ofGetHeight() * 0.5, 0);
    
    
    //----------------------------- TCP -----------------------------------------
    isConnected = tcpClient.setup("169.254.163.57", 14999);
    tcpClient.setMessageDelimiter("/r");
    
    connectTime = 0;
    deltaTime = 0;
    
    tcpClient.setVerbose(true);
    
    //---------------------------- Leap -----------------------------------------
    leap.open();
}
Exemplo n.º 27
0
//--------------------------------------------------------------
void testApp::draw(){
	
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	lineBlurTarget.begin();
	ofClear(0,0,0,0);
	ofPushStyle();
	
	cam.begin(ofRectangle(0,0,1920,1080));
	ofSetLineWidth(	lineThickness *2);
	ofSetColor(255);
	traversal.setMode(OF_PRIMITIVE_LINE_STRIP);
	traversal.draw();
	cam.end();
	
	ofPopStyle();
	lineBlurTarget.end();
	
	renderTarget.begin();
	ofClear(0,0,0,0);
	
	cam.begin(ofRectangle(0,0,1920,1080));
	ofPushStyle();

	ofSetColor(255);
	
	ofSetLineWidth(	timeline.getValue("line width") );
	lineAttenuate.begin();
	lineAttenuate.setUniform1f("focalPlane", powf(timeline.getValue("line focal dist"),2));
	lineAttenuate.setUniform1f("focalRange", powf(timeline.getValue("line focal range"),2));
	lineAttenuate.setUniform1f("lineFade", lineAlpha);
	lineAttenuate.setUniform3f("attractor", trailHead.x, trailHead.y, trailHead.z);
	lineAttenuate.setUniform1f("radius", 300.);
	
	geometry.setMode(OF_PRIMITIVE_LINE_STRIP);
	geometry.draw();
	
	lineAttenuate.end();
	
	traversal.setMode(OF_PRIMITIVE_LINE_STRIP);
	traversal.draw();

	//POINT SPRITES
	billboard.begin();
	ofEnablePointSprites();
	ofDisableArbTex();

	nodeSpriteBasic.getTextureReference().bind();
	ofSetColor(255*.5);
	
	//glPointSize(replicatePointSize);
	billboard.setUniform1f("minSize", replicatePointSize);
	billboard.setUniform3f("attractor", trailHead.x, trailHead.y, trailHead.z);
	billboard.setUniform1f("radius", 300.);
	
	nodeCloudPoints.drawVertices();
	nodeSpriteBasic.getTextureReference().unbind();

	//FUZZIES
//	glPointSize(pointSize);
//	ofSetColor(255*.15);
//	nodeRingSprite.getTextureReference().bind();
//	nodeCloudPoints.drawVertices();
//	nodeRingSprite.getTextureReference().unbind();
	
	//NODES
	nodeSprite.getTextureReference().bind();
	traversedNodePoints.drawVertices();
	nodeSprite.getTextureReference().unbind();
	
	billboard.end();
	ofDisablePointSprites();
	ofEnableArbTex();
	
	ofPopStyle();
	cam.end();
	
	//line blur
	gaussianBlur.begin();
	
	ofPushStyle();
	//ofSetColor(255 * lineBlurFade);
	ofSetColor(255*lineBlurFade);

	gaussianBlur.setUniform1i("tex", 0);
	gaussianBlur.setUniform2f("sampleOffset", lineBlurAmount, 0);
	lineBlurTarget.getTextureReference().draw(0, 0, 1920, 1080);
	
	gaussianBlur.setUniform2f("sampleOffset", 0, lineBlurAmount);
	lineBlurTarget.getTextureReference().draw(0, 0,1920, 1080);
	
	gaussianBlur.end();
	
	ofPopStyle();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	if(ofGetKeyPressed('=')){
		lineBlurTarget.draw(fboRect.getX(), fboRect.getMaxY(), fboRect.width,-fboRect.height);
	}
	else{
		renderTarget.draw(fboRect.getX(), fboRect.getMaxY(), fboRect.width,-fboRect.height);
	}
	
	if(rendering && timeline.getIsPlaying()){
		char fileName[1024];
		sprintf(fileName, "%sframe_%05d.png", renderFolder.c_str(), frameNum++);
		ofImage image;
		image.setUseTexture(false);
		renderTarget.readToPixels(image.getPixelsRef());
		image.mirror(true, false);
		image.saveImage(string(fileName));
	}
	
	timeline.draw();
	gui.draw();
}
Exemplo n.º 28
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetVerticalSync(true);
	ofSetFrameRate(60);
	ofBackground(10, 10, 10);
	ofEnableDepthTest();
    
    // turn on smooth lighting //
    bSmoothLighting     = true;
    ofSetSmoothLighting(true);
    
    // lets make a high-res sphere //
    // default is 20 //
    ofSetSphereResolution(128);
	
    // radius of the sphere //
	radius		= 180.f;
	center.set(ofGetWidth()*.5, ofGetHeight()*.5, 0);
    
    // Point lights emit light in all directions //
    // set the diffuse color, color reflected from the light source //
    pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f));
    
    // specular color, the highlight/shininess color //
	pointLight.setSpecularColor( ofColor(255.f, 255.f, 0.f));
	pointLight.setPointLight();
    
    
	
    spotLight.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
	spotLight.setSpecularColor( ofColor(255.f, 255.f, 255.f));
    
    // turn the light into spotLight, emit a cone of light //
    spotLight.setSpotlight();
    
    // size of the cone of emitted light, angle between light axis and side of cone //
    // angle range between 0 - 90 in degrees //
    spotLight.setSpotlightCutOff( 50 );
    
    // rate of falloff, illumitation decreases as the angle from the cone axis increases //
    // range 0 - 128, zero is even illumination, 128 is max falloff //
    spotLight.setSpotConcentration( 45 );
    
	
    // Directional Lights emit light based on their orientation, regardless of their position //
	directionalLight.setDiffuseColor(ofColor(0.f, 0.f, 255.f));
	directionalLight.setSpecularColor(ofColor(255.f, 255.f, 255.f));
	directionalLight.setDirectional();
    
    // set the direction of the light
    // set it pointing from left to right -> //
	directionalLight.setOrientation( ofVec3f(0, 90, 0) );
    
	
	bShiny = true;
    // shininess is a value between 0 - 128, 128 being the most shiny //
	material.setShininess( 120 );
    // the light highlight of the material //
	material.setSpecularColor(ofColor(255, 255, 255, 255));
	
	bPointLight = bSpotLight = bDirLight = true;
    
    // tex coords for 3D objects in OF are from 0 -> 1, not 0 -> image.width
    // so we must disable the arb rectangle call to allow 0 -> 1
    ofDisableArbTex();
    // load an image to use as the texture //
    ofLogoImage.loadImage("of.png");
    bUseTexture = true;
}
Exemplo n.º 29
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetWindowShape(WIDTH, HEIGHT);
	ofSetWindowPosition((ofGetScreenWidth() - ofGetWidth()) / 2, (ofGetScreenHeight() - ofGetHeight()) / 2);
	ofSetFrameRate(60);
	ofDisableArbTex();
	//ofSetVerticalSync(true);

#ifdef SHIPPING
	ofLogToFile(ofVAArgsToString("logs/%s_log.txt", ofGetTimestampString("%Y-%m-%d-%H-%M-%S").c_str()));
	ofHideCursor();
	bDebugVisible = false;
	isFullscreen = true;
	switchScreenSize(isFullscreen);
#endif

	{
		ofLog(OF_LOG_NOTICE, "application start with resolution: %u x %u", ofGetWidth(), ofGetHeight());
	}
	
    {
		const string theme_path = "fonts/theme.xml";
		ofVec2f gui_pos;
		ofxGuiGroupRef gui;
		auto getNextPosition = [&]() -> ofVec2f { return gui->getPosition() + ofVec2f(gui->getWidth(), 0); };		

		mSettings.setName("settings");
		mSettings.add(gThreshold.set("threshold", 128.0f, 0.0f, 255.0f));

		mUniforms.setName("uniforms");
		mUniforms.add(uDeltaTime.set("uDeltaTime", 0.0f, 0.0f, 1.0f));
		mUniforms.add(uElapsedTime.set("uElapsedTime", ofGetElapsedTimef()));

		gui.reset(new ofxGuiGroup);
		loadGuiTheme(gui, theme_path);
		gui->setup("gui");
		gui->add(mSettings);
		gui->add(mUniforms);
		gui_pos = getNextPosition();
		mGui.push_back(gui);


		gui.reset(new ofxGuiGroup);
		loadGuiTheme(gui, theme_path);
		ofParameterGroup infos;
		infos.setName("hot key");
		infos.add(ofParameter<string>().set("ESC", "exit"));
		infos.add(ofParameter<string>().set("F1", "gui"));
		infos.add(ofParameter<string>().set("F5", "reload shaders"));
		infos.add(ofParameter<string>().set("F11", "fullscreen"));
		infos.add(ofParameter<string>().set("S", "save settings"));
		infos.add(ofParameter<string>().set("L", "load settings"));
		infos.setSerializable(false);
		gui->setup("info");
		gui->add(infos);
		gui->setPosition(gui_pos);
		gui_pos = getNextPosition();
		mGui.push_back(gui);


		for (auto& g : mGui)
		{
			g->loadFromFile(getGuiFilename(g));
			g->saveToFile(getGuiFilename(g));
		}
			
    }
	
	{
		ofXml xml;
		if (xml.load("settings/config.xml"))
		{
			spout_prefix = xml.getValue("spout_prefix");
			num_spout = xml.getValue<int>("num_spout");
			screen_width = xml.getValue<int>("screen_width");
			screen_height = xml.getValue<int>("screen_height");
			offset_width = xml.getValue<int>("offset_width");
			offset_height = xml.getValue<int>("offset_height");
			ofLog(OF_LOG_NOTICE, "get config setting:\nspout_prefix: %s\nnum_spout: %u\nscreen_width: %u\nscreen_height: %u\noffset_width: %u\noffset_height: %u", 
				spout_prefix, num_spout, screen_width, screen_height, offset_width, offset_height);
			if (num_spout > 0)
			{
				bundles.resize(num_spout);
				for (int i = 0; i < bundles.size(); i++)
				{
					string channel_name = ofVAArgsToString("%s_%u - Resolume Arena", spout_prefix.c_str(), i);
					printf("create spout receiver with channel name: %s\n", channel_name.c_str());
					bundles[i].receiver.init(channel_name);
				}
			}
		}
	}

	{
		ofFbo::Settings s;
		s.width = screen_width * num_spout;
		s.height = screen_height;
		s.useDepth = false;
		s.colorFormats.emplace_back(GL_RGBA);

		mFbo.reset(new ofFbo);
		mFbo->allocate(s);
	}
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    
    ofSetFrameRate(60);
    
    ofSetVerticalSync(true);
    ofEnableDepthTest();
    ofBackground(50, 50, 50, 0);
    //we need to call this for textures to work on models
       ofDisableArbTex();
    ofLoadImage(heightMap, "heightmap.png");
    normalFbo.allocate(ofGetWidth(), ofGetHeight());
      ofEnableArbTex();
    
    normalShader.load("","normal.frag");
    terrainShader.load("terrain");
    
 
    
    mesh.setMode(OF_PRIMITIVE_TRIANGLES);
    
    
    int rings = 32, resolution = 32;
    
    float length = 512, maxRadius = 256;
    
    for(int i = 0; i < rings; i++) {
        
        float radius = ofNoise(i / 5.) * maxRadius;
        
        ofVec3f offset(0, 0, ofMap(i, 0, rings, -length, length) / 2);
        
        
        for(int j = 0; j < resolution; j++) {
            
            float theta = ofMap(j, 0, resolution, 0, 360); //j/PI * 32;
            
            ofVec2f cur(radius, 0);
            
            cur.rotate(theta);
            
            mesh.addVertex(offset+cur);
            
            mesh.addColor(ofFloatColor((i * j) % 2 == 0 ? 255 : 0));
            
//            mesh.addVertex(offset+cur);
//            mesh.addColor(ofFloatColor(1.0, 0.0, 0.0));
            
            
        }
    }
    
    for(int i = 0; i < rings - 1; i++) {
        for(int j = 0; j < resolution; j++) {
            int sw = i * resolution + j, se = sw + 1;
            if(j + 1 == resolution) {
                se -= resolution;
            }
            
            int nw = sw + resolution, ne = se + resolution;
            mesh.addTriangle(sw, se, nw);
            mesh.addTriangle(nw, se, ne);
            mesh.addTriangle(nw, sw, se);
        }
    }
    
    	light.enable();
}