コード例 #1
0
ファイル: testApp.cpp プロジェクト: Vamoss/devart-template
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    switch(key) {
        case 'f': ofToggleFullscreen(); break;
            
            
            // clear the frame
        case 'c': ildaFrame.clear(); break;
            
            // draw rectangle
        case 'r': {
            ofPolyline p = ofPolyline::fromRectangle(ofRectangle(ofRandomuf()/2, ofRandomuf()/2, ofRandomuf()/2, ofRandomuf()/2));
            ildaFrame.addPoly(p);
        }
            break;

            // change color
        case 'R': ildaFrame.params.output.color.r = 1 - ildaFrame.params.output.color.r; break;
        case 'G': ildaFrame.params.output.color.g = 1 - ildaFrame.params.output.color.g; break;
        case 'B': ildaFrame.params.output.color.b = 1 - ildaFrame.params.output.color.b; break;

            // toggle draw lines (on screen only)
        case 'l': ildaFrame.params.draw.lines ^= true; break;
            
            // toggle loop for last poly
        case 'o': ildaFrame.getLastPoly().setClosed(ildaFrame.getLastPoly().isClosed()); break;
            
            // toggle draw points (on screen only)
        case 'p': ildaFrame.params.draw.points ^= true; break;
            
            // adjust point count
        case '.': ildaFrame.polyProcessor.params.targetPointCount++; break;
        case ',': if(ildaFrame.polyProcessor.params.targetPointCount > 10) ildaFrame.polyProcessor.params.targetPointCount--; break;

            // adjust point count quicker
        case '>': ildaFrame.polyProcessor.params.targetPointCount += 10; break;
        case '<': if(ildaFrame.polyProcessor.params.targetPointCount > 20) ildaFrame.polyProcessor.params.targetPointCount -= 10; break;
            
            // flip image
        case 'x': ildaFrame.params.output.transform.doFlipX ^= true; break;
        case 'y': ildaFrame.params.output.transform.doFlipY ^= true; break;

            // cap image
        case 'X': ildaFrame.params.output.doCapX ^= true; break;
        case 'Y': ildaFrame.params.output.doCapY ^= true; break;

            // move output around
        case OF_KEY_UP: ildaFrame.params.output.transform.offset.y -= 0.05; break;
        case OF_KEY_DOWN: ildaFrame.params.output.transform.offset.y += 0.05; break;
        case OF_KEY_LEFT: ildaFrame.params.output.transform.offset.x -= 0.05; break;
        case OF_KEY_RIGHT: ildaFrame.params.output.transform.offset.x += 0.05; break;
            
            // scale output
        case 'w': ildaFrame.params.output.transform.scale.y += 0.05; break;
        case 's': ildaFrame.params.output.transform.scale.y -= 0.05; break;
        case 'a': ildaFrame.params.output.transform.scale.x -= 0.05; break;
        case 'd': ildaFrame.params.output.transform.scale.x += 0.05; break;
            
        case 'C': ildaFrame.drawCalibration(); break;
    }
}
コード例 #2
0
ファイル: ofApp.cpp プロジェクト: kylemcdonald/ofxSplineTool
void ofApp::setup() {
	ofSetVerticalSync(true);
	splineTool.setup(256);
	
	for(int i = 0; i < 5; i++) {
		splineTool.add(ofVec2f(ofRandomuf(), ofRandomuf()) * 256);
	}
}  
コード例 #3
0
void Particle::setup(){
	color.r = 1;
	color.g = 1;
	color.b = 1;
	color.a = 1;
	radius = 1;
	rotation = ofRandomuf() * 2 * PI;
	frame = 0; 
	nProperty = ofRandomuf();
	state = DEAD;
	life = 0;
}
コード例 #4
0
void Wasp::setup(InputHistory* hist ) 
{ 
	input_history = hist;
	trail_time = ofRandomuf();
	// square distribution
	float max_speed_pre = ofRandomuf();
	max_speed_pre *= max_speed_pre;
	max_speed = 1000.0f + max_speed_pre*1000.0f;
	
	acceleration = ofRandom( 0.8f, 1.2f ) * max_speed * 5.0f;
	
}
コード例 #5
0
ファイル: Star.cpp プロジェクト: yutatoga/mowa
Star::Star(ofVec2f p){
    loaded = false;
	pos = p;
	ticks = 0;
	rad = 0.001;//+0.01 * ofRandomuf();
    float randomVal = ofRandomuf();
	color = MColor(randomVal*TWO_PI,1.0,1.0,"HSB");
    char fname[64];
    soundIndex = (int)(randomVal * 4);
    strength = 1;
    loaded = true;
    rotation = (ofRandomuf()-0.5) * 0.05;
}
コード例 #6
0
void Critter::MaybeReproduce(std::list<Critter *> &group) {
  if (!attacker() && food >= 0.5 && ofRandomuf() < reproductivity() && group.size() < kMaxPopulation) {
    area *= kChildScaleFactor;
    food -= 0.5;
    age = 0;
    const ofVec2f epsilon = ofVec2f(0.1, 0.1);
    Critter *critter = new Critter(player, 0, mass, area, position + epsilon, velocity);
    group.push_back(critter);
  }
  const float cell_mortality = radius() <= kBreederSize ? mortality() : kWallMortality;
  if (ofRandomuf() < cell_mortality * age * age * age) {
    area = 0;
  }
}
コード例 #7
0
void Critter::UpdateInternal(float dt) {
  if (radius() < kBreederSize - kGrowthRate) {
    area += kGrowthRate * ofRandomuf();
  }
  if (radius() > kWallSize) {
    is_attacker = true;
  }
  if (age <= 1.0 - kAgeRate) {
    age += kAgeRate * ofRandomuf();
  }
  force += -kDrag * velocity;
  orientation_speed *= 0.99;
  orientation += parity * orientation_speed * dt;
}
コード例 #8
0
VoronoiFilter::VoronoiFilter(ofTexture & texture) : AbstractFilter(texture.getWidth(), texture.getHeight()) {
    _name = "Voronoi";
    _texture = texture;
    for (int i=0; i<NUM_POINTS; i++) {
        _vertices[i*2] = ofRandomuf();
        _vertices[i*2+1] = ofRandomuf();
        _colors[i*3] = ofRandomuf();
        _colors[i*3+1] = ofRandomuf();
        _colors[i*3+2] = ofRandomuf();
    }
    _addParameter(new Parameter2fv("verts", _vertices, NUM_POINTS));
    _addParameter(new Parameter3fv("colors", _colors, NUM_POINTS));
    _setupShader();
}
コード例 #9
0
// ----------------------------------------------------
void SpotsScene::addShape() {
    if(shapes.size() < maxShapesOnScreen) {
        ofVec2f pt = getCentreCubeScreen();
        float r = ofRandom(5.f, 40.f);
        pt.x += cos(ofRandomuf()*TWO_PI) * r;
        pt.y += sin(ofRandomuf()*TWO_PI) * r;
        
        SpotShape shape;
        shape.setPhysics(1, 0.1, 1);
        shape.setup(box2d.getWorld(), pt, 1);
        shape.radiusTarget = ofRandom(5.f, 60.f);
        shape.colour = complimentaryColours[(int)ofRandom(0, complimentaryColours.size())]; //choice of random complimentary colour
        shapes.push_back(shape);
    }
}
コード例 #10
0
	void Controller::update() {
		
		forceSet.update(state);
		
		int resolution = state.getWidth();
		random.allocate(resolution, resolution, OF_IMAGE_COLOR_ALPHA);
		float* x = random.getPixels();
		for (int i = 0; i < resolution*resolution; i++) {
			*x++ = ofRandomf() * birthSpread + birthPlace.x;
			*x++ = ofRandomf() * birthSpread + birthPlace.y;
			*x++ = ofRandomf() * birthSpread + birthPlace.z;
			
			*x++ = ofRandomuf() < birthRate;
		}

		ofEnableAlphaBlending();
		
		random.update();
		state.getTargetPosition().begin();
		random.draw(0,0);
		state.getTargetPosition().end();

		ofPushStyle();
		state.getTargetVelocity().begin();
		random.draw(0,state.getHeight(), state.getWidth(), -state.getHeight());
		state.getTargetVelocity().end();
		ofPopStyle();
		
		ofDisableAlphaBlending();
	}
