//----------------------------------------------------------------------------
// streaming
//----------------------------------------------------------------------------
Object* ParticleController::Factory (Stream& rkStream)
{
    ParticleController* pkObject = new ParticleController;
    Stream::Link* pkLink = new Stream::Link(pkObject);
    pkObject->Load(rkStream,pkLink);
    return pkObject;
}
void matrixP::update() {
	if(mRenderAuto) {
		framecounter++;
		if(framecounter==CYCLELIMIT) {
			typecounter++;
			mGhostGoal.x = Rand::randFloat(0.0f, getWindowWidth() - 1.0f);
			mGhostGoal.y = Rand::randFloat(0.0f, getWindowHeight() - 1.0f);
			mStepX = (mGhostGoal.x - mGhostMouse.x)/CYCLELIMIT;
			mStepY = (mGhostGoal.y - mGhostMouse.y)/CYCLELIMIT;
			framecounter = 0;
		}
		if(typecounter==4) {
			mRenderOrdered = !mRenderOrdered;
			typecounter = 1;
		}
		mRenderColor = typecounter;
		
		mGhostMouse.x += mStepX;
		mGhostMouse.y += mStepY;

		mParticleController.update(mRenderColor, mRenderOrdered, mGhostMouse);
	}
	else mParticleController.update(mRenderColor, mRenderOrdered, mMouseLoc);
	printStats();
}
void HellCinderApp::update()
{
    if (particleCount < maxParticles) {
        particleController.addParticles( particleIncrement );
        particleCount += particleIncrement;
    }
    
    particleController.update(channel);
}
void TutorialApp::update()
{
	if( ! mChannel ) return;
	
	if( mIsPressed )
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN, mMouseLoc, mMouseVel );
	
	mParticleController.update( mPerlin, mChannel, mMouseLoc );
}
Exemple #5
0
void chapter3App::update()
{
    if (! mChannel ) return;
    
    if( mIsPressed )
        mParticleController.addParticles( 5, mMouseLoc, mMouseVel );
    
    mParticleController.update(perlin, mChannel, mMouseLoc );
}
Exemple #6
0
void Box2DTestApp::update()
{
	if (mousePressed)
		particleController.addParticle(mousePos);
	particleController.update();

	// step physics world
	float32 timeStep = 1.0f / 60.0f;
	int32 velocityIterations = 6;
	int32 positionIterations = 2;
	world.Step(timeStep, velocityIterations, positionIterations);
}
Exemple #7
0
void FlockingApp::update()
{
	// UPDATE CAMERA
	mEye = vec3( 0.0f, 0.0f, mCameraDistance );
	mCam.lookAt( mEye, mCenter, mUp );
	gl::setMatrices( mCam );
	gl::rotate( mSceneRotation );
	
	// UPDATE PARTICLE CONTROLLER
	if( mCentralGravity ) mParticleController.pullToCenter( mCenter );
	mParticleController.update();
}
Exemple #8
0
void FlockingApp::update()
{
	// UPDATE CAMERA
	mEye = Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCam.lookAt( mEye, mCenter, mUp );
	gl::setMatrices( mCam );
	gl::rotate( mSceneRotation );
	
	// UPDATE PARTICLE CONTROLLER AND PARTICLES
	mParticleController.applyForceToParticles( mZoneRadius * mZoneRadius );
	if( mCentralGravity ) mParticleController.pullToCenter( mCenter );
	mParticleController.update( mFlatten );
}
Exemple #9
0
void FlockingApp::update()
{
	if( mLowerThresh > mHigherThresh ) mHigherThresh = mLowerThresh;

	mParticleController.applyForceToPredators( mZoneRadius, 0.4f, 0.7f );	
	mParticleController.applyForceToParticles( mZoneRadius, mLowerThresh, mHigherThresh, mAttractStrength, mRepelStrength, mOrientStrength );
	if( mCentralGravity ) mParticleController.pullToCenter( mCenter );
	mParticleController.update( mFlatten );
	
	mEye	= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCam.lookAt( mEye, mCenter, mUp );
	gl::setMatrices( mCam );
	gl::rotate( mSceneRotation );
}
Exemple #10
0
void VideoPanApp::update()
{
	if( mMovie.checkNewFrame() ) {
		mMovieFrame = gl::Texture(mMovie.getTexture());
		if( particleCount < maxParticles ) {
			mParticleController.addParticle( gl::Texture(mMovie.getTexture()) );
			particleCount++;
			mMovie.stepForward();
		}
	} else {
		mParticleController.setWidth(mParticleWidth);
		mParticleController.setPixelOffset(mPixelOffset);
		mParticleController.update();
	}
}
Exemple #11
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 );
}
Exemple #12
0
void TutorialApp::setup()
{
	Url url( "http://www.libcinder.org/media/tutorial/paris.jpg" );
	mImage = gl::Texture( loadImage( loadUrl( url ) ) );

	mParticleController.addParticles( 250 );
}
Exemple #13
0
void Box2DTestApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();

	particleController.draw();
}
Exemple #14
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);
    
}
void JtChapterOneApp::draw()
{
    //float gray = sin( getElapsedSeconds() ) * 0.5f + 0.5f;
    //gl::clear( Color( gray, gray, gray ), true);

    myPController.draw();
}
Exemple #16
0
void TutorialApp::draw()
{
    if(isFirst) {
        gl::clear( Color( 0, 0, 0 ), true );
        isFirst = false;
    }

    gl::enableAlphaBlending();
	
	if( mDrawImage ){
		mTexture.enableAndBind();
		gl::draw( mTexture, getWindowBounds() );
	}
    
//	if( mDrawParticles ){
		glDisable( GL_TEXTURE_2D );
		mParticleController.draw();
//	}
    
    if( mDrawImage ){
        mOverlay.enableAndBind();
        gl::draw( mOverlay, getWindowBounds() );
    }

//	if( mSaveFrames ){
//		writeImage( getHomeDirectory() / ( "image_" + toString( getElapsedFrames() ) + ".png" ), copyWindowSurface() );
//	}
}
void TutorialApp::draw()
{	
	gl::clear( Color( 0, 0, 0 ), true );
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	// DRAW PARTICLES
	mParticleController.draw();
	
	// DRAW ZONE DIAGRAM
	gl::disableDepthRead();
	gl::disableDepthWrite();
	gl::setMatricesWindow( getWindowSize() );
	gl::pushModelView();
        gl::translate( Vec3f( 117.0f, getWindowHeight() - 117.0f, 0.0f ) );
        
        gl::color( ColorA( 1.0f, 0.25f, 0.25f, 1.0f ) );
        gl::drawSolidCircle( Vec2f::zero(), mZoneRadius );
    
        gl::color( ColorA( 0.25f, 0.25f, 1.0f, 1.0f ) );
        gl::drawSolidCircle( Vec2f::zero(), mThresh * mZoneRadius );    
        
        gl::color( ColorA( 1.0f, 1.0f, 1.0f, 0.25f ) );
        gl::drawStrokedCircle( Vec2f::zero(), 100.0f );
	gl::popModelView();
	
	// DRAW PARAMS WINDOW
	params::InterfaceGl::draw();
}
void Path2dApp::setup(){
  thread.setup();
  controller = new ParticleController();
  controller->setup();
  mPerlin = Perlin();
  mImage = gl::Texture( loadImage( loadResource( "header.png" ) ) );
}
Exemple #19
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 );
}
Exemple #20
0
void FlockingApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'p' ){
		mParticleController.addParticles( NUM_PARTICLES_TO_SPAWN );
	} else if( event.getChar() == ' ' ){
		mSaveFrames = !mSaveFrames;
	}
}
Exemple #21
0
void syphonImpApp::renderSceneToFbo()
{
	// this will restore the old framebuffer binding when we leave this function
	// on non-OpenGL ES platforms, you can just call mFbo.unbindFramebuffer() at the end of the function
	// but this will restore the "screen" FBO on OpenGL ES, and does the right thing on both platforms
	gl::SaveFramebufferBinding bindingSaver;
	
	// bind the framebuffer - now everything we draw will go there
	myFbo.bindFramebuffer();
    gl::setViewport(myFbo.getBounds() );
    gl::setMatricesWindow( myFbo.getSize(), false );
	
	// clear out the FBO with blue
	gl::clear();
   mParticleController.update();
    mParticleController.draw();
    
}
Exemple #22
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);

}
void TutorialApp::update()
{

    // Stop repulsing for now.
	//mParticleController.repulseParticles();

    // UPDATE CAMERA
	mEye = Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCam.lookAt( mEye, mCenter, mUp );
	gl::setMatrices( mCam );
	gl::rotate( mSceneRotation );
	
	// UPDATE PARTICLE CONTROLLER
    mParticleController.applyForce( mZoneRadius * mZoneRadius, mThresh );    
	if( mCentralGravity ) mParticleController.pullToCenter( mCenter );
    
	mParticleController.update( mFlatten );
}
Exemple #24
0
void Day57App::draw()
{
    gl::clear(Color(0, 0, 0), true);
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
    gl::color(ColorA(1.0f, 1.0f, 1.0f, 1.0f));
    mParticleController.draw();
    //	mParticleController.drawConnections();
}
void HellCinderApp::draw()
{
    
    gl::clear( Color( 0, 0, 0 ), true );
	
	glDisable( GL_TEXTURE_2D );
	//gl::draw( texture, getWindowBounds() );

	particleController.draw();
}
Exemple #26
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 );
}
void RoboticaProjectApp::update()
{
    //get the latest pcm buffer from the track
	mPcmBuffer = mTrack->getPcmBuffer();
    
    if( mPcmBuffer ){
       // mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT )
        fftRef = audio::calculateFft( mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT ), bandCount );
        if(mAddParticle){
            particleC->addParticle(mAddPos);
            mAddParticle = false;
        }
        
        particleC->update(fftRef, bandCount, getElapsedSeconds());
    }    
        
    
    
}
Exemple #28
0
void TutorialApp::draw()
{	
	gl::clear( Color( 0, 0, 0 ), true );
	
	mImage.enableAndBind();
	gl::draw( mImage, getWindowBounds() );
	
	glDisable( GL_TEXTURE_2D );
	glColor3f( 1, 1, 1 );
	mParticleController.draw();
}
Exemple #29
0
void VideoPanApp::draw()
{
	// clear out the window with black
	
	gl::clear( Color( 0, 0, 0 ) ); 
	
	gl::setMatricesWindow(getWindowSize(), true);

	gl::rotate(90);
	mParticleController.draw();
	params::InterfaceGl::draw();
}
Exemple #30
0
void FlockingApp::draw()
{	
	gl::clear( Color( 0, 0, 0.01f ), true );
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	// DRAW PARTICLES
	glColor4f( ColorA( 1.0f, 1.0f, 1.0f, 1.0f ) );
	mParticleController.draw();
	
	// DRAW PARAMS WINDOW
	mParams->draw();
}