Exemplo n.º 1
0
void Day57App::setup()
{
    Rand::randomize();
    
    mCenter = vec3(getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, 0.0f);
    mCentralGravity = false;
    mFlatten = false;
    mSaveFrames = false;
    mIsRenderingPrint = false;
    mZoneRadius = 80.0f;
    mLowerThresh = 0.5f;
    mHigherThresh = 0.8f;
    mAttractStrength = 0.004f;
    mRepelStrength = 0.01f;
    mOrientStrength = 0.01f;
    
    // SETUP CAMERA
    mCameraDistance = 350.0f;
    mEye = vec3(0.0f, 0.0f, mCameraDistance);
    mCenter = vec3(0.);
    mUp = vec3(0., 1., 0.);
//    mCam.lookAt(vec3(0.,0.,20.), vec3(0.));
    mCam.setPerspective(75.0f, getWindowAspectRatio(), 5.0f, 5000.0f);
    
    
    // CREATE PARTICLE CONTROLLER
    mParticleController.addParticles(NUM_INITIAL_PARTICLES);
    
}
Exemplo n.º 2
0
void FlockingApp::setup()
{	
	mCentralGravity = true;
	mFlatten		= false;
	mZoneRadius		= 30.0f;
	
	// SETUP CAMERA
	mCameraDistance = 500.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f::zero();
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 2000.0f );

	// SETUP PARAMS
	mParams = params::InterfaceGl::create( "Flocking", Vec2i( 200, 220 ) );
	mParams->addParam( "Scene Rotation", &mSceneRotation, "opened=1" );
	mParams->addSeparator();
	mParams->addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1500.0 step=50.0 keyIncr=s keyDecr=w" );
	mParams->addParam( "Center Gravity", &mCentralGravity, "keyIncr=g" );
	mParams->addParam( "Flatten", &mFlatten, "keyIncr=f" );
	mParams->addSeparator();
	mParams->addParam( "Zone Radius", &mZoneRadius, "min=10.0 max=100.0 step=1.0 keyIncr=z keyDecr=Z" );
	
	// CREATE PARTICLE CONTROLLER
	mParticleController.addParticles( NUM_INITIAL_PARTICLES );
}
Exemplo n.º 3
0
void TutorialApp::setup()
{
	Url url( "http://www.libcinder.org/media/tutorial/paris.jpg" );
	mImage = gl::Texture( loadImage( loadUrl( url ) ) );

	mParticleController.addParticles( 250 );
}
Exemplo n.º 4
0
void FlockingApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'p' ){
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN );
	} else if( event.getChar() == ' ' ){
		mSaveFrames = !mSaveFrames;
	}
}
Exemplo n.º 5
0
void syphonImpApp::setup()
{
    gl::Fbo::Format format;
    //	format.setSamples( 4 ); // uncomment this to enable 4x antialiasing
	myFbo = gl::Fbo( WIDTHFBO,HEIGHTFBO, format );
    
    mParticleController.addParticles(WIDTHFBO,HEIGHTFBO,1000);

}
Exemplo n.º 6
0
void chapter3App::update()
{
    if (! mChannel ) return;
    
    if( mIsPressed )
        mParticleController.addParticles( 5, mMouseLoc, mMouseVel );
    
    mParticleController.update(perlin, mChannel, mMouseLoc );
}
Exemplo n.º 7
0
void TutorialApp::update()
{
	if( ! mChannel ) return;
	
	if( mIsPressed )
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN, mMouseLoc, mMouseVel );
	
	mParticleController.update( mPerlin, mChannel, mMouseLoc );
}
void HellCinderApp::update()
{
    if (particleCount < maxParticles) {
        particleController.addParticles( particleIncrement );
        particleCount += particleIncrement;
    }
    
    particleController.update(channel);
}
Exemplo n.º 9
0
void TutorialApp::update()
{
	if( ! mChannel ) return;
	
	if( mIsPressed )
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN, mMouseLoc, mMouseVel );
	
