//-------------------------------------------------------------- void ofApp::update(){ float time = ofGetElapsedTimef(); float noiseTime = time * 1.0; for (int i = 0; i < myMesh.getVertices().size(); i++) { ofVec3f loc = myMesh.getVertices()[i] / 1400.0; float r = ofNoise(loc.x, loc.y, loc.z, ofGetElapsedTimef() * 0.5); float g = ofNoise(loc.x, loc.y, loc.z, ofGetElapsedTimef() * 0.6); float b = ofNoise(loc.x, loc.y, loc.z, ofGetElapsedTimef() * 0.7); myMesh.setColor(i, ofFloatColor(r, g, b, 1.0)); } }
SpiralNoteObj(int _life, int _note){ note = _note; life = _life; color = ofFloatColor((note-25)*0.02, 0.7, 1.0 ); // d = floor(_note * 0.1); l = floor(2400 / _note); d = 4; // l = 50; };
Particles::Particles(int _maxParticles){ maxParticles = _maxParticles; numParticles = 0; friction = 0.01; //mesh.setMode(OF_PRIMITIVE_POINTS); mesh = ofSpherePrimitive(200, 72).getMesh(); for (int i = 0; i < mesh.getVertices().size(); i++) { mesh.addColor(ofFloatColor(1.0, 1.0, 1.0, 1.0)); } }
//-------------------------------------------------------------- void testApp::renderRadialSignedNoiseDemo (){ float centerX = radialNoiseDemoX; float centerY = radialNoiseDemoY; // Render the Signed Noise demo, using // the noise as radial displacements to a circle. ofPushMatrix(); ofTranslate(centerX + radialNoiseDemoR,centerY,0); ofEnableAlphaBlending(); ofEnableSmoothing(); ofNoFill(); // Draw a faint plain circle, so that we can better understand // the radial displacements caused by the signed noise later on. ofSetColor(0,0,0, 64); ofSetCircleResolution(256); ofEllipse(0,0, radialNoiseDemoR*2,radialNoiseDemoR*2); // Let's use the signed noise as a radial displacement to a circle. // We render out the points stored in the X and Y arrays. ofMesh wigglyMeshLine; // yes, technically, it's a "mesh" wigglyMeshLine.setMode(OF_PRIMITIVE_LINE_STRIP); float px = 0, py = 0; for (int i=(nSignedNoiseData-1); i>=0; i--){ // From the 'i' iterator, use ofMap to compute both // an angle (around a circle) and an alpha value. float angle = ofMap(i, 0,nSignedNoiseData-1, 0,-TWO_PI) - HALF_PI; float alph = ofMap(i, 0,nSignedNoiseData-1, 1,0 ); wigglyMeshLine.addColor(ofFloatColor(0,0,255, alph)); // Cpmpute the displaced radius float wigglyRadius = radialNoiseDemoR; wigglyRadius += radialNoiseDemoR * signedNoiseData[i]; // Good old-fashioned trigonometry: y = cos(t), x = sin(t) px = wigglyRadius * cos( angle ); py = wigglyRadius * sin( angle ); wigglyMeshLine.addVertex(ofVec2f(px,py)); } // draw the "mesh" (line) ofEnableSmoothing(); wigglyMeshLine.draw(); // draw a little ball at the end ofFill(); ofSetColor(0,0,0, 160); ofEllipse(px,py, 7,7); ofPopMatrix(); }
void KinectCloud::recordPointCloud() { // 画面の幅と高さ int w = ((testApp*)ofGetAppPtr())->kinectWidth; int h = ((testApp*)ofGetAppPtr())->kinectHeight; // メッシュを生成 ofMesh mesh; mesh.setMode(OF_PRIMITIVE_POINTS); // ブレンド設定 if (gui.getValueB("blend_add")) { ofEnableBlendMode(OF_BLENDMODE_ADD); } // 設定した間隔で、画面の深度情報と色を取得してメッシュの頂点に設定 int step = gui.getValueI("step"); for(int y = 0; y < h; y += step) { for(int x = 0; x < w; x += step) { if(((testApp*)ofGetAppPtr())->kinect.getDistanceAt(x, y) < gui.getValueI("thresh")) { if (gui.getValueB("pick_color")) { ofFloatColor col = ((testApp*)ofGetAppPtr())->kinect.getColorAt(x, y); //col = ofFloatColor(col.r, col.g, col.b, gui.getValueF("cloud_alpha")); //HSBを調整 ofColor tmpColor = ofColor(col.r * 255, col.g * 255, col.b * 255); float hue = tmpColor.getHue(); float sat = tmpColor.getSaturation() * gui.getValueF("color_s"); float br = tmpColor.getBrightness() * gui.getValueF("color_b"); tmpColor.setHsb(hue, sat, br); col.r = (float)tmpColor.r / 255.0; col.g = (float)tmpColor.g / 255.0; col.b = (float)tmpColor.b / 255.0; col.a = 0.9; mesh.addColor(col); } else { mesh.addColor(ofFloatColor(255,255,255)); } ofVec3f loc = ((testApp*)ofGetAppPtr())->kinect.getWorldCoordinateAt(x, y); //float rand = gui.getValueF("cloud_rand"); //loc = ofVec3f(loc.x + ofRandom(-rand, rand), loc.y + ofRandom(-rand, rand), loc.z); //loc = ofVec3f(loc.x, loc.y, loc.z + ofRandom(-rand, rand)); mesh.addVertex(loc); } } } //dequeに追加 meshs.push_back(mesh); int rec_step = gui.getValueF("rec_step"); int rec_size = gui.getValueF("rec_size"); if (meshs.size() > rec_size * rec_step) { meshs.pop_front(); } }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetFrameRate(60); ofSetVerticalSync(true); ofBackground(100); sender.setup("localhost", 5500); col.addListener(this, &ofApp::update_col); pos.addListener(this, &ofApp::update_pos); gui.setup("panel"); gui.add( col.set( "myObject1.color", ofFloatColor(0.5,0.5,0.7,1.0), ofFloatColor(0,0,0,0), ofFloatColor(1,1,1,1) ) ); gui.add( pos.set( "myObject1.pos", ofVec3f(ofGetWidth()*.5, ofGetHeight()*.5, 0.), ofVec3f(0,0,0), ofVec3f(ofGetWidth(),ofGetHeight(), 1000) ) ); gui.add( param1.set( &sender, "param1float", 0.5f, 0.0f, 0.1f) ); gui.add( param2.set( &sender, "param2bool", true) ); gui.add( param3.set( &sender, "param3vec2", ofVec2f(1.0,2.0), ofVec2f(0,0), ofVec2f(1,1)) ); }
WallOBoxes::WallOBoxes(int columns, int rows) { _columns = columns >= 1 ? columns : 1; _rows = rows >= 1 ? rows : 1; _center = ofPoint(); _boxSize = 50.0f; _boxSpacing = 50.0f; _orientation = ofQuaternion(0.0, 0.0, 0.0, 1.0); _boxes = NULL; _kinectOffsets = NULL; _boxMaterial.setShininess(100); _boxMaterial.setSpecularColor(ofFloatColor(1.0f,1.0f,1.0f)); _brightLight.setDiffuseColor(ofFloatColor(1.0f,1.0f,1.0f)); _brightLight.setPosition(0, 0, 500); ofMeshCubeSetResolution(1); this->reset(); }
void CloudsVisualSystemOscillations::BuildGrid(){ grid.clear(); int spacing = (int) floor(GridPointSpacing); ofFloatColor c = (!invertColorScheme)? ofFloatColor(1,1,1,GridPointAlpha) : ofFloatColor(0,0,0,GridPointAlpha); for (float x = GridClipping.low; x < GridClipping.high ; x += spacing){ for (float y = GridClipping.low; y < GridClipping.high ; y +=spacing){ float _x1 =x, _x2 = x, _y1 = y, _y2 = y, _z1 = GridClipping.low, _z2 = GridClipping.high; for (int i = 0 ; i < 3 ; i++){ grid.addVertex(ofPoint(_x1,_y1,_z1)); grid.addVertex(ofPoint(_x2,_y2,_z2)); grid.addColor(c); grid.addColor(c); //Group theory in your face: (12)(23) ~ (123) swap(_y1, _z1); swap(_x1, _y1); swap(_y2, _z2); swap(_x2, _y2); } } } }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetVerticalSync(true); ofEnableDepthTest(); ofDisableArbTex(); ofLoadImage(heightMap, "heightmap.png"); normalFbo.allocate(ofGetWidth(), ofGetHeight()); ofEnableArbTex(); normalShader.load("","normal.frag"); terrainShader.load("terrain"); int scale = 15; int w = ofGetWidth()/scale; int h = ofGetHeight()/scale; for (int y = 0; y < h; y++){ for (int x = 0; x<w; x++){ float offsetX = 0; float offsetY = (x%2==1)?0.5:0.0; terrain.addVertex(ofPoint((x+offsetX)*scale,(y+offsetY)*scale,0)); terrain.addNormal(ofPoint(1,0,0)); terrain.addTexCoord(ofVec2f((float)(x+offsetX)/(float)w,(float)(y+offsetY)/(float)h)); } } for (int y = 0; y<h-1; y++){ for (int x=0; x<w-1; x++){ if(x%2==0){ terrain.addIndex(x+y*w); // a terrain.addIndex((x+1)+y*w); // b terrain.addIndex(x+(y+1)*w); // d terrain.addIndex((x+1)+y*w); // b terrain.addIndex((x+1)+(y+1)*w); // c terrain.addIndex(x+(y+1)*w); // d } else { terrain.addIndex((x+1)+y*w); // b terrain.addIndex(x+y*w); // a terrain.addIndex((x+1)+(y+1)*w); // c terrain.addIndex(x+y*w); // a terrain.addIndex(x+(y+1)*w); // d terrain.addIndex((x+1)+(y+1)*w); // c } } } bWireframe = false; light.setDiffuseColor(ofFloatColor(1.,1.,0.9)); light.setPosition(100, 100, 1000); }
//normal update call void CloudsVisualSystemRandomDigits2::selfUpdate() { vector<ofVec2f> uvs; vector<ofFloatColor> colors; ofFloatColor darkColor = ofFloatColor(dark, dark, dark); ofFloatColor lightColor = ofFloatColor(light, light, light); for (int i=0; i<numbers.size(); i++) { if (ofRandom(400) < 1) { numbers[i].triggerCount(); } numbers[i].update(); numbers[i].fillUvs(uvs); numbers[i].fillColors(colors, darkColor, lightColor); } vbo.setTexCoordData(&uvs[0], uvs.size(), GL_STATIC_DRAW); vbo.setColorData(&colors[0], colors.size(), GL_STATIC_DRAW); }
void meshScene1::setup(){ // mesh.setMode(OF_PRIMITIVE_POINTS); // mesh.setMode(OF_PRIMITIVE_LINES); // mesh.setMode(OF_PRIMITIVE_LINE_STRIP); // mesh.setMode(OF_PRIMITIVE_LINE_LOOP); mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); mesh.enableColors(); ofVec3f top(100.0, 50.0, 0.0); ofVec3f left(50.0, 150.0, 0.0); ofVec3f right(150.0, 150.0, 0.0); mesh.addVertex(top); mesh.addColor(ofFloatColor(1.0, 0.0, 0.0)); mesh.addVertex(left); mesh.addColor(ofFloatColor(0.0, 1.0, 0.0)); mesh.addVertex(right); mesh.addColor(ofFloatColor(1.0, 1.0, 0.0)); }
void FishWave::updateMesh(){ m.clear(); strokeMesh.clear(); for (int i = 0; i < polyline.getVertices().size(); i++) { ofVec2f p = polyline.getVertices()[i]; ofVec2f p2 = ofVec2f(p.x, ofGetHeight()); ofVec3f dir = polyline.getTangentAtIndex(i); float angle = atan2(dir.x, dir.y)*(180)/pi; ofColor col = color; int a = angle/2+col.getHueAngle()/2+ofGetFrameNum()/5.; col.setHueAngle(a%360); ofColor cc = baseColor; float pct = ofMap(p.y, ypos-energyHighlightSize, ypos, 1, 0, true); col.r = pct * cc.r + (1-pct) * col.r; col.g = pct * cc.g + (1-pct) * col.g; col.b = pct * cc.b + (1-pct) * col.b; m.addVertex(points[i].p); m.addColor(ofFloatColor(col, 1)); m.addVertex(p2); m.addColor(ofFloatColor(col, 1)); // ofNode node; // ofNode child; // child.setParent(node); // child.setPosition(ofVec3f(0, ofMap(pct, 0, 1, 0, 20), 0)); // // node.setPosition(p); // ofQuaternion q = ofQuaternion(0, ofVec3f(1, 0, 0), 0, ofVec3f(0, 1, 0), angle, ofVec3f(0, 0, 1)); // node.setOrientation(q); // // strokeMesh.addVertex(node.getGlobalPosition()); // strokeMesh.addVertex(child.getGlobalPosition()); } }
void Brush::init(int _numSprings){ float angle = getAngle() + HALF_PI; float step = brushWidth/(float)_numSprings; while ( _numSprings > colors.size() ){ colors.push_back(ofFloatColor(1.0,1.0) ); } ofPoint top; top.x = x + cos(angle) * brushWidth*0.5; top.y = y + sin(angle) * brushWidth*0.5; ofPoint buttom; buttom.x = x + cos(angle+PI) * brushWidth*0.5; buttom.y = y + sin(angle+PI) * brushWidth*0.5; ofPoint diff = buttom - top; diff.normalize(); diff *= step; for(int i = 0; i < springs.size(); i++){ delete As[i]; delete Bs[i]; } As.clear(); Bs.clear(); springs.clear(); for(int i = 0; i < _numSprings; i++){ Particle *a = new Particle(); a->set( top + diff * i ); a->size = step; a->bFixed = true; As.push_back(a); Particle *b = new Particle(); b->set( ofPoint(x+ofRandom(-brushWidth*0.5,brushWidth*0.5), y+ofRandom(-brushWidth*0.5,brushWidth*0.5) ) ); b->size = step; b->damping = damp; b->bFixed = false; b->color.set(colors[i]); Bs.push_back(b); Spring newSpring; newSpring.A = a; newSpring.B = b; newSpring.k = k; springs.push_back(newSpring); } }
//----------------------------------------------------------------------------------------- // void ofApp::update() { float time = ofGetElapsedTimef(); for (int y=0; y<H; y++) { for (int x=0; x<W; x++) { int i = x + W * y; //Vertex index ofPoint p = mesh.getVertex( i ); //the following equation is based on the linear theory of ocean surface waves // assuming the amplitude of waves on the water surface is infinitely small so the surface is almost exactly a plane. To simplify the mathematics, we can also assume that the flow is 2-dimensional with waves traveling in the x-direction. //read more details on http://oceanworld.tamu.edu/resources/ocng_textbook/chapter16/chapter16_01.htm freq = sqrt(g * k); float height = amp * sin(k * x - freq * time * 2); // the z position of each mesh vertex are determined by the x position, the height that's caculated by the linear theory of the ocean suface wave, and ofSignedNoise, which returns a number between -1 and 1 p.z = (W-x)/7.f * ofSignedNoise(height * .001, y*.007, height)+ofSignedNoise(x * .01, y*.08, height); // p.z = (W-x)/15.f * height * ofSignedNoise(height * .001, y*.007 ); mesh.setVertex( i, p ); //The color of vertex changes as the z position goes up and down mesh.setColor(i, ofFloatColor( (abs(height) + .5) * 30/255.f, (abs(height) + .5) * 80/255.f, (abs(height) + .5)*100/255.f)); // mesh.setColor( i, ofFloatColor( // ofMap(height, amp, -amp, 60, 100)/255.f, // 1- ofMap(height, amp, -amp, 200, 250)/255.f, // ofMap(height, amp, -amp, 200, 250)/255.f // )); } } setNormals( mesh ); //the light moves position and changes color pointLight.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.5)*(ofGetWidth()*.3), ofGetHeight()/2, 500); pointLight2.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.15)*(ofGetWidth()*.3), ofGetHeight()*.5 + sin(ofGetElapsedTimef()*.7)*(ofGetHeight()), -300); pointLight3.setPosition( cos(ofGetElapsedTimef()*1.5) * ofGetWidth()*.5, sin(ofGetElapsedTimef()*1.5f) * ofGetWidth()*.5, cos(ofGetElapsedTimef()*.2) * ofGetWidth() ); }
//-------------------------------------------------------------- void ofApp::setup(){ ofEnableSmoothing(); ofBackground(0); pVec.clear(); delauMesh.clear(); for (int i = 0; i < N; i++) { pVec.push_back(ofVec2f(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()))); } for(int i = 0; i < N-2; i++) { ofVec2f v1 = pVec[i]; for(int j = i+1; j < N-1; j++) { ofVec2f v2 = pVec[j]; for(int k = j+1; k < N; k++) { ofVec2f v3 = pVec[k]; float tmp = 2.0*((v2.x-v1.x)*(v3.y-v1.y)-(v2.y-v1.y)*(v3.x-v1.x)); ofVec2f center = ofVec2f( ((v3.y-v1.y)*(v2.x*v2.x-v1.x*v1.x+v2.y*v2.y-v1.y*v1.y)+ (v1.y-v2.y)*(v3.x*v3.x-v1.x*v1.x+v3.y*v3.y-v1.y*v1.y))/tmp, ((v1.x-v3.x)*(v2.x*v2.x-v1.x*v1.x+v2.y*v2.y-v1.y*v1.y)+ (v2.x-v1.x)*(v3.x*v3.x-v1.x*v1.x+v3.y*v3.y-v1.y*v1.y))/tmp ); float r = ofDist(center.x,center.y, v1.x,v1.y) - 0.01; Boolean flg = false; for (int l = 0; l < N; l++) { if (ofDist(center.x,center.y, pVec[l].x,pVec[l].y) < r) { flg = true; break; } } ofFloatColor c = ofFloatColor( ofRandom(0.0,1.0), ofRandom(0.0,1.0), ofRandom(0.0,1.0) ); if (!flg) { //ofDrawLine(v1.x, v1.y, v2.x, v2.y); //ofDrawLine(v2.x, v2.y, v3.x, v3.y); //ofDrawLine(v3.x, v3.y, v1.x, v1.y); delauMesh.addVertex(v1); delauMesh.addColor(c); delauMesh.addVertex(v2); delauMesh.addColor(c); delauMesh.addVertex(v3); delauMesh.addColor(c); } } } } }
// 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 CloudsVisualSystemOscillations::selfSetup(){ NUMPOINTS = 10000; GridPointSpacing = 100; cout<<"made it to selfsetup"<<endl; ofFloatColor zero = ofFloatColor(0,0,0); for (int i = 0; i < NUMPOINTS ; i++){ //the Zpos serves as an index mesh.addVertex(ofPoint(0,0,i)); mesh.addColor(ofFloatColor(1.,1.,1.,1.)); } cout<<"made it past mesh creation loop"<<endl; //TODO: Find way to update on every resize offsetX = offsetY = 0; BuildGrid(); cout<<"made it past build grid"<<endl; loadShader(); cout<<"made it past load shaders"<<endl; }
void CloudsClip::loadAdjustmentFromXML(bool forceReload){ // if(adjustmentLoaded && !forceReload){ // return; // } ofxXmlSettings adjustmentSettings; if(!adjustmentSettings.loadFile(getAdjustmentXML())){ // ofLogError() << "Couldn't load adjustment XML" << getAdjustmentXML() << endl; } adjustTranslate.x = adjustmentSettings.getValue("adjustment:translate:x", 0.); adjustTranslate.y = adjustmentSettings.getValue("adjustment:translate:y", 0.); adjustTranslate.z = adjustmentSettings.getValue("adjustment:translate:z", 0.); adjustRotate.x = adjustmentSettings.getValue("adjustment:rotate:x", 0.); adjustRotate.y = adjustmentSettings.getValue("adjustment:rotate:y", 0.); adjustRotate.z = adjustmentSettings.getValue("adjustment:rotate:z", 0.); adjustScale.x = adjustmentSettings.getValue("adjustment:scale:x", 1.); adjustScale.y = adjustmentSettings.getValue("adjustment:scale:y", 1.); minDepth = adjustmentSettings.getValue("adjustment:depth:min", 300); maxDepth = adjustmentSettings.getValue("adjustment:depth:max", 1200); skinTargetColor = ofFloatColor(adjustmentSettings.getValue("adjustment:skin:targetR", 1.0), adjustmentSettings.getValue("adjustment:skin:targetG", 0.0), adjustmentSettings.getValue("adjustment:skin:targetB", 0.0)); // cout << "loaded skin target color " << skinTargetColor << endl; skinLowerThreshold = adjustmentSettings.getValue("adjustment:skin:lowerThreshold", 0.); skinUpperThreshold = adjustmentSettings.getValue("adjustment:skin:upperThreshold", 1.); skinHueWeight = adjustmentSettings.getValue("adjustment:skin:hueWeight", 0.5); skinSatWeight = adjustmentSettings.getValue("adjustment:skin:satWeight", 0.5); skinBrightWeight = adjustmentSettings.getValue("adjustment:skin:brightWeight", 0.5); // contourTargetThreshold = adjustmentSettings.getValue("adjustment:extraction:threshold", 100); // contourMinBlobSize = adjustmentSettings.getValue("adjustment:extraction:blobsize", 100); faceCoord = ofVec2f(adjustmentSettings.getValue("adjustment:extraction:faceu", 320.), adjustmentSettings.getValue("adjustment:extraction:facev", 110.)); // cout << "loaded face coord color " << faceCoord << endl; //cout << "FOR CLIP " << getID() << " LOADED " << contourTargetColor << " target thresh " << contourTargetThreshold << " blob size " << contourMinBlobSize << endl; adjustmentLoaded = true; }
//-------------------------------------------------------------- void testApp::setup(){ mesh.setMode(OF_PRIMITIVE_LINE_LOOP); mesh.enableColors(); mesh.enableIndices(); ofVec3f top(100.0, 50.0, 0.0); ofVec3f left(50.0, 150.0, 0.0); ofVec3f right(150.0, 150.0, 0.0); mesh.addVertex(top); mesh.addColor(ofFloatColor(1.0,0.0,0.0)); mesh.addVertex(left); mesh.addColor(ofFloatColor(0.0,1.0,0.0)); mesh.addVertex(right); mesh.addColor(ofFloatColor(0.0,0.0,1.0)); mesh.addIndex(0); mesh.addIndex(2); mesh.addIndex(1); mesh.addIndex(0); mesh.addIndex(2); }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button) { path = new ofxSuperPath(); paint = new ofxPaint(path, ofColor(255), 100); brush = new ofxShatterBrush(path, paint); brush->setDynamic(true); brush->setSpeed(6); brush->setShatterForce(20); marking = new ofxMarking(path, paint, brush); path->reset(); path->lineStart(x,y,0, ofFloatColor(0), ofGetFrameNum(), 0); }
//-------------------------------------------------------------- void Particle::drawHistory(int renderMode) { ofEnableAlphaBlending(); if(useHistory && pts.size()>2) { ofNoFill(); colors.clear(); for (int i=0; i<pts.size(); i++) { float pct = ofMap(i, 0, pts.size()-1, 0, 0.8) * alpha; colors.push_back(ofFloatColor(1,1,1,pct)); } vbo.setColorData(&colors[0], colors.size(), GL_DYNAMIC_DRAW); vbo.setVertexData(&pts[0], pts.size(), GL_DYNAMIC_DRAW); vbo.draw(renderMode, 0, pts.size()); } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ path = new ofxSuperPath(); paint = new ofxPaint(path, ofColor(255), 100); brush = new ofxRibbonBrush(path, paint); brush->setDynamic(true); brush->setSpeed(6); brush->setUseAcceleration(false); marking = new ofxMarking(path, paint, brush); path->reset(); path->lineStart(x,y,0, ofFloatColor(0), ofGetFrameNum(), 0); }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button) { path = new ofxSuperPath(); paint = new ofxPaint(path, ofColor(255,ofRandom(255),ofRandom(255)), 100); brush = new ofxPerlinBrush(path, paint); brush->setDynamic(true); brush->setSpeed(6); brush->setNoiseScale(ofRandom(.001)); marking = new ofxMarking(path, paint, brush); path->reset(); path->lineStart(x,y,0, ofFloatColor(0), ofGetFrameNum(), 0); }
//-------------------------------------------------------------- void testApp::renderNoisyRobotArmDemo(){ float t = ofGetElapsedTimef(); float shoulderNoiseAngleDegrees = 90 + 70.0 * ofSignedNoise(t * 1.00); float elbowNoiseAngleDegrees = 60 + 80.0 * ofSignedNoise(t * 0.87); float wristNoiseAngleDegrees = (2.5 * 72) + 45.0 * ofSignedNoise(t * 1.13); float noisyR = ofNoise(t * 0.66); // different multiplicative step-factors 不同的乘法系数 float noisyG = ofNoise(t * 0.73); // guarantee that our color channels are 保证我们的颜色通道 float noisyB = ofNoise(t * 0.81); // not all (apparently) synchronized. 明显的不同步 ofEnableSmoothing(); ofEnableAlphaBlending(); ofSetCircleResolution(12); ofSetLineWidth(1.0); ofPushMatrix(); // Translate over to the shoulder location; draw it // 转化到肩部位置;画它 ofTranslate(ofGetWidth()/2, 540, 0); ofRotate(shoulderNoiseAngleDegrees, 0, 0, 1); drawNoisyArmRect(100,24); // Translate over to the forearm location; draw it // 转化到前臂位置;画它 ofTranslate(76, 0, 0); ofRotate(elbowNoiseAngleDegrees, 0, 0, 1); drawNoisyArmRect(90,16); // Translate over to the hand location; draw it. // Note that the color of the 'hand' is controlled by noise. // 转化到手部位置;画它 // 需要注意,手部的颜色是由噪点决定的 ofTranslate(74, 0, 0); ofRotate(wristNoiseAngleDegrees, 0, 0, 1); ofSetCircleResolution(5); // a kludgy "pentagon" 一个五变形 ofFill(); ofSetColor (ofFloatColor(noisyR, noisyG, noisyB, 0.75)); ofEllipse(-10,0, 60,60); ofNoFill(); ofSetColor(0); ofEllipse(-10,0, 60,60); ofSetCircleResolution(12); ofSetColor(0); ofFill(); ofEllipse(0,0, 7,7); ofPopMatrix(); }
//-------------------------------------------------------------- void ofApp::setup(){ strangeMesh.setMode(OF_PRIMITIVE_POINTS); strangeMesh.enableColors(); float x = 0.1, y = 0.1, // starting point a = -0.966918, // coefficients for "The King's Dream" b = 2.879879, c = 0.765145, d = 0.744728; int initialIterations = 100, // initial number of iterations // to allow the attractor to settle iterations = 1000000; // number of times to iterate through // the functions and draw a point initialZoomFactor = 100.0; // blows the points out to a usable scale // compute some initial iterations to settle into the orbit of the attractor for (int i = 0; i < initialIterations; i++) { // compute a new point using the strange attractor equations float xnew = sin(y*b) + c*sin(x*b); float ynew = sin(x*a) + d*sin(y*a); // save the new point x = xnew; y = ynew; } // go through the equations many times, drawing a point for each iteration for (int i = 0; i < iterations; i++) { // compute a new point using the strange attractor equations float xnew = sin(y*b) + c*sin(x*b); float ynew = sin(x*a) + d*sin(y*a); // save the new point x = xnew; y = ynew; // draw the new point // glVertex2f(x, y); ofVec3f tempVec3f(xnew*initialZoomFactor, ynew*initialZoomFactor, 0.0); strangeMesh.addVertex(tempVec3f); strangeMesh.addColor(ofFloatColor(1.0, 1.0, 1.0, 0.025)); } }
// draw any debug stuff here void CloudsVisualSystemNbody::regenerate(){ particles.clear(); particleHeads.clear(); for(int y = 0; y < numParticles / 512; y++){ for(int x = 0; x < 512; x++){ //placeholder // particleHeads.addVertex(ofVec3f(x,y,0)); particles.addColor(ofFloatColor(0,0)); particles.addVertex( ofVec3f(x,y*trailLength,0) ); for(int t = 0; t < trailLength; t++){ particles.addColor(ofFloatColor::white); particles.addVertex( ofVec3f(x,y*trailLength+t,0) ); } particles.addColor(ofFloatColor(0,0)); particles.addVertex( ofVec3f(x,y*(trailLength)-1,0) ); } } particles.setMode(OF_PRIMITIVE_LINE_STRIP); //positions are for all the points, including the trails positionFront.allocate(512,numParticles/512*trailLength, GL_RGB32F ); positionBack.allocate(512,numParticles/512*trailLength, GL_RGB32F ); //but force and velocity is just for the heads! velocityFront.allocate(512,numParticles/512, GL_RGB32F ); velocityBack.allocate(512,numParticles/512, GL_RGB32F ); force.allocate(512,numParticles/512, GL_RGB32F ); meshFromFbo(force, drawMesh); meshFromFbo(positionFront, drawMeshTrails); cout << "Generated " << particles.getNumVertices() << endl; }
//-------------------------------------------------------------- void ofApp::update() { dir.x = ofRandomf() * 1.57; pos.x = (width / 2.0) + (ofRandomf() * 0.5); if(isDrawS && !isPaused) fluid.addTemporalForce(pos, dir, ofFloatColor(0.12, 0.09, 0.09), rad, temp, den); if(isPaused) pCount += ofGetFrameRate() / 60; if(pCount >= pTime) { pCount = 0; isPaused = false; } if(!isStatA) ofSetWindowShape(width, height); else ofSetWindowShape(width + 85.0, height); // Update // fluid.update(); ofSetWindowTitle(ofToString(ofGetFrameRate())); updateArduino(); if(!isPaused) { irsVal = (float)ard.getAnalog(5); } if(irsVal < 590.0) { isPaused = true; } else { isPaused = false; } }
void BaseGame::showHitAnimations() { LaserManager &lm = *laserManager; for(int i = 0; i<previousShots.size(); i++) { //lm.addLaserDot(previousShots[i], ofColor::white); float timeSinceShot = ofGetElapsedTimef() - previousShotTimes[i]; float shotAnimateTime = 0.7; ofVec2f shotAnimatePath = ofVec2f(200,200); float progress = Cubic::easeOut(ofMap(timeSinceShot, 0,shotAnimateTime, 0, 1),0,1,1); if(progress < 1) { lm.addLaserDot(previousShots[i] + shotAnimatePath * progress, ofFloatColor(1,1,1), 1-progress); lm.addLaserDot(previousShots[i] + shotAnimatePath * ofVec2f(1,-1) * progress, ofFloatColor(1,1,1), 1-progress); lm.addLaserDot(previousShots[i] + shotAnimatePath * ofVec2f(-1,-1) * progress, ofFloatColor(1,1,1), 1-progress); lm.addLaserDot(previousShots[i] + shotAnimatePath * ofVec2f(-1,1) * progress, ofFloatColor(1,1,1), 1-progress); } } }
void Stars::setup(){ for(int i = 0; i < _num; i++){ _pos[i].set( ofRandom(-_limit, _limit), ofRandom(-_limit, _limit), ofRandom(-_limit, _limit) ); } _color = ofFloatColor(1.0, 1.0, 1.0, 1.0); }
SlideSequencer::SlideSequencer(){ currentLine = 0; desiredLine = 0; countDown = 0; set(0,0,ofGetWidth(),ofGetHeight()); imagePath = " "; text = NULL; textColor.addState(ofFloatColor(0.0,0.0)); textColor.addState(5); bFinish = false; }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(51,51,51); ofSetDepthTest(true); ofEnableSmoothing(); // ofEnableDepthTest(); light.enable(); light.setSpotlight(); light.setPosition(-100, 100, 100); light.setAmbientColor( ofFloatColor(0.5,0.2,0.32,1.0) ); light.setDiffuseColor( ofFloatColor(0.5,0.5,1.0) ); light.setSpecularColor( ofFloatColor( 1.0, 1.0, 1.0) ); for( int i = 0; i < 200; i++ ) { for( int j = 0; j < 200; j++ ) { mesh.addColor(ofFloatColor(0.5, 0.8, 1.0 ) ); } } }