void Fluid2DParticlesApp::setup()
{
    glEnable( GL_TEXTURE_2D );
    gl::enableAlphaBlending();
    gl::enableAdditiveBlending();

    mRgbScale = 50;
    mDenScale = 50;

    mFluid2D.set( 192, 192 );
    mFluid2D.setDensityDissipation( 0.99f );
    mFluid2D.setRgbDissipation( 0.99f );
    mVelScale = 3.0f*std::max( mFluid2D.resX(), mFluid2D.resY() );

    mParams = params::InterfaceGl( "Params", ivec2( 300, 400 ) );
    mParams.addParam( "Stam Step", mFluid2D.stamStepAddr() );
    mParams.addSeparator();
    mParams.addParam( "Velocity Input Scale", &mVelScale, "min=0 max=10000 step=1" );
    mParams.addParam( "Density Input Scale", &mDenScale, "min=0 max=1000 step=1" );
    mParams.addParam( "Rgb Input Scale", &mRgbScale, "min=0 max=1000 step=1" );
    mParams.addSeparator();
    mParams.addParam( "Velocity Dissipation", mFluid2D.velocityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
    mParams.addParam( "Density Dissipation", mFluid2D.densityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
    mParams.addParam( "Rgb Dissipation", mFluid2D.rgbDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
    mParams.addSeparator();
    mParams.addParam( "Velocity Viscosity", mFluid2D.velocityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
    mParams.addParam( "Density Viscosity", mFluid2D.densityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
    mParams.addParam( "Rgb Viscosity", mFluid2D.rgbViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
    mParams.addSeparator();
    mParams.addSeparator();
    mParams.addParam( "Vorticity Confinement", mFluid2D.enableVorticityConfinementAddr() );
    mParams.addSeparator();
    std::vector<std::string> boundaries;
    boundaries.push_back( "None" );
    boundaries.push_back( "Wall" );
    boundaries.push_back( "Wrap" );
    mParams.addParam( "Boundary Type", boundaries, mFluid2D.boundaryTypeAddr() );
    mParams.addSeparator();
    mParams.addParam( "Enable Buoyancy", mFluid2D.enableBuoyancyAddr() );
    mParams.addParam( "Buoyancy Scale", mFluid2D.buoyancyScaleAddr(), "min=0 max=100 step=0.001" );
    mParams.addParam( "Vorticity Scale", mFluid2D.vorticityScaleAddr(), "min=0 max=1 step=0.001" );

    mFluid2D.setDt( 0.1f );
    mFluid2D.enableDensity();
    mFluid2D.enableRgb();
    mFluid2D.enableVorticityConfinement();

    mParticles.setup( getWindowBounds(), &mFluid2D );
}
void Fluid2DParticleSoupApp::setup()
{
	glEnable( GL_TEXTURE_2D );

	mDenScale = 50;
	mRgbScale = 40;

	mFluid2D.set( 192, 192 );
   	mFluid2D.setDensityDissipation( 0.99f );
	mFluid2D.setRgbDissipation( 0.99f ); 
	mVelScale = 3.0f*std::max( mFluid2D.resX(), mFluid2D.resY() );
	
	mParams = params::InterfaceGl( "Params", Vec2i( 300, 400 ) );
	mParams.addParam( "Stam Step", mFluid2D.stamStepAddr() );
	mParams.addSeparator();
	mParams.addParam( "Velocity Input Scale", &mVelScale, "min=0 max=10000 step=1" );
	mParams.addParam( "Density Input Scale", &mDenScale, "min=0 max=1000 step=1" );
	mParams.addParam( "Rgb Input Scale", &mRgbScale, "min=0 max=1000 step=1" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Dissipation", mFluid2D.velocityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
	mParams.addParam( "Density Dissipation", mFluid2D.densityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
	mParams.addParam( "Rgb Dissipation", mFluid2D.rgbDissipationAddr(), "min=0.0001 max=1 step=0.0001" );     
	mParams.addSeparator();
	mParams.addParam( "Velocity Viscosity", mFluid2D.velocityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addParam( "Density Viscosity", mFluid2D.densityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addParam( "Rgb Viscosity", mFluid2D.rgbViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addSeparator();
	mParams.addParam( "Vorticity Confinement", mFluid2D.enableVorticityConfinementAddr() );
	mParams.addSeparator();
	std::vector<std::string> boundaries;
	boundaries.push_back( "None" ); boundaries.push_back( "Wall" ); boundaries.push_back( "Wrap" );
	mParams.addParam( "Boundary Type", boundaries, mFluid2D.boundaryTypeAddr() );
	mParams.addSeparator();
	mParams.addParam( "Enable Buoyancy", mFluid2D.enableBuoyancyAddr() );
	mParams.addParam( "Buoyancy Scale", mFluid2D.buoyancyScaleAddr(), "min=0 max=100 step=0.001" );
	mParams.addParam( "Vorticity Scale", mFluid2D.vorticityScaleAddr(), "min=0 max=1 step=0.001" );
	
	mFluid2D.setRgbDissipation( 0.9930f );
	mFluid2D.enableDensity();
	mFluid2D.enableRgb();
	mFluid2D.enableVorticityConfinement();
	mFluid2D.initSimData();

	mParticleSoup.setup( &mFluid2D );

	mColor = Colorf( 0.98f, 0.7f, 0.4f );
}
Example #3
0
void Fluid2DTextureApp::setup()
{
	mFrameRate = 0.0f;

	mTex = gl::Texture::create( loadImage( loadResource( RES_IMAGE ) ) );

	mFluid2D.enableTexCoord();
	mFluid2D.setTexCoordViscosity( 1.0f );

	mDenScale = 50;

	mFluid2D.set( 192, 192 );
   	mFluid2D.setDensityDissipation( 0.99f );
	mVelScale = 0.50f*std::max( mFluid2D.resX(), mFluid2D.resY() );
    
	mParams = params::InterfaceGl( "Params", ivec2( 300, 400 ) );
	mParams.addParam( "Stam Step", mFluid2D.stamStepAddr() );
	mParams.addSeparator();
	mParams.addParam( "Velocity Input Scale", &mVelScale, "min=0 max=10000 step=1" );
	mParams.addParam( "Density Input Scale", &mDenScale, "min=0 max=1000 step=1" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Dissipation", mFluid2D.velocityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
	mParams.addParam( "Density Dissipation", mFluid2D.densityDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
	mParams.addParam( "TexCoord Dissipation", mFluid2D.texCoordDissipationAddr(), "min=0.0001 max=1 step=0.0001" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Viscosity", mFluid2D.velocityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addParam( "Density Viscosity", mFluid2D.densityViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addParam( "TexCoord Viscosity", mFluid2D.texCoordViscosityAddr(), "min=0.000001 max=10 step=0.000001" );
	mParams.addSeparator();
	//mParams.addParam( "Vorticity Confinement", mFluid2D.enableVorticityConfinementAddr() );
	//mParams.addSeparator();
	std::vector<std::string> boundaries;
	boundaries.push_back( "None" ); boundaries.push_back( "Wall" ); boundaries.push_back( "Wrap" );
	mParams.addParam( "Boundary Type", boundaries, mFluid2D.boundaryTypeAddr() );
	mParams.addSeparator();
	mParams.addParam( "Enable Buoyancy", mFluid2D.enableBuoyancyAddr() );
	mParams.addParam( "Buoyancy Scale", mFluid2D.buoyancyScaleAddr(), "min=0 max=100 step=0.001" );
	mParams.addParam( "Vorticity Scale", mFluid2D.vorticityScaleAddr(), "min=0 max=1 step=0.001" );
	
	mTriMesh = ci::TriMesh::create( TriMesh::Format().positions(2).texCoords0(2) );

	// Points and texture coordinates
	for( int j = 0; j < mFluid2D.resY(); ++j ) {
		for( int i = 0; i < mFluid2D.resX(); ++i ) {
			mTriMesh->appendPosition( vec2( 0.0f, 0.0f ) );
			mTriMesh->appendTexCoord0( vec2( 0.0f, 0.0f ) );
		}
	}
	// Triangles
	for( int j = 0; j < mFluid2D.resY() - 1; ++j ) {
		for( int i = 0; i < mFluid2D.resX() - 1; ++i ) {
			int idx0 = (j + 0)*mFluid2D.resX() + (i + 0 );
			int idx1 = (j + 1)*mFluid2D.resX() + (i + 0 );
			int idx2 = (j + 1)*mFluid2D.resX() + (i + 1 );
			int idx3 = (j + 0)*mFluid2D.resX() + (i + 1 );
			mTriMesh->appendTriangle( idx0, idx1, idx2 );
			mTriMesh->appendTriangle( idx0, idx2, idx3 );
		}
	}
	
	//console() << mFluid2D << std::endl;
}