//	mParticleController.repulseParticles();
	
	if( mCentralGravity )
		mParticleController.pullToCenter();
		
	if( mAllowPerlin )
		mParticleController.applyPerlin( mPerlin );
		
	mParticleController.update( mChannel, mMouseLoc );
}
Exemplo n.º 10
0
void Path2dApp::update(){
  
  //cout<<thread.mPoints.size()<<endl;
  //cout<<(float)app::getFrameRate()<<endl;

  if(frameCount % 30 == 0){
  //float xPos = lerp( windowWidth, 0, pow(0,windowWidth+ 20));
  //float xPos = randFloat(windowWidth-20,windowWidth+20);
    float xPos = randFloat(windowWidth, windowWidth+200);
  controller->addParticles(NUM_PARTICLES_PER_FRAME, Vec2f(xPos,randFloat(windowHeight*3/8,windowHeight*5/8)), Vec2f(randFloat(),randFloat()));
  }
  thread.update();
  
  if(frameCount == 0 || frameCount % 620 == 0){
    Content *c = new Content(Vec3f(windowWidth+200,randFloat(windowHeight*3/8, windowHeight*5/8),randFloat(-1.0,-1.0)),postIndex);
    mContents.push_back(c);
    postIndex ++;
    if(postIndex>6) postIndex = 0;
  }
  
  frameCount ++;
  
  for(std::list<Content*>::iterator i = mContents.begin(); i!= mContents.end();){
    
    Content *c = (*i);
    if(c->die()){
      i = mContents.erase(i);
      delete c;
    }else{
      Vec2f steer = c->seek(thread.mPoints);
      c->addForce(steer);
      c->update();
      ++i;
    }
  }
  
  double currentTime = app::getElapsedSeconds();
  double deltaTime = currentTime - mLastTime;
  float delta = (float)app::getFrameRate() / (1.0 / deltaTime);
  
  mLastTime = currentTime;
  
	this->controller->update(delta, mPerlin, thread.mPoints);
  
}
Exemplo n.º 11
0
void FlockingApp::setup()
{	
	Rand::randomize();
	
	mCenter			= Vec3f( getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, 0.0f );
	mCentralGravity = true;
	mFlatten		= false;
	mSaveFrames		= false;
	mIsRenderingPrint = false;
	mZoneRadius		= 80.0f;
	mLowerThresh	= 0.5f;
	mHigherThresh	= 0.8f;
	mAttractStrength	= 0.004f;
	mRepelStrength		= 0.01f;
	mOrientStrength		= 0.01f;
	
	// SETUP CAMERA
	mCameraDistance = 350.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f::zero();
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 5000.0f );

	// SETUP PARAMS
	mParams = params::InterfaceGl( "Flocking", Vec2i( 200, 310 ) );
	mParams.addParam( "Scene Rotation", &mSceneRotation, "opened=1" );
	mParams.addSeparator();
	mParams.addParam( "Eye Distance", &mCameraDistance, "min=100.0 max=2000.0 step=50.0 keyIncr=s keyDecr=w" );
	mParams.addParam( "Center Gravity", &mCentralGravity, "keyIncr=g" );
	mParams.addParam( "Flatten", &mFlatten, "keyIncr=f" );
	mParams.addSeparator();
	mParams.addParam( "Zone Radius", &mZoneRadius, "min=10.0 max=100.0 step=1.0 keyIncr=z keyDecr=Z" );
	mParams.addParam( "Lower Thresh", &mLowerThresh, "min=0.025 max=1.0 step=0.025 keyIncr=l keyDecr=L" );
	mParams.addParam( "Higher Thresh", &mHigherThresh, "min=0.025 max=1.0 step=0.025 keyIncr=h keyDecr=H" );
	mParams.addSeparator();
	mParams.addParam( "Attract Strength", &mAttractStrength, "min=0.001 max=0.1 step=0.001 keyIncr=a keyDecr=A" );
	mParams.addParam( "Repel Strength", &mRepelStrength, "min=0.001 max=0.1 step=0.001 keyIncr=r keyDecr=R" );
	mParams.addParam( "Orient Strength", &mOrientStrength, "min=0.001 max=0.1 step=0.001 keyIncr=o keyDecr=O" );
	
	// CREATE PARTICLE CONTROLLER
	mParticleController.addParticles( NUM_INITIAL_PARTICLES );
	mParticleController.addPredators( NUM_INITIAL_PREDATORS );
}
Exemplo n.º 12
0
void TutorialApp::setup()
{	

	mCentralGravity = true;
    mFlatten        = true; //makes it easy to see the effects in 2D...while we are experimenting
	mZoneRadius		= 65.0f;
    mThresh         = 0.65f;
    
    //define the camera
    mCameraDistance = 500.0f;
    mEye    = Vec3f( 0.0f, 0.0f, mCameraDistance ); //position of the camera
    mCenter = Vec3f::zero(); //the location in 3D space that the camera points at
    mUp     = Vec3f::yAxis(); //the camera's up direction

    // Takes four parameters:
    // (1) foV : the smaller the number the tighter the fustrum (usually between 60.0 and 90.0)
    // (2) aspect ratio of the application window
    // (3) near clipping plane
    // (4) far clipping plane
    mCam.setPerspective( 75.0f, getWindowAspectRatio(), 50.0f, 2000.0f ); 
    
    
    // Initialize the Params object
    mParams = params::InterfaceGl( "Flocking", Vec2i( 200, 240 ) );
    // We tell Params that we want it control the mSceneRotation variable...during runtime!
    // It expects the addr in memory of the variable...that's what & is.
    // So, it will include an arc-ball in the scene.
    mParams.addParam( "Scene Rotation", &mSceneRotation, "opened=1" );
    mParams.addSeparator();
    mParams.addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1500.0 step=50.0 keyIncr=s keyDecr=w" );
    mParams.addParam( "Center Gravity", &mCentralGravity, "keyIncr=g" );
	mParams.addParam( "Flatten", &mFlatten, "keyIncr=f" );
	mParams.addSeparator();
	mParams.addParam( "Zone Radius", &mZoneRadius, "min=10.0 max=100.0 step=1.0 keyIncr=z keyDecr=Z" );
	mParams.addParam( "Thresh", &mThresh, "min=0.025 max=1.0 step=0.025 keyIncr=t keyDecr=T" );    
    
    // CREATE PARTICLE CONTROLLER
	mParticleController.addParticles( NUM_INITIAL_PARTICLES );

    
}
Exemplo n.º 13
0
// Draw
void PixarDemo2012::draw()
{

    gl::clear( ColorA(0.0f,0.0f,0.0f,1.0f) );

    //render Gradient FBO
    if(!drawMindField && !drawCloth)
    {
        renderGradientFBO();
    }

    gl::setViewport( getWindowBounds() );
    gl::setMatricesWindow( getWindowSize(), true );

    gl::clear( ColorA(0.0f,0.0f,0.0f,1.0f) );

    // draw FBO bg
    gl::color(1.0f,1.0f,1.0f);
    gl::draw( mGradientFBO.getTexture(0), Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );

    if ( drawTitle ) {
        if ( mTime > 10.0f ) drawTitle = false;
        theTitle.Render();
    }


    // FFT stuff
    generateWaveforms();

    if ( drawMindField ) {
        theMindField.Render();
        drawFader();
        return;
    }
    if ( drawCubes ) {
        gl::popMatrices();
        gl::setMatrices( theCubes.cubesCamera );
        theCubes.Render();
    }
    if ( drawCloth ) {

        theCloth.Render();
        drawFader();
        return;
    }


    // Balls
    if ( !drawCubes ) {
        gl::setMatricesWindow( getWindowSize(), true );
        if (makeBall > 0.075f) mParticleController.addParticles(1,makeBall*100.0f,mTime);
        mParticleController.draw();
    }
    if ( drawFPS ) {
        string mString;
        mString = str(boost::format("FRAMERATE: %f") % getAverageFps() );
        gl::drawString( mString, Vec2f( 10.0f, 10.0f ), Color::white(), mFont );
    }

    drawFader();

}
Exemplo n.º 14
0
void TutorialApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'p' ){
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN );
	}
}
Exemplo n.º 15
0
//------------------------------------------------------------
//--
//------------------------------------------------------------
void cdr_Snow::setup()
{
    setFrameRate(20);

    myParticles.addParticles(100);
}