コード例 #11
0
ファイル: simulationManager.cpp プロジェクト: 6301158/ofx-dev
//------------------------------------
simulationManager::simulationManager(){
		
		for (int i = 0; i < NUM_SPRINGS; i++){
		
			springs[i] 			= new spring();
			springs[i]->pta 	= (ofRandomuf() > 0.9f) ? 40	: 0;
			springs[i]->ptb 	= i+1;
			
			springs[i]->dist 	= 80.50f;
			if (i == 39) springs[i]->dist = 400;
			springs[i]->kspr 	= 5.05f;
		
		}
		
		


		

		for (int i = 0; i < NUM_PARTICLES; i++){
			
			DIVStemp[i] = new derivative();
			PTStemp[i] = new particle();
		
		}
		
		
}
コード例 #12
0
//--------------------------------------------------------------
void Branch::update(){
    vel = ofVec3f(ofRandomf(),ofRandomuf()*8*-1,0);
    vel.x+=sin(drawPoint.y*0.07)*2;

    if (thickness > 0){
    points.push_back(drawPoint);
    drawPoint += vel;

    }

    for (int i = 0; i < bloomNums.size(); i++){
        int locIndex = bloomNums[i];
        if (locIndex==points.size()){
            Bloom b;
            b.setup(points[locIndex]);
            blooms.push_back(b);
        }

    }

    for (int i = 0; i< blooms.size(); i++){
        blooms[i].update();

    }

}
コード例 #13
0
ファイル: ofxParticles.cpp プロジェクト: ccabrales/ZoneRush
void ofxParticleSystem::addParticles(ofxParticleEmitter & src, ofImage* texture){
    for(int i=0;i<src.numPars;i++){
        ofVec3f pos = src.positionStart;
        ofVec3f vel = src.velocityStart;
        if(src.positionEnd != src.positionStart || src.velocityStart != src.velocityEnd){
            float rf = ofRandomuf();
            pos = src.positionStart.interpolated(src.positionEnd, rf);
            vel = src.velocityStart.interpolated(src.velocityEnd, rf);
        }
        ofVec3f p = pos+ofRandVec3f()*src.posSpread;
        ofVec3f v = vel+ofRandVec3f()*src.velSpread;
        float s = src.size+ofRandomf()*src.sizeSpread;
        float l = src.life+ofRandomf()*src.lifeSpread;
        ofxParticle * par = new ofxParticle(p,v,s,l);
        par->rotation = src.rotation+ofRandVec3f()*src.rotSpread;
        par->texture = texture;
        par->rotationalVelocity = src.rotVel+ofRandVec3f()*src.rotVelSpread;
        par->particleID = totalParticlesEmitted+i;
        ofColor pColor = src.color;
        if(src.colorSpread != ofColor(0,0,0,0)){
            pColor.r = ofClamp(pColor.r + ofRandomf()*src.colorSpread.r,0,255);
            pColor.g = ofClamp(pColor.g + ofRandomf()*src.colorSpread.g,0,255);
            pColor.b = ofClamp(pColor.b + ofRandomf()*src.colorSpread.b,0,255);
            pColor.a = ofClamp(pColor.a + ofRandomf()*src.colorSpread.a,0,255);
        }
        par->color = pColor;
        particles.push_back(par);
    }
    numParticles+=src.numPars;
    totalParticlesEmitted+=src.numPars;
}
コード例 #14
0
void Walker::update() {


  float r = ofRandomuf();
	// a 70% chance of moving to the right
  if (r < 0.2) {
    if (mTargetX > mX) {
      mX++;
    } else if (mTargetX < mX) {
      mX--;
    }
    if (mTargetY > mY) {
      mY++;
    } else if (mTargetY < mY) {
      mY--;
    }
  } else {
    float dirX = ofRandomf();
    float dirY = ofRandomf();
    mX += dirX;
    mY += dirY;
  }

  mX = ofClamp(mX, 0, ofGetWidth() - 1);
  mY = ofClamp(mY, 0, ofGetHeight() - 1);
}
コード例 #15
0
ファイル: Particle.cpp プロジェクト: stdmtb/3s1e
//--------------------------------------------------------------
Particle::Particle() {
   
    uniquef     = ofRandomuf();
    uniquei     = ofRandom(-1000000, 1000000);
    bRemove     = false;
    
    bFirstPos   = false;
    bTaken      = false;
    alpha       = 1;
    
    drag        = ofRandom(0.95, 0.96);
    radius      = 10;
    fadeSpeed   = ofRandom(0.02, 0.006);
    drawRadius  = 3;
    useHistory  = false;
    bFirstPos   = true;
    fadeInSpeed = 0.1;//ofRandom(0.01, 0.03);
    
    birthdate   = ofGetElapsedTimef();
    age         = 0;
    frameAge    = 0;
    
    maxSpeed    = 4;//ofRandom(3.0, 8.0);
    maxForce    = 0.1;//ofRandom(3.0, 8.0);
    wanderTheta = 0.0f;
}
コード例 #16
0
void DelaunayPulseIn::start ( int which_target, float start_radius, float _max_brightness, float _speed )
{
	target_index = which_target;
	speed = _speed;
	initial_radius = start_radius;
	max_brightness = _max_brightness;
	while ( !queued_pulses.empty() )
		queued_pulses.pop();
	// find all lights closer than start_radius and add
	ofxVec2f source_pos( lights->getLight(which_target).getX(), lights->getLight(which_target).getY() );
	const vector< int >& valid_lights = delaunay->getLights();
	for ( int i=0; i< valid_lights.size(); i++ )
	{
		ofxVec2f test_pos( lights->getLight(valid_lights[i]).getX(), lights->getLight(valid_lights[i]).getY() );
		float distance = (source_pos-test_pos).length();
		if ( distance < start_radius  && distance > start_radius*0.7f )
		{
			float brightness_pct = 1.0f-((distance-start_radius*0.7f)/(start_radius*0.7f));
			float brightness = max_brightness*brightness_pct/**brightness_pct*/;
			brightness *= ofRandom( 0.8f, 1.2f );
			float rand = ofRandomuf();
			rand*=rand;
			queued_pulses.push( MovingPulse( valid_lights[i], brightness, rand*0.2f ) );
		}
	}
	timer = 0;
	
}
コード例 #17
0
ファイル: SimpleGui.cpp プロジェクト: pettert/ofxXmlGui
	HorizontalRule *SimpleGui::addHR() {
		string dummy = ofToString(ofRandomuf());
		HorizontalRule *r = (HorizontalRule*)INSTANTIATE_WITH_ID("horizontalrule", dummy);
		r->width = SIMPLE_GUI_WIDTH;
		gui->addChild(r);
		return r;
	}
