Example #1
0
void BulletTestApp::initTest()
{

	// Clean up last test
	if ( mWorld ) {
		mWorld->clear();
	}
	
	// Used when generating terrain
	Channel32f heightField;

	// Create and add the wobbly box
	mGroundTransform.setIdentity();
	switch ( mTest ) {
	case 0:
		mGround = bullet::createRigidBox( mWorld, Vec3f( 200.0f, 35.0f, 200.0f ), 0.0f );
		bullet::createRigidSphere( mWorld, 50.0f, 64, 0.0f, Vec3f( 0.0f, -50.0f, 0.0f ) );
		break;
	case 1:
		mGround = bullet::createRigidHull( mWorld, mConvex, Vec3f::one() * 50.0f, 0.0f );
		break;
	case 2:
		mGround = bullet::createRigidMesh( mWorld, mConcave, Vec3f( 10.0f, 1.0f, 10.0f ), 0.0f, 0.0f );
		break;
	case 3:
		mGround = bullet::createRigidBox( mWorld, Vec3f( 200.0f, 35.0f, 200.0f ), 0.0f );
		break;
	case 4:
		mGround = bullet::createRigidBox( mWorld, Vec3f( 200.0f, 35.0f, 200.0f ), 0.0f );
		break;
	case 5:
		heightField = Channel32f( loadImage( loadResource( RES_IMAGE_HEIGHTFIELD_SM ) ) );
		mGround = bullet::createRigidTerrain( mWorld, heightField, -1.0f, 1.0f, Vec3f( 6.0f, 80.0f, 6.0f ), 0.0f );
		break;
	case 6:

		// ADVANCED: To add a custom class, create a standard pointer to it and 
		// pushBack it into your world. Be sure to delete this pointer when you no loinger need it
		heightField = Channel32f( loadImage( loadResource( RES_IMAGE_HEIGHTFIELD ) ) );
		mTerrain = new DynamicTerrain( heightField, -1.0f, 1.0f, Vec3f( 2.0f, 50.0f, 2.0f ), 0.0f );
		mWorld->pushBack( mTerrain );
		break;

	case 7:

		// Start capture
		if ( !mCapture ) {
			mCapture = Capture( 320, 240 );
			mCapture.start();
		}

		break;

	}

	// Set friction for box
	if ( mTest < 5 ) {
		btRigidBody* boxBody = bullet::toBulletRigidBody( mGround );
		boxBody->setFriction( 0.95f );
	}

}
Example #2
0
void Fluid2DCamAppApp::setup()
{
	glEnable( GL_TEXTURE_2D );
	
	mVelThreshold = 0.75f;
	mNumActiveFlowVectors = 0;
#if defined( CINDER_MSW )
	mVelScale = 0.5f;
	mDenScale = 0.0025f;
#elif defined( CINDER_MAC )
	mVelScale = 2.0f;
	mDenScale = 0.007f;
#endif

	mFluid2D.set( mFluid2DResX, mFluid2DResY );
	mFluid2D.enableDensity();
	mFluid2D.enableVorticityConfinement();
	mFluid2D.setNumPressureIters( 24 );
	mFluid2D.initSimData();
	
	// Create these so we can create the textures ahead of time
	mSurfVel0		= Surface32f( mFluid2DResX, mFluid2DResY, false, SurfaceChannelOrder::RGB );
	mSurfVel1		= Surface32f( mFluid2DResX, mFluid2DResY, false, SurfaceChannelOrder::RGB );
	mChanDen0		= Channel32f( mFluid2DResX, mFluid2DResY );
	mChanDen1		= Channel32f( mFluid2DResX, mFluid2DResY );
	mChanDiv		= Channel32f( mFluid2DResX, mFluid2DResY );
	mChanPrs		= Channel32f( mFluid2DResX, mFluid2DResY );
	mChanCurl		= Channel32f( mFluid2DResX, mFluid2DResY );
	mChanCurlLen	= Channel32f( mFluid2DResX, mFluid2DResY );
	mTexVel0		= gl::Texture( mSurfVel0 );
	mTexVel1		= gl::Texture( mSurfVel1 );
	mTexDen0		= gl::Texture( mChanDen0 );
	mTexDen1		= gl::Texture( mChanDen1 );
	mTexDiv			= gl::Texture( mChanDiv );
	mTexPrs			= gl::Texture( mChanPrs );
	mTexCurl		= gl::Texture( mChanCurl );
	mTexCurlLen		= gl::Texture( mChanCurlLen );
	
	mParams = params::InterfaceGl( "Params", Vec2i( 300, 400 ) );
	mParams.addParam( "Stam Step", mFluid2D.stamStepAddr() );
	mParams.addSeparator();
	mParams.addParam( "Velocity Threshold", &mVelThreshold, "min=0 max=2 step=0.001" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Input Scale", &mVelScale, "min=0 max=10 step=0.001" );
	mParams.addParam( "Density Input Scale", &mDenScale, "min=0 max=1 step=0.0001" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Dissipation", mFluid2D.velocityDissipationAddr(), "min=0 max=1 step=0.0001" );
	mParams.addParam( "Density Dissipation", mFluid2D.densityDissipationAddr(), "min=0 max=1 step=0.0001" );
	mParams.addSeparator();
	mParams.addParam( "Velocity Viscosity", mFluid2D.velocityViscosityAddr(), "min=0 max=10 step=0.000001" );
	mParams.addParam( "Density Viscosity", mFluid2D.densityViscosityAddr(), "min=0 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" );
	
	// Camera
	try {
		mCapture = Capture( 640, 480 );
		mCapture.start();
	}
	catch( ... ) {
		console() << "Failed to initialize capture" << std::endl;
	}
}
Example #3
0
void BulletTestApp::initTest()
{

	// Clean up last test
	if ( mWorld ) {
		mWorld->clear();
		mWorld->getInfo().m_sparsesdf.Reset();
	}
	
	// Used when generating terrain
	Channel32f heightField;

	// Create and add the wobbly box
	btSoftBody* body				= 0;
	btSoftBody::Material* material	= 0;
	mGroundTransform.setIdentity();
	switch ( mTest ) {
	case 0:
		mGround = bullet::createRigidBox( mWorld, Vec3f( 200.0f, 35.0f, 200.0f ), 0.0f );
		bullet::createRigidSphere( mWorld, 50.0f, 0.0f, Vec3f( 0.0f, -50.0f, 0.0f ) );
		break;
	case 1:
		mGround = bullet::createRigidHull( mWorld, mConvex, Vec3f::one() * 50.0f, 0.0f );
		break;
	case 2:
		mGround = bullet::createRigidMesh( mWorld, mConcave, Vec3f( 10.0f, 1.0f, 10.0f ), 0.0f, 0.0f );
		break;
	case 5:
		heightField = Channel32f( loadImage( loadResource( RES_IMAGE_HEIGHTFIELD_SM ) ) );
		mGround = bullet::createRigidTerrain( mWorld, heightField, -1.0f, 1.0f, Vec3f( 6.0f, 80.0f, 6.0f ), 0.0f );
		break;
	case 6:
		// ADVANCED: To add a custom class, create a standard pointer to it and 
		// pushBack it into your world. Be sure to delete this pointer when you no longer need it.
		heightField = Channel32f( loadImage( loadResource( RES_IMAGE_HEIGHTFIELD ) ) );
		mTerrain = new DynamicTerrain( heightField, -1.0f, 1.0f, Vec3f( 2.0f, 50.0f, 2.0f ), 0.0f );
		mWorld->pushBack( mTerrain );
		break;
	case 7:

		// Start capture
		if ( !mCapture ) {
			mCapture = Capture( 320, 240 );
			mCapture.start();
		}

		break;
	case 8:
		mWorld->getInfo().m_gravity = toBulletVector3( Vec3f( 0.0f, -0.5f, 0.0f ) );

		mGround = bullet::createSoftCloth( mWorld, Vec2f::one() * 180.0f, Vec2i( 18, 20 ), SoftCloth::CLOTH_ATTACH_CORNER_ALL, Vec3f( 0.0f, 0.0f, 40.0f ), Quatf( 0.0f, 0.0f, 0.0f, 0.1f ) );
		
		body = toBulletSoftBody( mGround );
		
		body->m_materials[ 0 ]->m_kAST	= 0.2f;
		body->m_materials[ 0 ]->m_kLST	= 0.2f;
		body->m_materials[ 0 ]->m_kVST	= 0.2f;
		
		body->m_cfg.kDF					= 0.9f; 
		body->m_cfg.kSRHR_CL			= 1.0f;
		body->m_cfg.kSR_SPLT_CL			= 0.0f;
		body->m_cfg.collisions			= btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS;
		
		body->getCollisionShape()->setMargin( 0.0001f );
		body->setTotalMass( 500.0f );
		body->generateClusters( 0 );

		material						= body->appendMaterial();
		material->m_kAST				= 0.5f;
		material->m_kLST				= 0.5f;
		material->m_kVST				= 1.0f;
		body->generateBendingConstraints( 1, material );

		break;
	case 9:
		heightField = Channel32f( loadImage( loadResource( RES_IMAGE_HEIGHTFIELD_SM ) ) );
		mGround = bullet::createRigidTerrain( mWorld, heightField, -1.0f, 1.0f, Vec3f( 6.0f, 80.0f, 6.0f ), 0.0f );
		break;
	default:
		mGround = bullet::createRigidBox( mWorld, Vec3f( 200.0f, 35.0f, 200.0f ), 0.0f );
		break;
	}

	// Set friction for box
	if ( mTest < 5 ) {
		btRigidBody* boxBody = bullet::toBulletRigidBody( mGround );
		boxBody->setFriction( 0.95f );
	}

}