Ejemplo n.º 1
0
void BasicApp::setup()
{
	setWindowSize(800, 600);

	configFilename = "config.xml"; 
	bgColor = Color::black();

	showRect = true;
	rectRot = 0.f;
	rectColor = ColorA::gray(0.5f);
	rectPosition = Vec3f::zero();

	showCircle = true;
	circleRadius = 70.f;
	circleColor = ColorA::gray(0.7f);
	circlePosition = Vec3f::zero();

	text = "Config Block for Cinder";

	doubleParam = 0.0; intParam = 0; quatfParam = Quatf();
	
	enumNames.push_back( "Orange" );
	enumNames.push_back( "Apple" );
	enumNames.push_back( "Banana" );
	enumValue = 0;

	//-----------------------------------------------------------------------------

    mParams = params::InterfaceGl( "Settings", Vec2i( 400, 550 ) );
    mConfig = new config::Config(&mParams);
    
    mParams.addParam("Configuration file name", &configFilename);
    mParams.addButton("Save config", bind(&BasicApp::saveConfig, this));
    mParams.addButton("Load config", bind(&BasicApp::loadConfig, this));
    mParams.addSeparator();
	
    mConfig->addParam("Background color", &bgColor);
    mConfig->addParam("Text", &text);
    mParams.addSeparator();

	mConfig->newNode("Rectangle");
    mConfig->addParam("Show rectangle", &showRect);
    mConfig->addParam("Rectangle rotation", &rectRot);
    mConfig->addParam("Rectangle color", &rectColor);
	mConfig->addParam("Rectangle position", &rectPosition);
    mParams.addSeparator();

	mConfig->newNode("Circle");
	mConfig->addParam("Show circle", &showCircle);
    mConfig->addParam("Circle radius", &circleRadius);
    mConfig->addParam("Circle color", &circleColor);
	mConfig->addParam("Circle position", &circlePosition);

	mConfig->newNode("Other");
	mConfig->addParam("Double type parameter", &doubleParam);
	mConfig->addParam("Int type parameter", &intParam);
	mConfig->addParam("Quatf type parameter", &quatfParam);
	mConfig->addParam("Enum type parameter", enumNames, &enumValue);

}
void LookAroundYouApp::setup()
{
	Rand::randomize();
	
    mVolume = 1.0;
    
    // Setup GUI
	getWindow()->setTitle("MPCDigital App");
	mParams = params::InterfaceGl( "Settings", Vec2i( 300, 200 ) );
	mParams.addParam( "Framerate", &mFrameRate, "", true );
    mParams.addSeparator();
    mParams.addParam("Speed", &Boid::speedMultiplier, "min=0.5 max=5.0 step=0.01");
    mParams.addParam("Radius", &Boid::radiusMultiplier, "min=0.5 max=5.0 step=0.01");
    mParams.addParam("Range", &Boid::range, "min=10.0 max=100 step=0.1");
    mParams.addSeparator();
    mParams.addParam("Master Volume", &mVolume, "min=0 max=1.0 step=0.01");
    
    
    // Setup Audio
    AudioDevice::printDeviceMap();
    mAudioDevice = make_shared<AudioDevice>();
    mAudioDevice->setup(0);
    mAudioDevice->setAmbientReverb(FMOD_PRESET_UNDERWATER);
    console() << "Channels Available: " << mAudioDevice->getNumRemainingChannels() << endl;
    
    DataSourceRef data = loadAsset("music/Music For Airports - 1 1.mp3");
    string musicName = mAudioDevice->registerSound(data, true, false, true);
    music = mAudioDevice->getSoundInstance(musicName, 1.0);
    music->pause();
    
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/blue.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/fliup.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/green.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/howl.wav"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/orange.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/red.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/white.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/yellow.aif"), true, true));
    
    // Setup noise generator to drive Boid motion
    mPerlin = new Perlin();
    mPerlin->setSeed(clock());
	mPerlin->setOctaves(1);
    
    // Construct Boids
    for(int i=0; i<10; i++) {
        int n = Rand::randInt(0, fxnames.size());
        SoundInstanceRef fx = mAudioDevice->getSoundInstance(fxnames[n], 1.0);
        BoidRef boid = make_shared<Boid>(mPerlin, fx);
        mBoids.push_back(boid);
    }
    
	
	// enable the depth buffer (for 3D)
	gl::enableDepthRead();
	gl::enableDepthWrite();
    gl::enableAlphaBlending();
}
Ejemplo n.º 3
0
void TestbedApp::setup()
{
	std::vector<std::string> testNames;

	testCount = 0;
	while( nullptr != g_testEntries[testCount].createFcn ) {
		testNames.push_back( g_testEntries[testCount].name );
		++testCount;
	}

	testIndex = b2Clamp(testIndex, 0, testCount-1);
	testSelection = testIndex;

	entry = g_testEntries + testIndex;
	if (entry && entry->createFcn) {
		test = entry->createFcn();
		testSelection = testIndex;
		testIndex = -1;
	}

#if ! defined( CINDER_GL_ES )
	mParams = params::InterfaceGl( "Params", ivec2( 250, 400 ) );
	mParams.addParam( "Tests", testNames, &testSelection );
	mParams.addSeparator();
	mParams.addParam( "Vel Iters", &settings.velocityIterations, "min=1 max=500 step=1" );
	mParams.addParam( "Pos Iters", &settings.positionIterations, "min=0 max=100 step=1" );
	mParams.addParam( "Pcl Iters", &settings.particleIterations, "min=1 max=100 step=1" );
	mParams.addParam( "Hertz", &settingsHz, "min=1 max=100 step=1" );
	mParams.addSeparator();
	mParams.addParam( "Sleep", &settings.enableSleep );
	mParams.addParam( "Warm Starting", &settings.enableWarmStarting );
	mParams.addParam( "Time of Impact", &settings.enableContinuous );
	mParams.addParam( "Sub-Stepping", &settings.enableSubStepping );
	mParams.addParam( "Strict Particle/Body Contacts", &settings.strictContacts );
	mParams.addSeparator( "Draw" );
	mParams.addParam( "Shapes", &settings.drawShapes );
	mParams.addParam( "Particles", &settings.drawParticles );
	mParams.addParam( "Joints", &settings.drawJoints );
	mParams.addParam( "AABBs", &settings.drawAABBs) ;
	mParams.addParam( "Contact Points", &settings.drawContactPoints );
	mParams.addParam( "Contact Normals", &settings.drawContactNormals );
	mParams.addParam( "Contact Impulses", &settings.drawContactImpulse );
	mParams.addParam( "Friction Impulses", &settings.drawFrictionImpulse );
	mParams.addParam( "Center of Masses", &settings.drawCOMs );
	mParams.addParam( "Statistics", &settings.drawStats );
	mParams.addParam( "Profile", &settings.drawProfile );
#else
	float s = 1080.0f/480.0f;
	Rectf r = Rectf( 0, 0, 50*s, 50*s );
	mLeftButton = r + vec2( 0, getWindowHeight() - r.getHeight() );
	mRightButton = r + vec2( getWindowWidth() - r.getWidth(), getWindowHeight() - r.getHeight() );
#endif
}
void DelaunayMeshMaker::setup()
{
	mSurface = loadImage( app::loadAsset( "texture0.jpg" ) );
	
	int width = mSurface.getWidth();
	int height = mSurface.getHeight();
	app::setWindowSize( width, height );

	mFbo = gl::Fbo( width, height, false );

	mBorderPoints.push_back( Vec2f::zero() );
	mBorderPoints.push_back( Vec2f( (float)width, 0 ) );
	mBorderPoints.push_back( Vec2f( (float)width ,(float)height ) );
	mBorderPoints.push_back( Vec2f( 0 ,(float)height ) );

	mMesh.clear();

	mParams = params::InterfaceGl( "Parameters", Vec2i( 300, 250 ) );
	mParams.addParam( "Alpha", &mAlpha, "max=1.0 min=0.0 step=0.005" );
	mParams.addParam( "Blend", &mBlend );
	mParams.addParam( "Phong Shading", &mApplyPhongShading );
	mParams.addParam( "Depth Offset", &mDepthOffset, "step=0.1" );
	mParams.addParam( "Draw wireframe", &mDrawWireframe );
	
	mParams.addSeparator();
	mParams.addText("Edge detection");
	mParams.addParam( "Edge detection scale down", &mScaleDown, "min=1" );
	mParams.addParam( "Minimum threshold", &mCannyMinThreshold, "min=0.0f" );
	mParams.addParam( "Maximum threshold", &mCannyMaxThreshold, "min=0.0f" );

	mParams.addSeparator();
	mParams.addButton( "Tesselate", std::bind( &DelaunayMeshMaker::tesselate, this ) );

	mScaleDown			= 8;
	mScaleDownPrev		= mScaleDown;
	mCannyMinThreshold	= 60.0;
	mCannyMaxThreshold	= 70.0;
	mAlpha				= 0.0f;
	mBlend				= false;
	mApplyPhongShading	= false;
	mDrawWireframe		= false;
	mDepthOffset		= 0.0f;
	mPrevDepthOffset	= mDepthOffset;
	mPrevBlend			= mBlend;

	mPhongShader = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl") );

	mEdgeDetectSurface = edgeDetect( Surface8u( mSurface ), mCannyMinThreshold, mCannyMaxThreshold, mScaleDownPrev );

	mTesselator = Tesselator::makeTesselator();
	mTesselator->sDone.connect( boost::bind( &DelaunayMeshMaker::onTesselationDone, this ) );
}
Ejemplo n.º 5
0
void FxApp::setupParams()
{
	mParams.clear();

	mParams.addParam( "Effect", mEffectNames, &mCurrentEffect );

	mParams.addSeparator();

	mParams.addText( mEffects[ mCurrentEffect ]->getName() );
	mEffects[ mCurrentEffect ]->addToParams( mParams );

	mParams.addSeparator();
	mParams.addParam( "Fps", &mFps, "", true );
}
Ejemplo n.º 6
0
void bordaiApp::setup() {
	mParams = params::InterfaceGl("bordai", Vec2i(300, 175));
	mParams.addParam("Screen width", &mWindowSize.x, "", true);
	mParams.addParam("Screen height", &mWindowSize.y, "", true);
	mParams.addParam("Camera width", &mCameraLensSize.x, "min=128 max=1024 step=64 keyIncr=W keyDecr=w");
	mParams.addParam("Camera height", &mCameraLensSize.y, "min=128 max=1024 step=64 keyIncr=H keyDecr=h");
	mParams.addSeparator();
	mParams.addText("Press space to apply new camera resolution");
	mParams.addText("Press 'p' to pause/play camera");
	mParams.addSeparator();
	mParams.addParam("Framerate", &mFrameRate, "min=5.0 max=70.0 step=5.0 keyIncr=+ keyDecr=-");
	
	mHaarDetector = HaarDetector( getResourcePath( "haarcascade_frontalface_alt2.xml" ) );
	mCamera.startCapturing(mCameraLensSize.x, mCameraLensSize.y);
}
void SmilesApp::setup()
{	
    mSmileLimit = 4.0f;
    mSmileAverageNumOfFrames = 10;
    mCamIndex = 0;
    mFps = getAverageFps();
    
    try {
		mCapture = Capture( CAMWIDTH, CAMHEIGHT );
		mCapture.start();
	}
	catch( ... ) {
		console() << "Failed to initialize capture" << std::endl;
	}
    
    mSmileRect = Rectf(300,100,600,400);
    setupSmileDetector(mSmileRect.getInteriorArea().getWidth(), mSmileRect.getInteriorArea().getHeight());
    console()<< mSmileRect.getInteriorArea().getWidth() << mSmileRect.getInteriorArea().getHeight() << endl;
	mSmileThreshold = 0;
	mSmileAverageIndex = 0;
    
    mParams = params::InterfaceGl( "Parameters", Vec2i( 220, 170 ) );
    mParams.addParam( "FPS", &mFps,"", true );
    mParams.addSeparator();
	mParams.addParam( "SmileResponse", &mSmileResponse, "", true );
    mParams.addParam( "SmileThreshold", &mSmileThreshold, "", true );
    
    mParams.addParam( "mSmileLimit", &mSmileLimit );
    mParams.addParam( "mSmileAverageNumOfFrames", &mSmileAverageNumOfFrames );
    
}
Ejemplo n.º 8
0
void f6_structure::setup()
{
	// SET WINDOW
	setWindowSize(1920, 1080);
	setFrameRate(30.f);
	gl::color(Color::black());

	// SETUP PARTICLE SYSTEMS
	ParticleSystem ps1;
	ps1.setup();
	pss.push_back(ps1);

	// SETUP LISTENER
	Listener& listener = Listener::getInstance();
	listener.setup();

	// SETUP TRACKER
	//t.setup();

	// SETUP PARAMS
	mParams = params::InterfaceGl("Parameters", Vec2i(200, 150));
	mParams.addParam("Particle ID", &pf.d_particleToCreate, "keyIncr=+ keyDecr=-");
	mParams.addSeparator();
	mParams.addParam("Total particles", &mTotalParticles, "readonly=1");
	mParams.addParam("Volume", &mVolume, "readonly=1");
	mParams.addParam("Scale", &listener.mScale, "min=0.1 max=40.0 step=0.1");
	
}
Ejemplo n.º 9
0
void KaleidoscopeApp::setup()
{
    mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 300 ) );
    mParams.addParam( "Fps", &mFps, "", true );
    mParams.addParam( "Vertical sync", &mVerticalSyncEnabled );
    mParams.addSeparator();
    mNumReflectionLines = 3;
    mParams.addParam( "Reflection lines", &mNumReflectionLines, "min=0, max=32" );
    mRotation = 0.f;
    mParams.addParam( "Rotation", &mRotation, "step=.01" );
    mCenter = Vec2f( .5f, .5f );
    mParams.addParam( "Center X", &mCenter.x, "min=0 max=1 step=.005 group='Center'" );
    mParams.addParam( "Center Y", &mCenter.y, "min=0 max=1 step=.005 group='Center'" );

    mTexture = loadImage( loadAsset( "tx.jpg" ) );
    mTexture.setWrap( true, true );

    try
    {
        mShader = gl::GlslProg( loadAsset( "Kaleidoscope.vert" ),
                                loadAsset( "Kaleidoscope.frag" ) );
    }
    catch ( gl::GlslProgCompileExc &exc )
    {
        console() << exc.what() << endl;
    }
}
Ejemplo n.º 10
0
void SpirographApp::setup()
{
	mLoc = Vec2f(getWindowWidth()/2, getWindowHeight()/2);
	
	mSpirograph = new SpirographPoint();
	
	// Base Spirograph parameters
	mAngle = 0.0f;
	mRadius = 65.0f;
	
	mIncAngle = 0.02f;
	
	
	// Setup the parameters
	mParams = params::InterfaceGl("Spirograph Parameters", Vec2i(100, 200));
	
	mParams.addParam("Angle", &mAngle);
	mParams.addParam("Increment Angle", &mIncAngle);
	mParams.addParam("Radius", &mRadius);
	mParams.addSeparator();
	mParams.addParam("Spirograph Angle", &mSpirograph->mAngle);
	mParams.addParam("Spirograph Radius", &mSpirograph->mRadius);
	
	
	mSaveFrames = false;
	
	
	// Opengl blending
	glEnable(GL_BLEND);
	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glEnable(GL_POLYGON_SMOOTH);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // GL_FASTEST	
}
Ejemplo n.º 11
0
void AssimpApp::setup()
{
	mAssimpLoader = assimp::AssimpLoader( getAssetPath( "astroboy_walk.dae" ) );
	mAssimpLoader.setAnimation( 0 );


	CameraPersp cam;
	cam.setPerspective( 60, getWindowAspectRatio(), 0.1f, 1000.0f );
	cam.setEyePoint( Vec3f( 0, 7, 20 ) );
	cam.setCenterOfInterestPoint( Vec3f( 0, 7, 0 ) );
	mMayaCam.setCurrentCam( cam );

	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 300 ) );
	mEnableWireframe = false;
	mParams.addParam( "Wireframe", &mEnableWireframe );
	mEnableTextures = true;
	mParams.addParam( "Textures", &mEnableTextures );
	mEnableSkinning = true;
	mParams.addParam( "Skinning", &mEnableSkinning );
	mEnableAnimation = false;
	mParams.addParam( "Animation", &mEnableAnimation );
	mDrawBBox = false;
	mParams.addParam( "Bounding box", &mDrawBBox );
	mParams.addSeparator();
	mParams.addParam( "Fps", &mFps, "", true );
}
Ejemplo n.º 12
0
void ArmyDemoApp::setup()
{

	mSender.bind();
#if ! USE_UDP
	mSender.connect();
#endif

	model::Skeleton::sRenderMode = model::Skeleton::RenderMode::CLEANED;

	mLightPos = vec3(10.0f, 20.0f, 20.0f);
	mMouseHorizontalPos = 0;
	mMeshIndex = 0;
	mParams = params::InterfaceGl( "Parameters", ivec2( 200, 250 ) );
	mParams.addParam( "Fps", &mFps, "", true );
	mParams.addSeparator();
	mDrawMesh = true;
	mParams.addParam( "Draw Mesh", &mDrawMesh );
	mDrawSkeleton = false;
	mParams.addParam( "Draw Skeleton", &mDrawSkeleton );
	mDrawAbsolute = true;
	mParams.addParam( "Relative/Abolute skeleton", &mDrawAbsolute );
	mEnableWireframe = false;
	mParams.addParam( "Wireframe", &mEnableWireframe );
	
	gl::enableDepthWrite();
	gl::enableDepthRead();
	gl::enableAlphaBlending();
	
	mSkeletalMesh = model::SkeletalMesh::create( model::AssimpLoader( loadAsset( "maggot3.md5mesh" ) ) );
}
void CinderProjectionTestApp::setup()
{
	mLookEye = Vec3f( 5.0f, 10.0f, 30.0f );
	mSweetEye = Vec3f( 0.0f, 0.0f, 4.0f );
	mProjEye = Vec3f( 2.0f, 3.0f, 3.0f );
	mLookCenter = mSweetCenter = mProjCenter = Vec3f::zero();
	mLookUp = mSweetUp = mProjUp = Vec3f::yAxis();
	
	mLookDistance = 30.0f;
	// setPerspective of cams moved to ::resize()
	
	mActiveCam = CAM_LOOK;
	
	mCubeSize = 1.0f;
	
	mTexture = gl::Texture( loadImage( loadResource( RES_IMAGE ) ) );
    mProjShader = gl::GlslProg( loadResource( RES_TEXTUREPROJECTION_VERT ), loadResource( RES_TEXTUREPROJECTION_FRAG ) );
	mTextureScaling = 1.0f;
	
	vector<string> camEnum;
	camEnum.push_back("Look around (free)");
	camEnum.push_back("'Sweet spot' (fixed)");
	camEnum.push_back("Projector (fixed)");
	
	mParams = params::InterfaceGl( "Texture Projection", Vec2i( 160, 100 ) );
	//mParams.addParam( "Active Cam", camEnum, &mActiveCam ); // ::addParam(..enum..) is not available in Cinder 0.8.2
	//mParams.setOptions("", "iconified=true" ); // ::setOptions is not available in Cinder 0.8.2
	//mParams.setOptions("", "help='Keys [1], [2] and [3] can be used to switch camrea positions'" );
	mParams.addParam( "Avg. FPS", &mFPS, "precision=1", true );
	mParams.addParam( "Tex Scale", &mTextureScaling, "step=0.1" );
	mParams.addParam( "Cube Rot.", &mCubeRotation );
	mParams.addParam( "Cube Size", &mCubeSize, "keyincr=+ keydecr=-" );
	mParams.addSeparator();
	mParams.addParam( "Sweet Eye", &mSweetEye );
}
Ejemplo n.º 14
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 );
}
Ejemplo n.º 15
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 );

    
}
Ejemplo n.º 16
0
void TerrainApp::setup()
{
	gl::disableVerticalSync();

	CameraPersp cam;
	cam.lookAt( Vec3f( 40, 50, -10 ), Vec3f( 0, 0, 0 ) );
	cam.setPerspective( 60, getWindowAspectRatio(), 0.1f, 1000.0f );
	mMayaCam.setCurrentCam( cam );

	mLight = shared_ptr< gl::Light >( new gl::Light( gl::Light::DIRECTIONAL, 0 ) );
	mLight->setAmbient( Color( .2f, .2f, .2f ) );
	mLight->setDiffuse( Color( .5f, .5f, .5f ) );
	mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
	mLight->enable();

	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 300 ) );

	mLightDirection = Vec3f( -1, 0, .5 );
	mParams.addParam( "Light direction", &mLightDirection );
	mParams.addSeparator();

	mAmbient = Color::gray( .25 );
	mParams.addParam( "Ambient", &mAmbient );
	mDiffuse = Color::gray( .5 );
	mParams.addParam( "Diffuse", &mDiffuse );
	mSpecular = Color::white();
	mParams.addParam( "Specular", &mSpecular );
	mShininess = 30;
	mParams.addParam( "Shininess", &mShininess, "min=0 max=150 step=.25" );
	mEmission = Color::black();
	mParams.addParam( "Emission", &mEmission );
	mParams.addSeparator();

	mHeight = 50;
	mParams.addParam( "Heigth", &mHeight, "min=0 max=100 step=.4" );
	mNoiseScale = .034;
	mParams.addParam( "Noise scale", &mNoiseScale, "min=0 max=1 step=.002" );
	mParams.addSeparator();

	mParams.addParam( "Fps", &mFps, "", true );
}
Ejemplo n.º 17
0
void TweakBarApp::setup()
{
	mObjSize = 4;
	mLightDirection = Vec3f( 0, 0, -1 );
	mColor = ColorA( 0.25f, 0.5f, 1.0f, 1.0f );

	// setup our default camera, looking down the z-axis
	mCam.lookAt( Vec3f( -20, 0, 0 ), Vec3f::zero() );

	// Setup the parameters
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) );
	mParams.addParam( "Cube Size", &mObjSize, "min=0.1 max=20.5 step=0.5 keyIncr=z keyDecr=Z" );
	mParams.addParam( "Cube Rotation", &mObjOrientation );
	mParams.addParam( "Cube Color", &mColor, "" );	
	mParams.addSeparator();	
	mParams.addParam( "Light Direction", &mLightDirection, "" );
}
Ejemplo n.º 18
0
void ProceduralAnimApp::setup()
{
	mSkinnedVboBird = SkinnedVboMesh::create( loadModel( getAssetPath( "gannet rig2.DAE" ) ) );
	
	mRotationRadius = 20.0f;
	mLightPos = Vec3f(0, 20.0f, 0);
	mMouseHorizontalPos = 0;
	
	console() << *mSkinnedVboBird->getSkeleton();
	
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 250 ) );
	mDrawMesh = true;
	mParams.addParam( "Draw Mesh", &mDrawMesh );
	mDrawSkeleton = false;
	mParams.addParam( "Draw Skeleton", &mDrawSkeleton );
	mDrawLabels = false;
	mParams.addParam( "Draw Labels", &mDrawLabels );
	mEnableWireframe = false;
	mParams.addParam( "Wireframe", &mEnableWireframe );
	mParams.addSeparator();
	mFlapAngle = 0.0f;
	mFlapIncrement = 18.5f;
	mAmplitude = 1.0f;
	mShoulderAngle = 0.0f;
	mParams.addParam( "Flap speed", &mFlapIncrement, "min=1.0 max=45.0 precision=1" );
	mParams.addParam( "Amplitude", &mAmplitude, "min=0.0 max=3.0 step=0.05 precision=2" );
	mParams.addParam( "Shoulder angle", &mShoulderAngle, "min=-1.57 max=0.5 step=0.05 precision=2" );
	
	for( int i=0; i<NB_CLOUD_PARTICLES; ++i ) {
		mDust.push_back( SCENE_SIZE * Vec3f( Rand::randFloat() - 0.5f,
									  Rand::randFloat() - 0.5f,
									  Rand::randFloat() - 0.5f ) );
	}
	dustParticleTex = gl::Texture::create( loadImage( getAssetPath( "particle.png" ) ) );
	try {
		mDustShader = gl::GlslProg::create( app::loadResource(RES_CLOUD_VERT), app::loadResource(RES_CLOUD_FRAG) );
	}
	catch( gl::GlslProgCompileExc &exc ) {
		app::console() << "Shader compile error: " << std::endl;
		app::console() << exc.what();
	}
}
Ejemplo n.º 19
0
void Fluid2DBasicApp::setup()
{
	glEnable( GL_TEXTURE_2D );
	
	mDenScale = 25;    
	
	mFluid2D.set( 192, 192 );
 	mFluid2D.setDensityDissipation( 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.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.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.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.enableDensity();
	mFluid2D.enableVorticityConfinement();
	mFluid2D.initSimData();
	
}
Ejemplo n.º 20
0
void reflection_animationApp::setup()
{
    
	// STRUCTURE
	
	m_shapeDims = Vec3f(50, 75, 50);
	m_numlevels = 12;
    m_incr = 2;
	
    m_shapeType = PYRAMID;
    
    initShape();
	cout << m_structure.m_shapes.size() << endl;
    
    // DISPLAY
    
    m_showInterface = true;
    m_recording = false;
    
    m_path = getHomeDirectory() / "Desktop/"; 
    
	m_showColour = true;
    m_renderMode = ALPHA;
    
    m_contrast = 4.0f;
    m_alpha = .45f;
    
    m_face1Display = ACTIVE;
    m_face2Display = DICHROIC1;
    m_face3Display = GLASS;
    m_face4Display = NONE;
    
    m_dichroic1Colour = Color(0.3f, 0.8f, 1.0f);
    m_dichroic2Colour = Color(1.0f, 0.8f, 0.3f);
	
    // ANIMATION
    
    m_aniMode = VIDEO;
    
    // radar
    m_interval = 360;
    m_frontarea = 1.5f;
    m_backarea  = 6.0f;
    
	// GUI
    
	m_params = params::InterfaceGl( "Geometry/Animation Parameters [press TAB to hide]", Vec2i( 400, 600 ) );
	
    // render
    m_params.addText( "render", "label=`Render`" );
	m_params.addSeparator();
    vector<string> rstrs; rstrs.push_back("ALPHA"); rstrs.push_back("ADDITIVE"); rstrs.push_back("MULTIPLY");
    m_params.addParam( "Render Mode", rstrs, (int*)&m_renderMode );
    m_params.addParam( "Use Colour", &m_showColour );
    m_params.addParam( "Alpha", &m_alpha, "min=0.001 max=2.0 step=0.1" );
	m_params.addParam( "Contrast", &m_contrast, "min=0.001 max=5.0 step=0.1" );
	m_params.addParam( "Dichroic Colour 1", &m_dichroic1Colour );
	m_params.addParam( "Dichroic Colour 2", &m_dichroic2Colour );
    m_params.addText( "emptyline1", "label=` `" );
    
    // structure
	m_params.addText( "structure", "label=`Structure`" );
	m_params.addSeparator();
    vector<string> dstrs; dstrs.push_back("ACTIVE"); dstrs.push_back("DICHROIC1"); dstrs.push_back("DICHROIC2"); dstrs.push_back("GLASS"); dstrs.push_back("NONE");
	m_params.addParam( "Face 1 Display mode", dstrs, (int*)&m_face1Display );
    m_params.addParam( "Face 2 Display mode", dstrs, (int*)&m_face2Display );
    m_params.addParam( "Face 3 Display mode", dstrs, (int*)&m_face3Display );
    m_params.addParam( "Face 4 Display mode", dstrs, (int*)&m_face4Display );
    m_params.addText( "emptyline2", "label=` `" );
    
    // generate shape
    m_params.addText( "generate", "label=`Generate`" );
	m_params.addSeparator();
    vector<string> sstrs; sstrs.push_back("PYRAMID"); sstrs.push_back("TETRAHEDRON"); sstrs.push_back("HOLLOW PYRAMID");
	m_params.addParam( "Shape", sstrs, (int*)&m_shapeType );
    m_params.addParam( "Number Of Levels", &m_numlevels );
    m_params.addParam( "Vertical Interval", &m_incr );
    m_params.addParam( "Shape Dimensions", &m_shapeDims );
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    m_params.addText( "emptyline3", "label=` `" );
    
    // animation
    m_params.addText( "animation", "label=`Animation`" );
	m_params.addSeparator();
    vector<string> astrs; astrs.push_back("STATIC"); astrs.push_back("RADAR"); astrs.push_back("VIDEO"); astrs.push_back("VIDEO_RADAR");
	m_params.addParam( "Animation Mode", astrs, (int*)&m_aniMode );
    m_params.addParam( "Interval", &m_interval );
    m_params.addParam( "Size (front)", &m_frontarea );
    m_params.addParam( "Size (tail)", &m_backarea );
    
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    
	
	// CAMERA/PERSPECTIVE (not updated anymore -> mayacam)

	m_cameraDistance = 800.0f;
    
    m_eye        = Vec3f( 0.0f, 0.0f, m_cameraDistance );
	m_center     = Vec3f::zero();
	m_up         = Vec3f::yAxis();
    
    CameraPersp cam;
    
    cam.setEyePoint(m_eye);
    cam.setCenterOfInterestPoint(m_center);
    cam.setWorldUp(m_up);
    cam.setPerspective(60.0, getWindowAspectRatio(), 5.0, 5000.0);
    m_mayaCam.setCurrentCam( cam );
    
	
	// CAPTURE/VIDEO/INPUT
    
    m_surface = Surface8u(600, 400, true);
    
	vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {

				m_capture.push_back( Capture( 600, 400, device ) );
				m_capture.back().start();
				
				// placeholder texture
				m_textures.push_back( gl::Texture() );
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}
	
    // these should actually only be updated on change --> pointers to parameters
    
    DisplayMode* faceModesArr[] = {
        &m_face1Display, &m_face2Display, &m_face3Display, &m_face4Display
    };
    vector<DisplayMode*> p_faceModes(faceModesArr, faceModesArr+4);
    
    m_structure.setMaterialSettings( p_faceModes, &m_showColour, &m_alpha, &m_contrast );
    m_structure.setAnimationSettings( &m_aniMode );
    m_structure.setRadarSettings( &m_interval, &m_frontarea, &m_backarea);
    
    
}
Ejemplo n.º 21
0
void BoidsApp::setup()
{	
	Rand::randomize();
	//setFullScreen(true);
	shouldBeFullscreen = false;
	
	mCenter				= Vec3f( getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, 0.0f );
	mSaveFrames			= false;
	mIsRenderingPrint	= false;
	changeInterval		= 15.0;
	time(&lastChange);
	gravity				= false;
	
	// 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 );
	lastFrameTime		= getElapsedSeconds();
	deltaT				= 0;
	newFlock			= 0;
	
	mParticleTexture	= gl::Texture( loadImage( loadResource( RES_PARTICLE ) ) );
	
	
	// Initialize the OpenCV input (Below added RS 2010-11-15)
	try {
		//ci::Device device = Capture.
		std::vector<boost::shared_ptr<Capture::Device> > devices = Capture::getDevices();
		
		std::cout << "Capture Devices:" << std::endl;
		std::vector<boost::shared_ptr<Capture::Device> >::iterator device_iterator;
		//for(device_iterator=devices.begin(); device_iterator!=devices.end(); device_iterator++)
		for(int i=0; i<devices.size();i++)
		{
			console() << "device " << i << ": " << devices[i]->getName() << std::endl;
			
		}
		
		//UNCOMMENT FOLLOWING LINE FOR BUILT-IN CAMERA
		//capture = Capture(320,240);
		
		//UNCOMMENT FOLLOWING LINE FOR UNIBRAIN OR WHATEVER
		capture = Capture(320,240,devices[0]);//,devices[0]);	//FIXME this is a dumb way to select a device
		
		capture.start();
		silhouetteDetector = new SilhouetteDetector(320,240);
	} catch ( ... ) {
		console() << "Failed to initialize capture device" << std::endl;
	}
	cvThreshholdLevel = 45;		
	// CREATE PARTICLE CONTROLLER
	flock_one.addBoids( NUM_INITIAL_PARTICLES );
	flock_two.addBoids( NUM_INITIAL_PARTICLES );
	flock_one.setColor(ColorA( CM_RGB, 0.784, 0.0, 0.714, 1.0));
	flock_one.silRepelStrength = -0.50f;
	flock_two.setColor(ColorA( CM_RGB, 0.0, 1.0, 0.0, 1.0));
	imageColor = ColorA( CM_RGB, 0.4, 0.4, 0.4, 1.0);
	
	flock_one.addOtherFlock(&flock_two);
	flock_two.addOtherFlock(&flock_one);
	// SETUP PARAMS
	mParams = params::InterfaceGl( "Flocking", Vec2i( 200, 310 ) );
	mParams.addParam( "Scene Rotation", &mSceneRotation, "opened=1" );//
	mParams.addSeparator();
	mParams.addParam( "Fullscreen", &shouldBeFullscreen,"keyIncr=f" ); //FIXME
	mParams.addSeparator();
	mParams.addParam( "Eye Distance", &mCameraDistance, "min=100.0 max=2000.0 step=50.0 keyIncr=s keyDecr=w" );
	//mParams.addParam( "Center Gravity", &flock_one.centralGravity, "keyIncr=g" );
	//mParams.addParam( "Flatten", &flock_one.flatten, "keyIncr=f" );
	mParams.addSeparator();
	//mParams.addParam( "Zone Radius", &flock_one.zoneRadius, "min=10.0 max=100.0 step=1.0 keyIncr=z keyDecr=Z" );
//	mParams.addParam( "Lower Thresh", &flock_one.lowerThresh, "min=0.025 max=1.0 step=0.025 keyIncr=l keyDecr=L" );
//	mParams.addParam( "Higher Thresh", &flock_one.higherThresh, "min=0.025 max=1.0 step=0.025 keyIncr=h keyDecr=H" );
//	mParams.addSeparator();
//	mParams.addParam( "Attract Strength", &flock_one.attractStrength, "min=0.001 max=0.1 step=0.001 keyIncr=a keyDecr=A" );
//	mParams.addParam( "Repel Strength", &flock_one.repelStrength, "min=0.001 max=0.1 step=0.001 keyIncr=r keyDecr=R" );
//	mParams.addParam( "Orient Strength", &flock_one.orientStrength, "min=0.001 max=0.1 step=0.001 keyIncr=o keyDecr=O" );
//	mParams.addSeparator();
	mParams.addParam( "CV Threshhold", &silhouetteDetector->cvThresholdLevel, "min=0 max=255 step=1 keyIncr=t keyDecr=T" );
	
	//setup transformation from camera space to opengl world space
	imageToScreenMap.setToIdentity();
	imageToScreenMap.translate(Vec3f(getWindowSize().x/2, getWindowSize().y/2, 0));	//translate over and down
	imageToScreenMap.scale(Vec3f(-1*getWindowSize().x/320.0f, -1*getWindowSize().y/240.0f,1.0f));	//scale up
	polygons = new vector<Vec2i_ptr_vec>();
	
	currentBoidRuleNumber = 0;
	
	// ** stuff to create boid rulesets ** //
	
	// State 1: stuckOnYou - both flocks are attracted to the silhouette
	BoidSysPair stuckOnYou;
	stuckOnYou.flockOneProps.zoneRadius			= 80.0f;
	stuckOnYou.flockOneProps.lowerThresh		= 0.5f;
	stuckOnYou.flockOneProps.higherThresh		= 0.8f;
	stuckOnYou.flockOneProps.attractStrength	= 0.004f;
	stuckOnYou.flockOneProps.repelStrength		= 0.01f;
	stuckOnYou.flockOneProps.orientStrength		= 0.01f;
	stuckOnYou.flockOneProps.silThresh			= 1000.0f;
	stuckOnYou.flockOneProps.silRepelStrength	= -0.50f;
	stuckOnYou.flockOneProps.gravity			= false;
	stuckOnYou.flockOneProps.baseColor			= ColorA( CM_RGB, 0.784, 0.0, 0.714, 1.0);
	
	stuckOnYou.flockTwoProps=stuckOnYou.flockOneProps;
	stuckOnYou.imageColor						= ColorA( 0.08f, 0.0f, 0.1f, 1.0f);
	boidRulesets.push_back(stuckOnYou);
	
	// State 2: repel - both flocks are repeled by the silhouette
	BoidSysPair repel;
	repel.flockOneProps.zoneRadius				= 80.0f;
	repel.flockOneProps.lowerThresh				= 0.5f;
	repel.flockOneProps.higherThresh			= 0.8f;
	repel.flockOneProps.attractStrength			= 0.004f;
	repel.flockOneProps.repelStrength			= 0.01f;
	repel.flockOneProps.orientStrength			= 0.01f;
	repel.flockOneProps.silThresh				= 500.0f;
	repel.flockOneProps.silRepelStrength		= 1.00f;
	repel.flockOneProps.gravity					= false;
	repel.flockOneProps.baseColor				= ColorA( CM_RGB, 0.157, 1.0, 0.0,1.0);

	repel.flockTwoProps=repel.flockOneProps;
	repel.imageColor							= ColorA( 0.08f, 0.0f, 0.1f, 1.0f);	
	boidRulesets.push_back(repel);
	
	
	//// State 3: grav - like repel, but with gravity added
	BoidSysPair grav;
	grav.flockOneProps=repel.flockOneProps;
	grav.flockOneProps.gravity					= true;
	grav.flockOneProps.repelStrength			= 0.005f;
	grav.flockOneProps.baseColor				= ColorA( CM_RGB, 0.157, 0.0, 1.0,1.0);
	grav.flockTwoProps=grav.flockOneProps;
	grav.imageColor								= ColorA( 0.08f, 0.0f, 0.1f, 1.0f);
	boidRulesets.push_back(grav);
	
	
	//// State 4: diff - one flock is attracted to the silhouette and the other is repeled
	BoidSysPair diff;
	
	diff.flockOneProps=repel.flockOneProps;
	diff.flockTwoProps=stuckOnYou.flockOneProps;
	diff.imageColor								= ColorA( 0.08f, 0.0f, 0.1f, 1.0f);
	boidRulesets.push_back(diff);
	 
	
}
Ejemplo n.º 22
0
void FolApp::setup()
{
    gl::disableVerticalSync();

    mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 300 ) );
    mParams.addParam( "Blur amount", &mBlurAmount, "min=0 max=128 step=1" );
    mParams.addParam( "Clip", &mClip, "min=0 max=1 step=.005" );
    mParams.addParam( "Step", &mStep, "min=1 max=128 step=.5" );
    mParams.addSeparator();
    mParams.addParam( "Fps", &mFps, "", true );

    mParams.addSeparator();
    mParams.addButton( "Start recording", std::bind(&FolApp::toggleRecording, this ));

    mBlurKernelTexture = loadImage( loadResource( RES_BLUR_KERNEL ) );
    mBlurShader = gl::GlslProg( loadResource( RES_PASSTHROUGH_VERT ),
                                loadResource( RES_BLUR_FRAG ) );
    mWaveShader = gl::GlslProg( loadResource( RES_WAVE_VERT ),
                                loadResource( RES_WAVE_FRAG ) );

    gl::Fbo::Format format;
    format.enableColorBuffer( true, 2 );
    format.enableDepthBuffer( false );
    mDepthFbo = gl::Fbo( 640, 480, format );

    format.enableColorBuffer( true, 8 );
    format.enableDepthBuffer( false );
    format.setWrap( GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE );
    mOutputFbo = gl::Fbo( mDepthFbo.getWidth(),
                          mDepthFbo.getHeight(), format );
    mBloomFbo = gl::Fbo( mDepthFbo.getWidth() / 4,
                         mDepthFbo.getHeight() / 4, format );

    mBloomShader = gl::GlslProg( loadResource( RES_KAWASE_BLOOM_VERT ),
                                 loadResource( RES_KAWASE_BLOOM_FRAG ) );
    mBloomShader.bind();
    mBloomShader.uniform( "tex", 0 );
    mBloomShader.uniform( "pixelSize", Vec2f( 1. / mBloomFbo.getWidth(), 1. / mBloomFbo.getHeight() ) );
    mBloomShader.unbind();


    mMixerShader = gl::GlslProg( loadResource( RES_PASSTHROUGH_VERT ),
                                 loadResource( RES_MIXER_FRAG ) );
    mMixerShader.bind();
    int texUnits[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
    mMixerShader.uniform("tex", texUnits, 9);
    mMixerShader.unbind();

    /*
    	 0 0, 0, 0
    	 1 0.00392157, 0, 0
    	 2 0.0352941, 0.0235294, 0
    	 3 0.0745098, 0.0627451, 0
    	 4 0.117647, 0.12549, 0
    	 5 0.172549, 0.239216, 0
    	 6 0.227451, 0.388235, 0
    	 7 0.278431, 0.533333, 0
    	 8 0.345098, 0.717647, 0
    	 9 0.407843, 0.898039, 0
    	10 0.466667, 0.980392, 0
    	11 0.529412, 0.898039, 0
    	12 0.6, 0.717647, 0
    	13 0.662745, 0.533333, 0
    	14 0.721569, 0.388235, 0
    	15 0.780392, 0.243137, 0
    	16 0.835294, 0.129412, 0
    	17 0.882353, 0.0627451, 0
    	18 0.933333, 0.0235294, 0
    	19 0.980392, 0, 0
    	20 1, 0, 0
     */

    createVbo();

    // start OpenNI
    try
    {
        //mNI = OpenNI( OpenNI::Device() );

        //*
        string path = getAppPath().string();
#ifdef CINDER_MAC
        path += "/../";
#endif
        path += "rec-12033015082700.oni";
        mNI = OpenNI( path );
        //*/
    }
    catch (...)
    {
        console() << "Could not open Kinect" << endl;
        quit();
    }

    mNI.setMirrored( true );
    mNI.start();
}
void FmodExMultiple3DSoundPlayerApp::setup()
{
	setWindowSize(1024, 768);
	//Setup camera
	camDistance = 0.0f;
	camEye			= Vec3f( 0.0f, 0.0f, 20.f );
	camInitialEye = camEye;
	camCenter			= Vec3f(0, 0, -1.f);
	camUp				= Vec3f::yAxis();
	cam.setPerspective( 75.0f, getWindowAspectRatio(), 1.0f, 2000.0f );
	cam.lookAt( camEye, camCenter, camUp );
	
	//Setup Light
	lightDirection = Vec3f( 0, 0, -1 );
	
	
	//Setup 3D Sounds
	volume = 1.f;
	//we omit the velocities for simplicity of the example
	listenerVelocity.x = 0; 
	listenerVelocity.y = 0; 
	listenerVelocity.z = 0; 
	//we setup the listener with the same propierties of the camera (first person view)
	listenerUp.x = camUp.x;
	listenerUp.y = camUp.y; 
	listenerUp.z = camUp.z;
	listenerPos.x = camEye.x; 
	listenerPos.y = camEye.y;  
	listenerPos.z = camEye.z;
	forward = camCenter - camEye;
	forward.normalize();
	listenerForward.x = forward.x; 
	listenerForward.y = forward.y; 
	listenerForward.z = forward.z; 
	
	
	//we set the sounds positions
	Vec3f pos1 = Vec3f::zero() + 10 * Rand::randVec3f();
	sound3DPosition1.x = pos1.x;
	sound3DPosition1.y = pos1.y;
	sound3DPosition1.z = pos1.z;
	//we omit the sounds velocities for simplicity of the example
	sound3DVelocity1.x = 0;
	sound3DVelocity1.y = 0;
	sound3DVelocity1.z = 0;
	//we create the 3D sound players
	player1.loadSound(getResourcePath("synth.wav"));
	player1.setVolume(volume);
	player1.setMultiPlay(true); 
	player1.play();
	
	//we set the sounds positions
	Vec3f pos2 = Vec3f::zero() + 10 * Rand::randVec3f();
	sound3DPosition2.x = pos2.x;
	sound3DPosition2.y = pos2.y;
	sound3DPosition2.z = pos2.z;
	//we omit the sounds velocities for simplicity of the example
	sound3DVelocity2.x = 0;
	sound3DVelocity2.y = 0;
	sound3DVelocity2.z = 0;
	//we create the 3D sound players
	player2.loadSound(getResourcePath("1085.mp3"));
	player2.setVolume(volume);
	player2.setMultiPlay(true); 
	player2.play();
	
	
	sys = Fmodex3DSoundPlayer::getSystem();
	
	
	
	//Setup Params
	params = params::InterfaceGl( "3D_Sound", Vec2i( 200, 160 ) );
	params.addParam( "Scene Rotation", &sceneRotation, "" );
	params.addParam( "Light Direction", &lightDirection, "" );
	params.addSeparator();
	params.addParam( "Eye Distance", &camDistance, "min=-100.0 max=100.0 step=5.0 keyIncr=s keyDecr=w " );
	params.addParam( "Camera Center", &camCenter, "opened=1" );
	
}
void ForelleVisualAppApp::setup()
{
    
    loadSettings();
    
    // Setup the parameters
    clusterBar =  ClusterBar( "Cluster Window", Vec2i( 200, 400 ) );

    //Setup menueBar
    
    menueBar = params::InterfaceGl( "Menue Window", Vec2i(300, 400 ), ColorA(0.5,0.5,0.5,0.1) );
    menueBar.setOptions("", "text=light position='724 0' valueswidth=100 contained=true");
    menueBar.addButton("Clear Scene ", std::bind( &ForelleVisualAppApp::clearScene, this ) );
    menueBar.addButton("Delete Selected Cluster", std::bind( &ForelleVisualAppApp::deleteCluster, this ) );
    menueBar.addParam("Draw Grid" , &drawGrid,"");
    menueBar.addParam("Read Pixel" , &readPixels, "true=reading false='not reading'");
    menueBar.addButton("Refresh ClusterBar", std::bind( &ForelleVisualAppApp::refreshClusterBar, this ) );
    menueBar.addParam("Update Cluster" , &updateCluster,"true=updating false='not updating'");
    menueBar.addParam("Send only Selected Cluster" , &selectedClusterOn,"");


    menueBar.addSeparator();	
    menueBar.addButton("Load Scene ", std::bind( &ForelleVisualAppApp::loadScene, this ) );
    menueBar.addButton("Load Cluster to Universe ", std::bind( &ForelleVisualAppApp::loadClusterToUniverse, this ) );
    menueBar.addParam("    Load to Universe" , &templateUniverse,"min=0 max=3 step=1");
    menueBar.addButton("Save as Cluster", std::bind( &ForelleVisualAppApp::saveAsCluster, this ) );
    menueBar.addButton("Save as Scene", std::bind( &ForelleVisualAppApp::saveAsScene, this ) );
    menueBar.addButton("Save as Standart Scene", std::bind( &ForelleVisualAppApp::saveAsStandartScene, this ) );
    menueBar.addParam("Send Data" , &sendData,"true=sending false='not sending'");
    
    menueBar.addSeparator();	
    menueBar.addSeparator();	
    menueBar.addParam("All On" , &bAllOn,"");
    menueBar.addParam("All Off" , &bAllOff,"");

    menueBar.addButton("Show ClusterBar", std::bind( &ForelleVisualAppApp::showClusterBar, this ) );
    menueBar.show(false);
    for (int i=0; i < Const::MAX_DMX_CHANNELS ; i++) {
        data1[i]= 0;
        data2[i]= 0;
        data3[i]= 0;
        data4[i]= 0;
    }

    //setup boolean variables
    readPixels = true;
    sendData  = true;
    drawGrid = true;
    updateCluster = true;
    bAllOn = false;
    bAllOff = false;
    bShowClusterBar = false;
    selectedClusterOn = false;
    
    //default load out templates to universe 0
    templateUniverse = 0;
 
  
    // set our pointer to the last added cluster
    if(!clusters.empty())
        selectedCluster = clusters.end()-1;
         

    controller.printClusters(clusters);


    
    //Setup Artnetnode
    
    if(ipAdress.empty() )
        ipAdress = "10.0.2.1";  //if it isn´t initalised already
    node = CinderArtnet("Art-Net Test", "LongName", ipAdress);
    node.setNodeTypeAsServer();
    node.setSubnetAdress(0);
    node.enableDMXPortAsInputAndSetAdress(0,1);
    node.enableDMXPortAsInputAndSetAdress(1, 2);
    node.enableDMXPortAsInputAndSetAdress(2, 3);
    node.enableDMXPortAsInputAndSetAdress(3, 4);
    node.printConfig();
    node.startNode();
    
    // initalize start our Syphone Client
    client.setup(Vec2i(60,60));
    pos = Vec2i(0,0);
    scale = 9;
     
    
    
    
 
    mLogo = gl::Texture( loadImage( loadResource(RES_LOGO) ) );
        

}
Ejemplo n.º 25
0
void ProjectionMappingApp::setup()
{
	mDispMode = DispMode_GUIDE;
	mEditMode = EditMode_EDIT;
	mIsShowCtrlMesh = true;
	mMeshMode = false;
	mHandleSize = 30.0;
	mGridNum = Vec2i(16, 8);
	mMPPrev = Vec2f(0, 0);
	mSpan = 8;
	mHasMovie = false;

	glEnable(GL_TEXTURE_RECTANGLE_ARB);

	mTexFont = gl::TextureFont::create(Font("msgothic", 40));

	gl::Fbo::Format format;
	format.enableDepthBuffer(false);
	format.enableMipmapping(false);
	mFbo = gl::Fbo(1920, 1080, format);

	mScale = 1.0f;
	mParams = params::InterfaceGl( "App parameters", Vec2i( 200, 400 ) );

	// In Image
	mParams.addButton("SelectInImageFolder", std::bind(&ProjectionMappingApp::onSelectInFolder, this));
	mParams.addParam("mInImageFolder ", &mInImageFolder, mInImageFolder );
	mParams.addParam("InImageName ", &mInImageName, mInImageName );

	// Out Image
	mParams.addButton("SelectOutImageFolder", std::bind(&ProjectionMappingApp::onSelectOutFolder, this));
	mParams.addParam("mOutImageFolder ", &mOutImageFolder, mOutImageFolder );
	mParams.addParam("OutImageName ", &mOutImageName, mOutImageName );
	mParams.addParam("FrameDuration", &mDuration);
//	mOutImageFolder = getFolderPath(mOutImageFolder);

	mParams.addSeparator();

	mParams.addButton("Recode", std::bind(&ProjectionMappingApp::onRecode, this));

	mParams.addSeparator();
	mParams.addButton("WriteXML", std::bind(&ProjectionMappingApp::onWrite, this));
	mParams.addButton("ReadXML", std::bind(&ProjectionMappingApp::onRead, this));
	mParams.addSeparator();

	glDisable(GL_DEPTH);
	glDisable(GL_DEPTH_TEST);

	mShader = gl::GlslProg( loadResource( RES_NORMAL_MAP_VERT ), loadResource( RES_NORMAL_MAP_FRAG ) );
	
	gl::Texture::Format texformat;
	texformat.setTargetRect(); // GL_TEXTURE_RECTANGLE_ARBとして使う

	try
	{
		mDiffuseTex[DispMode_GUIDE]  = gl::Texture(loadImage("resources/Guide.jpg"), texformat);
		mDiffuseTex[DispMode_GUIDE1] = gl::Texture(loadImage("resources/0_CRV_mask.jpg"), texformat);
		mDiffuseTex[DispMode_GUIDE2] = gl::Texture(loadImage("resources/0_CRV_Line.jpg"), texformat);
		mDiffuseTex[DispMode_GUIDE3] = gl::Texture(loadImage("resources/0_CRV_LineGuide.jpg"), texformat);
		mDiffuseTex[DispMode_GUIDE4] = gl::Texture(loadImage("resources/0_CRV_TireGuide.jpg"), texformat);
	}
	catch (cinder::ImageIoExceptionFailedLoad * e)
	{
		app::console() << e->what() << std::endl;
		exit(1);
	}

	std::string moivePath = getOpenFilePath();
	if (!moivePath.empty()) {
		loadMovieFile(moivePath);
	}

	Vec2f result(1920-1, 1080-1);
	Vec2f div(mGridNum);

	int nx = ((mGridNum.x-1)*mSpan) - (mGridNum.x-2);
	int ny = ((mGridNum.y-1)*mSpan) - (mGridNum.y-2);
	
	mCtrlPointsNum = nx*ny;
	mCtrlPoints = new CtrlPoint[mCtrlPointsNum];

	int k = 0;
	for (int ix = 0; ix < mGridNum.x; ++ix) {
		for (int iy = 0; iy < mGridNum.y; ++iy) {
			float x = (result.x/(div.x-1)) * static_cast<float>(ix);
			float y = (result.y/(div.y-1)) * static_cast<float>(iy);

			CtrlPoint cp;
			cp.pos.set(x, y);
			cp.base.set(x, y);
			cp.mag.set(0, 0);
			cp.isSelected = false;
			mCtrlPoints[k] = cp;
			++k;
		}
	}

	resetMesh();

	// 頂点のバッファを確保
	this->createBezierMesh();

	setFullScreen(true);
}