コード例 #18
0
ファイル: Tree.cpp プロジェクト: Terricka/TJ_CCSP16
void Tree::seed2(float dotSize, float angle, float x, float y){
    
    if(dotSize > 1.0f){
        float r = ofRandomuf(); // will give a random number between 0 and 1
        
            if(r > 0.5){
                ofCircle(x, y, dotSize);
                float newX = x + cos(angle)*dotSize;
                float newY = y + sin(angle)*dotSize;
                seed2(dotSize*0.9f, angle - angleOffSetA, newX, newY); // changing the position of x and y each time
                
                
            } else {
                ofCircle(x, y, dotSize);
                float newX = x + cos(angle)*dotSize;
                float newY = y + sin(angle)*dotSize;
                seed2(dotSize*0.5f, angle - angleOffSetA, newX, newY);
                seed1(dotSize*0.7f, angle + angleOffSetB, newX, newY);
                seed2(dotSize*0.3f, angle - angleOffSetB, newX, newY);
                
            }
        
    }
    
    
}
コード例 #19
0
// - - - - - - -
// GPUGLITCHEFFECT METHODS
// - - - - - - -
void gpuGlitchEffect::refreshGlitches(){
	fbo.clear();
	
	int cnt = 1+ofRandomuf()*maxAllocations;
	vector<ofFbo> tmpFbos(cnt);
	for( auto it=tmpFbos.begin(); it!=tmpFbos.end(); ++it){
		it->allocate(round(fbo.getWidth()*(0.5+ofRandomuf()/2.0) ), round(fbo.getHeight()*(0.5+ofRandomuf()/2.0) ));
	}
//	while(cnt >= 1){
//		
//		cnt --;
//	}
	
	fbo.allocate(fboSettings);
	
}
コード例 #20
0
ファイル: Tree.cpp プロジェクト: kimm068/of_miyeon
void Tree::seed1(float dotSize, float angle, float x, float y) {
    ofSetColor(255, 0, 0);
    ofFill();
    //nested if statement
    if(dotSize >1.0f) {
        float r = ofRandomuf();    // gives you a random number between 0 & 1

        //first if statement will happen 98 of time
        if(r>0.02f) {
            ofDrawCircle(x,y,dotSize);
            float newX = x + cos(angle) * dotSize;
            float newY = y + sin(angle) * dotSize;

            seed1(dotSize*0.99f, angle+angleOffSetA, newX, newY);
            //- and + changes the angle of rotating

        }   else {
            ofDrawCircle(x,y,dotSize);
            float newX = x + cos(angle) * dotSize;
            float newY = y + sin(angle) * dotSize;
            seed1(dotSize*0.99f, angle-angleOffSetA, newX, newY);
            seed2(dotSize*0.4f, angle+angleOffSetB, newX, newY);
            seed1(dotSize*0.6f, angle-angleOffSetB, newX, newY);
        }
    }

}
コード例 #21
0
ファイル: Tree.cpp プロジェクト: Terricka/TJ_CCSP16
// void Tree:: functios from the header file
void Tree::seed1(float dotSize, float angle, float x, float y) {
    
    // nested if statment
    if(dotSize > 1.0f){
        float r = ofRandomuf(); // will give a random number between 0 and 1
        
       
            // first if statement will happpen 98% of the time
            if(r > 0.02) {
                ofCircle(x, y, dotSize);
                float newX = x + cos(angle)*dotSize;
                float newY = y + sin(angle)*dotSize;
                seed1(dotSize*0.9f, angle - angleOffSetA, newX, newY); // changing the position of x and y each time
            }   else {
                ofCircle(x, y, dotSize);
                float newX = x + cos(angle)*dotSize;
                float newY = y + sin(angle)*dotSize;
                seed1(dotSize*0.3f, angle - angleOffSetA, newX, newY);
                seed2(dotSize*0.7f, angle + angleOffSetB, newX, newY);
                seed1(dotSize*0.1f, angle - angleOffSetB, newX, newY);
            
            }
            
        }
}
コード例 #22
0
ファイル: Lighting.cpp プロジェクト: Entropy/Entropy
		//--------------------------------------------------------------
		void Lighting::createRandomLights()
		{
			this->lightingSystem.clearPointLights();

			const auto positionDist = 330.0f;
			const auto radius = 60.0f;

			const auto numPointLights = 60;
			for (int i = 0; i < numPointLights; ++i)
			{
				auto offset = glm::vec3(ofRandom(-positionDist, positionDist), 0.0f, ofRandom(-positionDist, positionDist));
				auto color = glm::normalize(glm::vec3(ofRandomuf(), ofRandomuf(), ofRandomuf()));
				auto light = ofxRTK::lighting::PointLight(offset, color, radius, 6000.0f);
				this->lightingSystem.addPointLight(light);
			}
		}
コード例 #23
0
colonyCell::colonyCell(const ofPoint initialPosition, const cellParams& params): _params(params)
{
    if (!isInsideBoard(initialPosition)){
        position = ofPoint(ofRandom(ofGetWidth()),ofGetHeight());
    } else {
        position = ofPoint(initialPosition);
    }
    
    /* Default Params */
    acceleration = ofVec2f(0,0);
    velocity = ofVec2f(ofRandom(-5,5), ofRandom(-5,5));
    cellSize = 1;
    age = 0;
    nutrientLevel = 50; //Magic number
    maxSpeed = ofRandom(_params.maxSpeed_min, _params.maxSpeed_max);
    maxForce = ofRandom(_params.maxForce_min, _params.maxForce_max);
    maxSize = ofRandom(_params.maxSize_min, _params.maxSize_max);
    lifespan = ofRandom(_params.lifespanMin, _params.lifespanMax);
    fertile = ofRandomuf() > _params.fertilityRate;
    dead = false;
    hasReplicated = false;
    fertilityAge = ofRandom(lifespan* 6./13., lifespan);
    
    anchor = ofPoint(ofGetWidth(), ofGetHeight())*2; //Init value off screen and >0
}
コード例 #24
0
ファイル: MindPaint.cpp プロジェクト: labe-me/MindPaint
void MindPaint::updateBrush(){
    float scoreFactor = max(0.0, min(1.0, (score/150.0))) * (1 - ofRandomuf() * 0.10);
    moverControl->update(scoreFactor);
    brush->update(mood, scoreFactor);
    brush->pos.x = moverControl->mover.pos.x;
    brush->pos.y = moverControl->mover.pos.y;
}
コード例 #25
0
ファイル: testApp.cpp プロジェクト: 6301158/ofx-dev
//--------------------------------------------------------------
void testApp::keyReleased(int key){
	if(key == 'c' or key == 'C'){
		physics->deleteAll();
		particles.clear();
	}
	if(key == ' '){
		bCreateParticleString = false;
	}
	
	if(key == 'b' or key == 'B'){
		physics->checkBounds(!physics->boundsCheck());
	}
	
	if(key == ' '){
		if(beginParticleString){
			physics->deleteParticle(beginParticleString);
			beginParticleString = NULL;
		}
	}
	
	if(key == 'r' or key == 'R'){
		for(int i=0; i<particles.size(); i++){
			if(ofRandomuf() < 0.2f){
				float rest = ofRandom(50, 200);
				ofxParticle*b = particles[(int)ofRandom(0, particles.size())];
				while(b == particles[i]){
					b = particles[(int)ofRandom(0, particles.size())];
				}
				ofxSpring*s = new ofxSpring(particles[i], b, rest);
				physics->add(s);
			}
		}
	}
}
コード例 #26
0
ファイル: Models.cpp プロジェクト: aliaskim/WWMMM
void Ocean::setup() {
    mesh_.setMode(OF_PRIMITIVE_TRIANGLES);
    
    float w = 910;
    float h = 610;
    float l = 20;
    float lx = l;
    float lx2 = cos(ofDegToRad(60)) * l;
    float ly = cos(ofDegToRad(30)) * l;
    float nx = ceil(w / lx) + 2;
    float ny = ceil(h / ly) + 2;
    float centerX = ((nx - 1) * lx + lx2) / 2;
    float centerY = (ny - 1) * ly / 2;
    for (int y = 0; y < ny; y++) {
        float offsetX = y % 2 ? 0 : lx2;
        for (int x = 0; x < nx; x++) {
            ofVec3f v = ofVec3f(x * lx + offsetX - centerX, 0, y * ly - centerY);
            mesh_.addVertex(v);
            mesh_.addTexCoord(ofVec2f((v.x - centerX) / w, (v.z - centerY) / h));
            if (x > 0 && y > 0) {
                int i = (y - 1) * nx + x - 1;
                int j = y * nx + x - 1;
                if (y % 2) {
                    mesh_.addTriangle(i, j + 1, j);
                    mesh_.addTriangle(i, i + 1, j + 1);
                } else {
                    mesh_.addTriangle(i, i + 1, j);
                    mesh_.addTriangle(i + 1, j + 1, j);
                }
            }
        }
    }
    vector<ofMeshFace> tris = mesh_.getUniqueFaces();
    for (auto it = tris.begin(); it != tris.end(); it++) {
        ofFloatColor c(ofRandomuf(), ofRandomuf(), ofRandomuf());
        it->setColor(0, c);
        it->setColor(1, c);
        it->setColor(2, c);
    }
    mesh_.setFromTriangles(tris);
    
    shader_.load("shaders/ocean");
    texture_.loadImage("colors_line_dark.png");
    
    setPosition(0, -20, -21);
}
コード例 #27
0
void boidMotioner::setup(int numPts){
	for (int i = 0;i < numPts;i++){
		Pts.push_back(ofVec2f(ofRandomf()*100.0,
							  ofRandomf()*100.0));
		Accs.push_back(ofVec2f(0.0,0.0));
	}
	attract.set(0.0, 0.0);
	seed = ofRandomuf();
}
コード例 #28
0
ofVec2f ofxWWRenderer::randomPointInCircle(ofVec2f position, float radius){
	float randomRadius = radius * ofRandomuf();
	float randomAngle = ofRandom(360.*DEG_TO_RAD);
	
	float x = randomRadius * cos(randomAngle);
	float y = randomRadius * sin(randomAngle);
	
	return position + ofVec2f(x,y);
}
コード例 #29
0
ファイル: ofApp.cpp プロジェクト: danielmorena/ofxMetaballs
void ofApp::setup() {
	ofSeedRandom(0);
	ofSetVerticalSync(true);

	iso.setup(64);
	
	vector<ofVec3f> centers;
	for(int i = 0; i < 12; i++) {
		centers.push_back(ofVec3f(ofRandomuf(), ofRandomuf(), ofRandomuf()));
	}
	iso.setCenters(centers);
	iso.setRadius(8/32., 16./32.);
	iso.update();
	
	ofMesh mesh = iso.getMesh();
	mesh.save("out-ascii.ply", false);
	mesh.save("out-binary.ply", true);
}  
コード例 #30
0
void ofApp::drawLine(float length, float theta, int dir, int num){
    float r = ofRandomuf();
    ofSetColor(0,0,0,150);
    ofFill();
    ofDrawLine(0, 0, 0, -length);
    ofTranslate(0, -length);
    
    if(r>0.9){
        drawCircle(5);
    }
    
     if(num<mazeSize){
         
        r = ofRandomuf();
         if(r > 0.5){
             dir = 1;
         }else{
             dir = -1;
         }
         
         r = ofRandomuf();
         if(r > 0 && r < 0.4){
             ofPushMatrix();
             ofRotate(theta);
             drawLine(length, 0, dir, num + 1);
             ofPopMatrix();
         }else if(r > 0.4 && r < 0.90){
             ofPushMatrix();
             ofRotate(theta);
             drawLine(length, 90 * dir, dir,num + 1);
             ofPopMatrix();
         }else{
             ofPushMatrix();
             ofRotate(theta);
             drawLine(length, 90 * dir, dir,num + 1);
             ofPopMatrix();
             ofPushMatrix();
             ofRotate(-theta);
             drawLine(length, 90 * dir, dir,num + 1);
             ofPopMatrix();
         }
     }
}