Ejemplo n.º 1
0
void redEyeApp::setup() {
    
    //-settings
    mListener.setup(43334);  //osc input port
    
    //--defaults
    mHide= false;       //also keydown 'i'
    mError= "";
    mOsc= "";
    mMode= 5;
    mAmplitude= 0.0f;
    mNumSamples= 512;
    mDownSample= 0;
    mWidth= 1.0f;
    mColorBack= ColorA(0.0f, 0.0f, 0.0f, 1.0f);
    
    //mVisible0= mVisible1= true;
    mScale0= mScale1= Vec3f(1.0f, 1.0f, 1.0f);
    mTranslate0= mTranslate1= Vec3f::zero();
    mColor0= ColorA(1.0f, 0.0f, 0.0f, 1.0f);
    mColor1= ColorA(0.0f, 1.0f, 0.0f, 1.0f);
    
    //--audio
    mInput= audio::Input();     //use default input device
    mInput.start();             //start capturing
    
    //--shaders
    mPathFrag= getPathDirectory(app::getAppPath().string())+"data/_default_frag.glsl";
    mPathVert= getPathDirectory(app::getAppPath().string())+"data/_default_vert.glsl";
    //loadShader();
    
    //--parameter window
    mParams= params::InterfaceGl::create(getWindow(), "redEye", toPixels(Vec2i(200, 400)));
    //mParams->addText("text", ("label=`redEye`"));
    mParams->addParam("NumSamples", &mNumSamples, "min=1 max=2048 step=1");
    mParams->addParam("DownSample", &mDownSample, "min=0 max=2047 step=1");
    mParams->addParam("Width", &mWidth, "min=0 max=1000 step=1");
    mParams->addParam("Back color", &mColorBack, "");
    mParams->addSeparator();
    //mParams->addParam("Visible", &mVisible0);
    mParams->addParam("Scale", &mScale0);
    mParams->addParam("Rotate", &mRotate0);
    mParams->addParam("Translate", &mTranslate0);
    mParams->addParam("Color", &mColor0, "");
    /*mParams->addSeparator();
    mParams->addParam("Visible1", &mVisible1);
    mParams->addParam("Scale1", &mScale1);
    mParams->addParam("Rotate1", &mRotate1);
    mParams->addParam("Translate1", &mTranslate1);
    mParams->addParam("Color1", &mColor1, "");*/
    
    //mParams->addParam("Cube Size", &mObjSize, "min=0.1 max=20.5 step=0.5 keyIncr=z keyDecr=Z");
    mParams->addSeparator();
    mParams->addParam("String00", &mNameFrag, "label=`frag (f):`");
    mParams->addParam("String01", &mNameVert, "label=`vert (v):`");
    mParams->addParam("String02", &mError, "label=`error:`");
    mParams->addParam("String03", &mOsc, "label=`osc:`");
    mParams->addParam("String04", &mMode, "label=`mode (m):`");
    mParams->addParam("String05", &mFps, "label=`fps:`");
}
Ejemplo 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 );
}
Ejemplo n.º 3
0
void GeometryApp::createParams()
{
#if ! defined( CINDER_GL_ES )
	vector<string> primitives = { "Capsule", "Cone", "Cube", "Cylinder", "Helix", "Icosahedron", "Icosphere", "Sphere", "Teapot", "Torus", "Plane" };
	vector<string> qualities = { "Low", "Default", "High" };
	vector<string> viewModes = { "Shaded", "Wireframe" };
	vector<string> texturingModes = { "None", "Procedural", "Sampler" };

	mParams = params::InterfaceGl::create( getWindow(), "Geometry Demo", toPixels( ivec2( 300, 200 ) ) );
	mParams->setOptions( "", "valueswidth=160 refresh=0.1" );

	mParams->addParam( "Primitive", primitives, (int*) &mPrimitiveSelected );
	mParams->addParam( "Quality", qualities, (int*) &mQualitySelected );
	mParams->addParam( "Viewing Mode", viewModes, (int*) &mViewMode );
	mParams->addParam( "Texturing Mode", texturingModes, (int*) &mTexturingMode );

	mParams->addSeparator();

	mParams->addParam( "Subdivision", &mSubdivision ).min( 1 ).max( 5 ).updateFn( [this] { createGeometry(); } );

	mParams->addSeparator();

	mParams->addParam( "Show Grid", &mShowGrid );
	mParams->addParam( "Show Normals", &mShowNormals );
	mParams->addParam( "Show Colors", &mShowColors ).updateFn( [this] { createGeometry(); } );
	mParams->addParam( "Face Culling", &mEnableFaceFulling ).updateFn( [this] { gl::enableFaceCulling( mEnableFaceFulling ); } );
#endif
}
Ejemplo n.º 4
0
void VectorBlur::setParams(params::InterfaceGlRef params)
{
	if (params == nullptr) {
		printf("hbVectorBlur get no params\n");
		return;
	}
	params->addSeparator();
	params->addText("Vector Blur Filter Settings");
	params->addParam("Vector Map Kernel", &mVectorMapKernel).min(1).max(5).step(1);
	params->addParam("Vector Map Theta", &mTheta).min(0.f).max(360.f).step(0.1f);
	params->addParam("Blur Map Kernel", &mSize).min(0).max((float)mSizeMax).step(1);
	params->addParam("Blur Map Amplifier", &mAmplifier).min(1.f).max(10.f).step(0.1f);
	params->addParam("Vector Blur Kernel", &mVectorBlurKernel).min(0).max(30).step(1);
	params->addSeparator();
}
Ejemplo n.º 5
0
void ForestApp::setup()
{
    mParams = params::InterfaceGl::create( getWindow(), "Forest parameters", toPixels(Vec2i(240, 600)) );

    mParams->addButton("Reset", bind( &ForestApp::resetButton, this ), "key=r");
    mParams->addButton("Stop sim", bind( &ForestApp::stopButton, this ), "key=s");
    mParams->addButton("Write results", bind( &ForestApp::writeButton, this ), "key=w");
    mParams->addParam("Sim step #", &mStrandBox.mSimulationStep, "readonly=true");
    
    mParams->addSeparator();

    mParams->addParam( "Number of seeds", &mStrandBox.mNumSeeds).min(0).max(16).step(1);
    mParams->addParam( "Number of strands", &mStrandBox.mNumStrands).min(0).max(1000).step(1);
    mParams->addParam( "Number of dots", &mDots.mNumDots).min(0).max(1000).step(1);
    mParams->addParam( "Strand length", &mStrandBox.mStrandLength).min(1).max(1000).step(1);
    mParams->addParam( "Growth probability", &mStrandBox.mGrowthProbability).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Growth dir Y", &mStrandBox.mGrowthDirection.y).min(-1.f).max(10.f).step(0.01f);

    mParams->addSeparator();

    mParams->addParam( "Spring length", &mStrandBox.mSpringLength).min(0.0001f).max(0.01f).step(0.0001f);
    mParams->addParam( "Spring iters", &mStrandBox.mSpringIterations).min(0).max(10000).step(10);
    mParams->addParam( "Spring K", &mStrandBox.mSpringK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Straighten K", &mStrandBox.mStraightenK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Smooth K", &mStrandBox.mSmoothK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Align K", &mStrandBox.mAlignmentK).min(0.f).max(4.0f).step(0.001f);

    mParams->addSeparator();

    mParams->addParam( "Smallest dot", &mDots.mSmallestDotSize).min(0.f).max(0.2f).step(0.001f);
    mParams->addParam( "Largest dot", &mDots.mLargestDotSize).min(0.f).max(0.2f).step(0.001f);
    mParams->addParam( "Dot gravity", &mDots.mDotGravity).min(0.f).max(20.0f).step(0.001f);
    mParams->addParam( "Dot spacing", &mDots.mDotSpacing).min(0.f).max(20.0f).step(0.001f);

    mParams->addSeparator();
    
    mParams->addParam( "Panel edge K", &mPanels.mEdgeK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Panel edge margin", &mPanels.mEdgeMargin).min(0.f).max(1.0f).step(0.001f);

    mParams->addSeparator();

    mParams->addParam( "Show affinity matrix", &mShowMatrix, "key=m");
    mParams->addParam( "Max strands per dot", &mDots.mDotMaxStrands).min(0).max(100).step(1);
    mParams->addParam( "Affinity repel K", &mDots.mRepelK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Affinity retain K", &mDots.mRetainK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Affinity decay K", &mDots.mDecayK).min(0.f).max(1.0f).step(0.001f);
    mParams->addParam( "Force attract K", &mDots.mAttractK).min(0.f).max(1.0f).step(0.001f);
}
Ejemplo n.º 6
0
void MotionBlurVelocityBufferApp::setup()
{
    mBackground = gl::Texture::create( loadImage( loadAsset( "background.jpg" ) ) );
    mGpuTimer = gl::QueryTimeSwapped::create();
    gl::enableVerticalSync();

    createGeometry();
    createBuffers();
    loadShaders();

#if ! defined( CINDER_ANDROID )
    mParams = params::InterfaceGl::create( "Motion Blur Options", ivec2( 250, 300 ) );
    mParams->addParam( "Average GPU Draw (ms)", &mAverageGpuTime );
    mParams->addParam( "Average CPU Draw (ms)", &mAverageCpuTime );
    mParams->addSeparator();
    mParams->addParam( "Enable Blur", &mBlurEnabled );
    mParams->addParam( "Show Velocity Buffers", &mDisplayVelocityBuffers );
    mParams->addParam( "Pause Animation", &mPaused );
    mParams->addParam( "Animation Speed", &mAnimationSpeed ).min( 0.05f ).step( 0.2f );
    mParams->addParam( "Max Samples", &mSampleCount ).min( 1 ).step( 2 );
    mParams->addParam( "Blur Noise", &mBlurNoise ).min( 0.0f ).step( 0.01f );
#endif

#if defined( CINDER_COCOA_TOUCH )
    getSignalSupportedOrientations().connect( [] { return InterfaceOrientation::LandscapeAll; } );
#endif
}
Ejemplo n.º 7
0
void TweakBarApp::setup()
{
	mObjSize = 4;
	mLightDirection = vec3( 0, 0, -1 );
	mColor = ColorA( 0.25f, 0.5f, 1, 1 );
	mSomeValue = 2;

	// Setup our default camera, looking down the z-axis
	mCam.lookAt( vec3( -20, 0, 0 ), vec3( 0 ) );

	// Create the interface and give it a name.
	mParams = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( ivec2( 200, 400 ) ) );

	// Setup the parameters
	mParams->addParam( "Cube Size", &mObjSize ).min( 0.1f ).max( 20.5f ).keyIncr( "z" ).keyDecr( "Z" ).precision( 2 ).step( 0.02f );
	mParams->addParam( "Cube Rotation", &mObjOrientation );
	mParams->addParam( "Cube Color", &mColor );
	mParams->addParam( "String ", &mString );

	mParams->addSeparator();

	// Attach a callback that is fired after a target is updated.
	mParams->addParam( "some value", &mSomeValue ).updateFn( [this] { console() << "new value: " << mSomeValue << std::endl; } );

	// Add a param with no target, but instead provide setter and getter functions.
	std::function<void( vec3 )> setter	= std::bind( &TweakBarApp::setLightDirection, this, std::placeholders::_1 );
	std::function<vec3 ()> getter		= std::bind( &TweakBarApp::getLightDirection, this );
	mParams->addParam( "Light Direction", setter, getter );

	// Other types of controls that can be added to the interface
	mParams->addButton( "Button!", std::bind( &TweakBarApp::button, this ) );
	mParams->addText( "text", "label=`This is a label without a parameter.`" );
}
void WaterSimulationApp::setup(){

	boxDimension=Vec3f(30.0f,30.0f,30.0f);
	boxCenter=Vec3f(boxDimension)/2.0f;

	//Fluid System setup
	fluidsys=&stamfluid;
	fluidsys->reset(boxDimension);

	randomForce=Vec3f(2,3,-1);
	randomForceX=boxCenter;

	//// setup our default camera, looking down the z-axis
	CameraPersp	cam;
	cam.setEyePoint(Vec3f(200, 50, 50));
	cam.setCenterOfInterestPoint(boxCenter);
	cam.setPerspective(60.0, getWindowAspectRatio(), 1.0, 1000.0);
	mMayaCam.setCurrentCam(cam);

	Matrix44f mvM=mMayaCam.getCamera().getModelViewMatrix();
	gravity = Vec3f(mvM.m10,mvM.m11,mvM.m12);//col4:camera center, row: right,up,back
	gravity*= 9.8f;
	// Setup the parameters
	mDrawGravity=false;
	mAddNewForce=false;
	mAnimate	=false;
	mDrawBox	=true;


	mParams = params::InterfaceGl::create( getWindow(), "Water Simulation Parameters", toPixels( Vec2i( 250,300  ) ) );
	mParams->addParam("Draw Box", &mDrawBox);
	mParams->addParam("Draw Grid",&mDrawGrid);
	mParams->addParam("Draw Random Force",&mDrawForce);
	mParams->addSeparator();
	mParams->addParam("External Force Position",&randomForceX);
	mParams->addParam("External Force Dir",&randomForce);
	mParams->addParam("Draw Gravity",&mDrawGravity);
	mParams->addParam("Draw Velocity", &(fluidsys->mDrawVelocity));
	mParams->addSeparator();
	mParams->addParam("Animate",&mAnimate);
	mParams->addText("status","label=` `");
	mParams->addParam("Time Elapsed",&(fluidsys->elapsed),"",true);
	mParams->addSeparator();
	mParams->addParam("Viscosity", &fluidsys->viscosity);
	mParams->addParam("Diffusion Rate", &fluidsys->diffusion);
	mParams->addParam("Buoyancy Rate",&fluidsys->buoyancy);
}
void TextboxApp::setup(){
    mString = "At­ NEXT14, great speakers will draw a picture of what ’The New Normal’ will look like in the near future. Join NEXT14 on May 5-6, 2014!";
    
    mTextBox = new next::TextBox();
    
    mTextBox->setFont(Font(app::loadResource(RES_TRANSCRIPT_BOLD),TEXT_BOX_FONT_SIZE * TEXT_BOX_TEXTURE_FONT_SIZE_SCALE));
    mTextBox->setFontSize(TEXT_BOX_FONT_SIZE);
    mTextBox->setLineHeight(TEXT_BOX_FONT_LINE_HEIGHT);
    mTextBox->setColorFont(TEXT_BOX_COLOR_FONT);
    
    mTextBox->setColorUnderline(TEXT_BOX_COLOR_UNDERLINE);
    mTextBox->setColorDropShadow(TEXT_BOX_COLOR_DROP_SHADOW);
    
    mTextBox->setDropShadowOffset(TEXT_BOX_DROP_SHADOW_OFFSET);
    mTextBox->dropShadow(TEXT_BOX_USE_DROP_SHADOW);
    mTextBox->setDropShadowScale(TEXT_BOX_DROP_SHADOW_SCALE);
    
    mTextBox->underline(TEXT_BOX_USE_UNDERLINE);
    mTextBox->setUnderlineHeight(TEXT_BOX_UNDERLINE_HEIGHT);
    mTextBox->setUnderlineBaselineOffset(TEXT_BOX_UNDERLINE_BASELINE_OFFSET);
    
    mTextBox->setWidth(TEXT_BOX_WIDTH);
    mTextBox->setString(mString);

    mParams = params::InterfaceGl::create("Controls", Vec2i(200,400));
    mParams->addSeparator();
    mParams->addParam("Texture Font Scale", &TEXT_BOX_TEXTURE_FONT_SIZE_SCALE, "min=1.0 max=16.0 step=1.0");
    mParams->addParam("Font Size", &TEXT_BOX_FONT_SIZE, "min=1.0 max=200.0 step=0.125");
    mParams->addParam("Font Line Height", &TEXT_BOX_FONT_LINE_HEIGHT, "min=1.0 max=2.0 step=0.0125");
    mParams->addParam("Width", &TEXT_BOX_WIDTH);
    mParams->addSeparator();
    mParams->addParam("Color Font", &TEXT_BOX_COLOR_FONT);
    mParams->addParam("Color Underline", &TEXT_BOX_COLOR_UNDERLINE);
    mParams->addParam("Color DropShadow", &TEXT_BOX_COLOR_DROP_SHADOW);
    mParams->addSeparator();
    mParams->addParam("Use DropShadow", &TEXT_BOX_USE_DROP_SHADOW);
    mParams->addParam("DropShadow Offset X", &TEXT_BOX_DROP_SHADOW_OFFSET[0]);
    mParams->addParam("DropShadow Offset Y", &TEXT_BOX_DROP_SHADOW_OFFSET[1]);
    mParams->addParam("DropShadow Scale", &TEXT_BOX_DROP_SHADOW_SCALE,"min=0.0 max=4.0 step=0.0125");
    mParams->addSeparator();
    mParams->addParam("Underline Height", &TEXT_BOX_UNDERLINE_HEIGHT, "min=0.0 max=30.0 step=0.0125");
    mParams->addParam("Underline Offset", &TEXT_BOX_UNDERLINE_BASELINE_OFFSET, "min=-20.0 max=20.0 step=0.0125");
    mParams->addParam("Debug Draw", &TEXT_BOX_DEBUG_DRAW);
    
    
}
Ejemplo n.º 10
0
void MeshViewApp::setup()
{
	loadConfig("configs/gaztank.ini");

	setupCamera();

	// Create lights
	m_light1 = new gl::Light(gl::Light::DIRECTIONAL, 0);
	m_light1->setDirection(Vec3f(0, 0, 1).normalized());
	m_light1->setAmbient(Color(0.0f, 0.0f, 0.1f));
	m_light1->setDiffuse(Color(0.9f, 0.6f, 0.3f));
	m_light1->setSpecular(Color(0.9f, 0.6f, 0.3f));

	m_light2 = new gl::Light(gl::Light::DIRECTIONAL, 1);
	m_light2->setDirection(Vec3f(0, 0, -1).normalized());
	m_light2->setAmbient(Color(0.0f, 0.0f, 0.0f));
	m_light2->setDiffuse(Color(0.2f, 0.6f, 1.0f));
	m_light2->setSpecular(Color(0.2f, 0.2f, 0.2f));

	// Setup matrix
	m_matrix.setToIdentity();
	m_matrix.translate(Vec3f::zero());
	m_matrix.rotate(Vec3f::zero());
	m_matrix.scale(Vec3f::one());

	m_rotateMesh = false;

	// Create a parameter window
	m_params = params::InterfaceGl::create(getWindow(), "Properties", Vec2i(180, 240));
	m_params->addText("LMB + drag - rotate");
	m_params->addText("RMB + drag - zoom");
	m_params->addSeparator();
	m_params->addButton("Full screen", [&] { setFullScreen(!isFullScreen()); });
	m_params->addParam("Auto rotate", &m_rotateMesh);
	m_params->addSeparator();
	m_params->addParam("Diffuse", &m_diffuseEnabled);
	m_params->addParam("Normal", &m_normalEnabled);
	m_params->addParam("Specular", &m_specularEnabled);
	m_params->addParam("AO", &m_aoEnabled);
	m_params->addParam("Emissive", &m_emissiveEnabled);
	m_params->addSeparator();
	m_params->addParam("Gamma", &m_gamma, "min=0.0 max=10.0 step=0.1");

	m_time = (float)getElapsedSeconds();
}
Ejemplo n.º 11
0
void GeoDeVisualizerApp::setup()
{
    // read the initial world
    json initJSON;
    if (!debug) {
        string JSONBuff;
        if (mServer.open(DEFAULT_PORT, "localhost")) {
            while (!mServer.isReady(JSONBuff)) {};
        }
        initJSON = json::parse(JSONBuff);
    } else {
        ifstream inputFile( "../../../resources/test_data.json" );
        assert( inputFile.good() );
        string JSONBuff(( istreambuf_iterator<char>( inputFile )), ( istreambuf_iterator<char>() ));
        initJSON = json::parse(JSONBuff);
    }
    
    if (!(isInitialJSON(initJSON) and validateInitialJSON(initJSON))) {
        cerr << "Initial JSON was not valid" << endl;
        exit(1);
    }
    
    // WRITE VERTICES AND FACES TO THE TRIMESH
    writeMesh(initJSON);
    mWorld.initialize(initJSON);
    setupColoniesList();
    resourceColors = ResourceColorPicker().getColors(mWorld.numResources());
    

    // SETUP CAMERA
    setupCamVars(mCamVars);
    mCam.setPerspective(75.0f, getWindowAspectRatio(), 0.5f, 2000.0f );
    
    // SETUP PARAMS
    setupParamVars(mCurParams, mPrevParams, mWorld.numResources());
    mParams = params::InterfaceGl::create("GeoDe", Vec2i(200, 400));
    mParams->addParam("scene rotation", &mCamVars.sceneRotation, "opened=1");
    mParams->addParam("eye distance", &mCamVars.cameraDistance, "min=1.0 max=1500.0 step=0.1 keyIncr=s keyDecr=k keyIncr=j");
    mParams->addSeparator();
    mParams->addParam("time", &mCurParams.timeStep);
    mParams->addParam("state", mDisplayModes, &mCurParams.displayMode);
    mParams->addSeparator();
}
Ejemplo n.º 12
0
void FlockingApp::setup()
{	
	Rand::randomize();
	
	mCenter			= vec3( 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			= vec3( 0.0f, 0.0f, mCameraDistance );
	mCenter			= vec3::zero();
	mUp				= vec3::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 5000.0f );

	// SETUP PARAMS
	mParams = params::InterfaceGl::create( "Flocking", ivec2( 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 PinballWarpingApp::setupParams()
{
    mParams = params::InterfaceGl::create("params", ivec2(300,300));
    mParams->addParam("FPS", &mFps);
    mParams->addSeparator();
    mParams->addParam("Draw Image", &mDrawImage);
    mParams->addParam("Debugging", &mPinball.mDebug);
    mParams->addParam("Editing Locations", &mPinball.mIsInEditingMode).updateFn([this] {
        if (!mPinball.mDebug)
            mPinball.saveJson();
    });
  
}
void PhysicallyBasedShadingApp::setupParams()
{
	mParams = params::InterfaceGl::create( "PBR", ivec2( 300, 400 ) );
	mParams->minimize();
	
	mParams->addText( "Material" );
	mParams->addParam( "Roughness", &mRoughness ).min( 0.0f ).max( 1.0f ).step( 0.01f );
	mParams->addParam( "Metallic", &mMetallic ).min( 0.0f ).max( 1.0f ).step( 0.01f );
	mParams->addParam( "Specular", &mSpecular ).min( 0.0f ).max( 1.0f ).step( 0.01f );
	mParams->addParam( "Base Color", &mBaseColor );
	
	mParams->addSeparator();
	mParams->addText( "Light" );
	mParams->addParam( "Animation", &mAnimateLight );
	mParams->addParam( "Radius", &mLightRadius ).min( 0.0f ).max( 20.0f ).step( 0.1f );
	mParams->addParam( "Color", &mLightColor );
	
	mParams->addSeparator();
	mParams->addText( "Camera" );
	mParams->addParam( "Focal Length", &mFocalLength ).min( 0.0f ).step( 1.0f ).updateFn( [this]() {
		if( mFocalLength != sFocalPresetsValues[mFocalLengthPreset] ){
			mFocalLengthPreset = 0;
		}
	} );
	mParams->addParam( "Lense", sFocalPresets, &mFocalLengthPreset );
	mParams->addParam( "Sensor Size", &mSensorSize ).min( 0.0f ).step( 1.0f ).updateFn( [this]() {
		if( mSensorSize != sSensorPresetsValues[mSensorSizePreset] ){
			mSensorSizePreset = 0;
		}
	} );
	mParams->addParam( "Film Gate", sSensorPresets, &mSensorSizePreset );
	mParams->addParam( "F-Stop", &mFStop ).min( 0.25f ).max( 8.0f ).step( 0.25f ).updateFn( [this]() {
		if( mFStop != sFStopPresetsValues[mFStopPreset] ){
			mFStopPreset = 0;
		}
	} );
	mParams->addParam( "F-Stop Preset", sFStopPresets, &mFStopPreset );
}
Ejemplo n.º 15
0
void PointCloudVAO::setupGUI()
{
	mParamStep = 2;
	mParamDepthMin = 100.0f;
	mParamDepthMax = 1000.0f;
	mParamPointSize = 4.0f;

	mGUI = params::InterfaceGl::create("Settings", ivec2(300, 200));
	mGUI->addSeparator();
	mGUI->addParam<int>("paramStep", &mParamStep).optionsStr("label='Spacing'");
	mGUI->addParam<float>("paramDepthMin", &mParamDepthMin).optionsStr("label='Min Depth'");
	mGUI->addParam<float>("paramDepthMax", &mParamDepthMax).optionsStr("label='Max Depth'");
	mGUI->addParam<float>("paramPointSize", &mParamPointSize).optionsStr("label='Point Size'");
}
Ejemplo n.º 16
0
void ITA_ForcesApp::setupGUI()
{
	mParamRadius = 0.25f;
	mParamMagScale = 1.5f;
	mParamDamping = 0.98f;
	mMouseInput = false;
	mNumInputs = 0.0f;

	mGUI = params::InterfaceGl::create("Settings", vec2(300,200));
	mGUI->addParam<bool>("paramMouseInput", &mMouseInput).optionsStr("label='Mouse Input'");
	mGUI->addSeparator();
	mGUI->addParam<float>("paramRadius", &mParamRadius).optionsStr("label='Radius Scale'");
	mGUI->addParam<float>("paramMagScale", &mParamMagScale).optionsStr("label='Magnitude Scale'");
	mGUI->addParam<float>("paramDamping", &mParamDamping).optionsStr("label='Damping'");
}
Ejemplo n.º 17
0
void PS3EyeSlowMoApp::setup()
{
    currentFrame = 0;
    mSkippedFrames = 1;
    using namespace ps3eye;
    
    mShouldQuit = false;
    
    // list out the devices
    std::vector<PS3EYECam::PS3EYERef> devices( PS3EYECam::getDevices() );
    console() << "found " << devices.size() << " cameras" << std::endl;
    
    mTimer = Timer(true);
    mCamFrameCount = 0;
    mCamFps = 0;
    mCamFpsLastSampleFrame = 0;
    mCamFpsLastSampleTime = 0;
    
    if(devices.size())
    {
        eye = devices.at(0);
        bool res = eye->init(640, 480, 60);
        console() << "init eye result " << res << std::endl;
        eye->start();

        frame_bgra = new uint8_t[eye->getWidth()*eye->getHeight()*4];
        mFrame = Surface(frame_bgra, eye->getWidth(), eye->getHeight(), eye->getWidth()*4, SurfaceChannelOrder::BGRA);
        memset(frame_bgra, 0, eye->getWidth()*eye->getHeight()*4);
        
        // create and launch the thread
        mThread = thread( bind( &PS3EyeSlowMoApp::eyeUpdateThreadFn, this ) );
    }
    
    mParams = params::InterfaceGl::create( "PS3EYE", toPixels( ivec2( 180, 150 ) ) );
    
    mParams->addParam( "Framerate", &mFrameRate, "", true );
    mParams->addParam( "Queue", &mQueueSize, "", true);
    mParams->addSeparator();
    mParams->addParam( "Skip", &mSkippedFrames).min( 1 ).step( 1 );
    mParams->addParam( "Auto gain", &isAutoGain );
    mParams->addParam( "Auto WB", &isAutoWB );

    //surfaceQueue = new ph::ConcurrentQueue<Surface*>();

    mAccumFbo = gl::Fbo::create( getWindowWidth(), getWindowHeight(),
                                gl::Fbo::Format().colorTexture( gl::Texture::Format().internalFormat( GL_RGB16F ) ).disableDepth() );
    
}
Ejemplo n.º 18
0
void ThresholdTestApp::setup()
{
	mParams = params::InterfaceGl::create( "Parameters", ivec2( 300, 240 ) );
	mParams->addParam( "Threshold", &mThresholdValue, "min=0 max=255 keyIncr=v keyDecr=V" );
	mParams->addButton( "open file", [this] { loadFile( getOpenFilePath() ); }, "key=o" );
	mParams->addSeparator();
	mParams->addParam( "Use Adapative", &mUseAdaptiveThreshold );
	mParams->addParam( "Use Adapative class", &mUseClassVersion );
	mParams->addParam( "Use Adapative percentage", &mUseAdaptivePercentage );
	mParams->addParam( "Show Grayscale", &mShowOriginalGrayScale );
	mParams->addParam( "Adaptive Kernel", &mAdaptiveThresholdKernel, "min=0 max=1000 keyIncr=k keyDecr=K" );
	mParams->addParam( "Adaptive Percentage", &mAdaptiveThresholdPercentage, "min=0 max=1.0 step=0.01 keyIncr=p keyDecr=P" );
	
	mThresholdValue = 128;
	mAdaptiveThresholdPercentage = 0.01f;
	mAdaptiveThresholdKernel = 64;
	
	loadFile( getOpenFilePath() );
}
Ejemplo n.º 19
0
void ciApp::setup()
{
	// check data folder
	if (!ci::fs::exists(data_path))
		ci::fs::create_directory(data_path);

	// setup fbo
	gl::Fbo::Format fbo_format;
	fbo_format.setSamples(4);
	fbo_format.setColorTextureFormat(gl::Texture2d::Format().internalFormat(GL_RGBA16F));
	fbo = gl::Fbo::create(FBO_WIDTH, FBO_HEIGHT, fbo_format.colorTexture());

	// setup vbo
	particle_buffer = gl::Vbo::create(GL_ARRAY_BUFFER, sizeof(Particle) * MAX_PARTICLES, nullptr, GL_STATIC_DRAW);

	// setup vao
	{
		particle_vao = gl::Vao::create();
		const gl::ScopedVao scp_vao(particle_vao);

		gl::enableVertexAttribArray(0);
		gl::enableVertexAttribArray(1);
		gl::vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Particle), (const GLvoid*)offsetof(Particle, position));
		gl::vertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Particle), (const GLvoid*)offsetof(Particle, color));
	}

	// PixelSaver
	pixel_saver = PixelSaver::create(data_path / "print_screen");

	// setup camera
	camera_ui = CameraUi(&camera, getWindow(), -500);
	camera.setPerspective(50.0f, (float)FBO_WIDTH / FBO_HEIGHT, 0.01f, 100.0f);
	camera.lookAt(vec3(-5, 0, 0), vec3(0));

	// setup params
	params = params::InterfaceGl::create(getWindow(), "parameters", ivec2(250, 300));
	params->addSeparator();

	// first reset
	reset();
}
void SpawnObjectApp::setup()
{
    mFixtures		= Fixture::loadFixtures( getAssetPath("fixtures_001.csv") );			// load CSV fixtures file
    
    mFixtureMesh    = Fixture::loadObj( getAssetPath("sphere.obj") );						// load fixture mesh
    mVenueMesh      = Fixture::loadObj( getAssetPath("piano2.obj") );						// load venue mesh
    
    mFadeIn         = 0.5f;
    mFadeOut        = 0.1f;
    mSpeed          = 0.2f;
    mRadius         = 1.5f;
    mPointsN        = 8;
    mDeg            = 3;

    mModule         = SpawnModule::create();                                                // create module
    
    mParams         = params::InterfaceGl::create( "Params", Vec2i( 200, 240 ) );           // Gui
    
    mParams->addParam( "Fade IN",   &mFadeIn    , "min=0.001 max=1.0 step=0.001" );
    mParams->addParam( "Fade OUT",  &mFadeOut   , "min=0.001 max=1.0 step=0.001" );
    mParams->addSeparator();
    
    mParams->addParam( "Speed",     &mSpeed     , "min=0.001 max=10.0 step=0.001" );
    mParams->addParam( "Radius",    &mRadius    , "min=0.1 max=15.0 step=0.1" );
    mParams->addParam( "Points N",  &mPointsN   , "min=2 max=100 step=1" );
    mParams->addParam( "Deg",       &mDeg       , "min=1 max=10 step=1" );
    
    ci::CameraPersp initialCam;                                                             // Initialise camera
    initialCam.setPerspective( 45.0f, ci::app::getWindowAspectRatio(), 0.1, 3000 );
    mMayaCam        = MayaCamUI( initialCam );
    
    // Set up light
    mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
    mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() );
    mLight->setAmbient( ColorAf::gray( 0.843f ) );
    mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) );
    mLight->enable();
    
    // create a path
    mModule->createPath( mPointsN, mDeg, mRadius );
}
Ejemplo n.º 21
0
void NormalGetterApp::setupParams(){
    mParams = params::InterfaceGl::create( "Normal Getter", vec2( 300, 220 ) );
    mParams->addSeparator();
    mParams->addButton("InvertG", [&](){
        invertG = !invertG;
    });
    mParams->addButton("InvertR", [&](){
        invertR =! invertR;
    });
    mParams->addParam("bias", &bias).min(0.f).max(100.f);
    mParams->addButton( "Load movie", [ & ](){
        makeMovie = true;
    } );
    mParams->addButton( "Play movie", [ & ](){
        if(mMovie) mMovie->play();
    } );
    mParams->addButton( "Stop movie", [ & ](){
        if(mMovie) mMovie->stop();
    } );
    mParams->addButton( "Choose Save Directory", [ & ](){
        saveDirectory = getFolderPath();
        directory = saveDirectory.string();
    } );
    mParams->addParam("Save Directory", &directory).updateFn([&](){
        saveDirectory = directory;
    });
    mParams->addButton( "Process Frame", [ & ](){
        if(mMovie && mOutputFbo)writeImage(saveDirectory / string(to_string(1000000 +int(mMovie->getCurrentTime()*mMovie->getFramerate()))+ ".png"), mOutputFbo->getColorTexture()->createSource(), ImageTarget::Options(),"png");
    } );
    mParams->addButton( "Process Batch", [ & ](){
        if(!pushFramesToBuffer && mMovie){
            pushFramesToBuffer = true;
            currentFrame = 0;
            mMovie->seekToStart();
            mMovie->setLoop(false);
            mMovie->play();
        }
    } );

}
Ejemplo n.º 22
0
void ParamsBasicApp::setup()
{
    
    ObjLoader loader( (DataSourceRef)loadResource( "Final_sculpture3.obj" ) );
	loader.load( &mMesh );
    a = 1;
    e = 1;
    c = 1;
	mVBO = gl::VboMesh( mMesh );
    mMesh.recalculateNormals();
        mCameraDistance = 25;
    receiver.setup(3000);
	mObjSize = 4;
    mEye = Vec3f(-1,0.8f,1);
	mLightDirection = Vec3f( -0.54f, -0.27f, -1.07f );
	mColor = ColorA( 0.25f, 0.5f, 1.0f, 1.0f );
    mCam.setPerspective( 60.0f, getWindowAspectRatio(), 0.1f, 30000.0f );
	// setup our default camera, looking down the z-axis
	mCam.lookAt( mEye, Vec3f(0,0,0) );
    
	// Setup the parameters
	mParams = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( 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, "" );
	mParams->addButton( "Button!", std::bind( &ParamsBasicApp::button, this ) );
	mParams->addText( "text", "label=`This is a label without a parameter.`" );
	mParams->addParam( "String ", &mString, "" );
    mParams->addParam( "Eye Distance", &mCameraDistance, "min=1.0 max=100.0 step=1.0 keyIncr=s keyDecr=w" );
    
    
    
    
}
Ejemplo n.º 23
0
void cApp::makeGui(){
    gui = params::InterfaceGl::create( getWindow(), "Ramses", vec2(300, getWindowHeight()) );
    gui->setOptions( "", "position=`0 0` valueswidth=100" );
    
    function<void(void)> update = [&](){
        for( int i=0; i<rms.size(); i++){
            rms[i].updateVbo(eye);
        }
    };
    
    
    function<void(void)> sx = [this](){
        saveXml();
    };
    
    function<void(void)> ld = [this](){
        loadXml();
        for( int i=0; i<rms.size(); i++){
            rms[i].eSimType = simType;
            rms[i].loadSimData(frame);
            rms[i].updateVbo(eye);
        }
    };

    function<void(void)> ren = [this](){
        bStart = true;
        mExp.startRender();
    };
    
    gui->addText( "main" );
    gui->addParam("start", &bStart );
    gui->addParam("frame", &frame ).updateFn(update);
    gui->addParam("ortho", &bOrtho );
    gui->addParam("xyz global scale", &Ramses::globalScale ).step(0.01).updateFn(update);
    //gui->addParam("r(x) resolution", &Ramses::boxelx, true );
    //gui->addParam("theta(y) resolution", &Ramses::boxely, true );
    gui->addButton("save XML", sx );
    gui->addButton("load XML", ld );
    gui->addButton("start Render", ren );

    gui->addSeparator();
    
    for( int i=0; i<6; i++){
        string p = to_string(simType) + "_"+  Ramses::prm[i];
        
        function<void(void)> up = [i, this](){
            rms[i].updateVbo(eye);
        };
        
        function<void(void)> up2 = [i, this](){
            rms[i].loadSimData(this->frame);
            rms[i].updateVbo(eye);
        };
        
        gui->addParam(p+" show", &rms[i].bShow ).group(p).updateFn(up2);
        //gui->addParam(p+" polar coordinate", &rms[i].bPolar ).group(p).updateFn(up2);
        
        gui->addParam(p+" Auto Min Max", &rms[i].bAutoMinMax ).group(p).updateFn(up);
        gui->addParam(p+" in min", &rms[i].in_min).step(0.05f).group(p).updateFn(up);
        gui->addParam(p+" in max", &rms[i].in_max).step(0.05f).group(p).updateFn(up);
        
        gui->addParam(p+" z extrude", &rms[i].extrude).step(1.0f).group(p).updateFn(up);
        //gui->addParam(p+" x offset", &rms[i].xoffset).step(1.0f).group(p).updateFn(up);
        //gui->addParam(p+" y offset", &rms[i].yoffset).step(1.0f).group(p).updateFn(up);
        //gui->addParam(p+" z offset", &rms[i].zoffset).step(1.0f).group(p).updateFn(up);
        
        gui->addParam(p+" xy scale", &rms[i].scale).step(1.0f).group(p).updateFn(up);
        //gui->addParam(p+" visible thresh", &rms[i].visible_thresh).step(0.005f).min(0.0f).max(1.0f).group(p).updateFn(up);
        gui->addParam(p+" log", &rms[i].eStretch).step(1).min(0).max(1).group(p).updateFn(up2);
        
        // read only
        //gui->addParam(p+" r(x) resolution", &rms[eSimType][i].boxelx, true );
        //gui->addParam(p+" theta(y) resolution", &rms[eSimType][i].boxely, true );
        
        //gui->addParam(p+" visible rate(%)", &rms[i].visible_rate, true ).group(p);
        //gui->addParam(p+" num particle", &rms[i].nParticle, true).group(p);
        
        gui->addSeparator();
        
    }
}
Ejemplo n.º 24
0
void cApp::makeGui(){
    gui = params::InterfaceGl::create( getWindow(), Ramses::simType[eSimType], vec2(300, getWindowHeight()) );
    gui->setOptions( "", "position=`0 0` valueswidth=100" );
    
    function<void(void)> update = [&](){
        for( int i=0; i<rms.size(); i++){ rms[i].updateVbo(resolution); }
    };
    
    function<void(void)> changeSym = [this](){
        for( int i=0; i<rms.size(); i++){
            rms[i].eSimType = eSimType;
            rms[i].loadSimData(frame);
            rms[i].updateVbo(resolution);
        }
    };
    
    function<void(void)> sx = [this](){
        saveXml();
    };
    
    function<void(void)> ld = [this](){
        loadXml();
        for( int i=0; i<rms.size(); i++){
            rms[i].eSimType = eSimType;
            rms[i].loadSimData(frame);
            rms[i].updateVbo(resolution);
        }
    };
    
    function<void(void)> ren = [this](){
        bStart = true;
        mExp.startRender();
    };
    
    function<void(void)> norm = [this](){

        norms.resetCol();
        norms.resetPos();
        norms.resetVbo();
        
        for( int i=0; i<rms.size(); i++){
            if(rms[i].bShow){
                feature3d( rms[i].pos );
            }
        }
        norms.init(GL_LINES);
    };
    
    gui->addText( "main" );
    gui->addParam("simType", &eSimType ).min(0).max(4).updateFn( changeSym );
    gui->addParam("start", &bStart );
    gui->addParam("frame", &frame ).updateFn(update);
    gui->addParam("ortho", &bOrtho );
    gui->addButton("Compute Norm", norm );

    gui->addParam("xyz global scale", &Ramses::globalScale ).step(0.01).updateFn(update);
    gui->addParam("r(x) resolution", &Ramses::boxelx, true );
    gui->addParam("theta(y) resolution", &Ramses::boxely, true );
    gui->addButton("save XML", sx );
    gui->addButton("load XML", ld );
    gui->addButton("start render", ren );
    
    gui->addSeparator();
    
    for( int i=0; i<6; i++){
        string p = Ramses::prm[i];
        //gui->addText( p );
        
        //function<void(void)> up = bind(&Ramses::updateVbo, &rms[i]);
        function<void(void)> up = [i, this](){
            rms[i].updateVbo(resolution);
        };
        
        function<void(void)> up2 = [i, this](){
            rms[i].loadSimData(this->frame);
            rms[i].updateVbo(resolution);
        };
        
        gui->addParam(p+" show", &rms[i].bShow ).group(p).updateFn(up2);
        gui->addParam(p+" polar coordinate", &rms[i].bPolar ).group(p).updateFn(up2);
        gui->addParam(p+" Auto Min Max", &rms[i].bAutoMinMax ).group(p).updateFn(up);
        gui->addParam(p+" in min", &rms[i].in_min).step(0.05f).group(p).updateFn(up);
        gui->addParam(p+" in max", &rms[i].in_max).step(0.05f).group(p).updateFn(up);
        
        gui->addParam(p+" z extrude", &rms[i].extrude).step(1.0f).group(p).updateFn(up);
        gui->addParam(p+" x offset", &rms[i].xoffset).step(1.0f).group(p).updateFn(up);
        gui->addParam(p+" y offset", &rms[i].yoffset).step(1.0f).group(p).updateFn(up);
        gui->addParam(p+" z offset", &rms[i].zoffset).step(1.0f).group(p).updateFn(up);
        
        gui->addParam(p+" xy scale", &rms[i].scale).step(1.0f).group(p).updateFn(up);
        //gui->addParam(p+" visible thresh", &rms[i].visible_thresh).step(0.005f).min(0.0f).max(1.0f).group(p).updateFn(up);
        gui->addParam(p+" log", &rms[i].eStretch).step(1).min(0).max(1).group(p).updateFn(up2);
        gui->addParam(p+" inAngle", &rms[i].inAngle).step(1).min(-180).max(180).group(p).updateFn(up);
        gui->addParam(p+" outAngle", &rms[i].outAngle).step(1).min(-180).max(180).group(p).updateFn(up);
        gui->addParam(p+" offsetRotateAngle", &rms[i].offsetRotateAngle).step(0.01).group(p).updateFn(up);
        gui->addParam(p+" rotateSpeed", &rms[i].rotateSpeed).step(0.01).group(p).updateFn(up);
        
        // read only
        //gui->addParam(p+" visible rate(%)", &rms[i].visible_rate, true ).group(p);
        //gui->addParam(p+" num particle", &rms[i].nParticle, true).group(p);
        
        gui->addSeparator();
    }
}
Ejemplo n.º 25
0
void OpenCVTemplateApp::makeGUI() {
    interface->clear();
    interface->addButton("load image", [this] {
        auto path = ci::app::getOpenFilePath();
        image = cv::imread(path.string());
        std::cout <<"cols "<<image.cols << std::endl;
        std::cout <<"rows "<<image.rows << std::endl;
        std::cout <<"channels "<<image.channels() << std::endl;
        imageTexture = gl::Texture::create(fromOcv(image));
    });
    interface->addButton("load video", [this] {
        auto path = ci::app::getOpenFilePath();
        video.open(path.string());
        frameWidth = video.get(cv::CAP_PROP_FRAME_WIDTH);
        frameHeight = video.get(cv::CAP_PROP_FRAME_HEIGHT);
        totalFrames = video.get(cv::CAP_PROP_FRAME_COUNT);
        video.read(frame);
        if(isGrayScale) {
            cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);
        }
        frameTexture = gl::Texture::create(fromOcv(frame));
        makeGUI();
    });
    interface->addSeparator();
    if(frameTexture) {
        interface->addParam("gray scale", &isGrayScale).updateFn([this] {
            video.retrieve(frame);
            if(isGrayScale) {
                cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);
            }
            frameTexture = gl::Texture::create(fromOcv(frame));
            makeGUI();
        });
        interface->addParam("nb of feature",&nbOfFeaturePoints).min(1).max(1000);
        if(isGrayScale) {
            interface->addButton("get feature points", [this] {
                cv::goodFeaturesToTrack(frame, featurePoints, nbOfFeaturePoints, 0.01, 10, cv::Mat(), 3, 0, 0.04);
            });
        }
        interface->addSeparator();
        interface->addParam("frame",&frameIndex).min(0).max(totalFrames-1).step(1).updateFn([this] {
            video.set(cv::CAP_PROP_POS_FRAMES,frameIndex);
            video.read(frame);
            if(isGrayScale) {
                cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);
            }
            frameTexture = gl::Texture::create(fromOcv(frame));
        });
        interface->addSeparator();
        interface->addParam("speed", &frameSpeed).min(1).max(1000).step(1);
        interface->addButton("play",[this] {
            currentState = PLAY;
            makeGUI();
        });
        if(currentState == PLAY) {
            interface->addButton("pause",[this] {
                currentState = PAUSE;
                makeGUI();
            });
        }
    }
}
Ejemplo n.º 26
0
void GeometryApp::createParams()
{
#if ! defined( CINDER_GL_ES )
	vector<string> primitives = { "Capsule", "Cone", "Cube", "Cylinder", "Helix", "Icosahedron", "Icosphere", "Sphere", "Teapot", "Torus", "Torus Knot", "Plane", "Rectangle", "Rounded Rectangle", "Circle", "Ring" };
	vector<string> qualities = { "Low", "Default", "High" };
	vector<string> viewModes = { "Shaded", "Wireframe" };
	vector<string> texturingModes = { "None", "Procedural", "Sampler" };

	mParams = params::InterfaceGl::create( getWindow(), "Geometry Demo", toPixels( ivec2( 300, 400 ) ) );
	mParams->setOptions( "", "valueswidth=100 refresh=0.1" );

	mParams->addParam( "Primitive", primitives, (int*)&mPrimitiveSelected ).updateFn( std::bind( &GeometryApp::updateParams, this ) );
	mParams->addParam( "Quality", qualities, (int*)&mQualitySelected );
	mParams->addParam( "Viewing Mode", viewModes, (int*)&mViewMode );
	mParams->addParam( "Texturing Mode", texturingModes, (int*)&mTexturingMode );

	mParams->addSeparator();

	mParams->addParam( "Show Grid", &mShowGrid );
	mParams->addParam( "Show Normals", &mShowNormals );
	mParams->addParam( "Show Tangents", &mShowTangents );
	mParams->addParam( "Show Colors", &mShowColors ).updateFn( [this] { createGeometry(); } );
	mParams->addParam( "Face Culling", &mEnableFaceFulling ).updateFn( [this] { gl::enableFaceCulling( mEnableFaceFulling ); } );

	mParams->addSeparator();

	mParams->addParam( "Show Wire Primitive", &mShowWirePrimitive );
	mParams->addParam( "Show Solid Primitive", &mShowSolidPrimitive );

	mParams->addSeparator();

	//
	mPrimitiveParams.resize( PRIMITIVE_COUNT );

	// Capsule
	mPrimitiveParams[CAPSULE].push_back( mParams->addParam( "Capsule: Radius", &mCapsuleRadius ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[CAPSULE].push_back( mParams->addParam( "Capsule: Length", &mCapsuleLength ).step( 0.05f ).updateFn( [this] { createGeometry(); } ) );

	// Cone
	mPrimitiveParams[CONE].push_back( mParams->addParam( "Cone: Ratio", &mConeRatio ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );

	// Helix
	mPrimitiveParams[HELIX].push_back( mParams->addParam( "Helix: Ratio", &mHelixRatio ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[HELIX].push_back( mParams->addParam( "Helix: Coils", &mHelixCoils ).step( 0.1f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[HELIX].push_back( mParams->addParam( "Helix: Twist", &mHelixTwist ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[HELIX].push_back( mParams->addParam( "Helix: Twist Offset", &mHelixOffset ).step( 0.05f ).updateFn( [this] { createGeometry(); } ) );

	// Ring
	mPrimitiveParams[RING].push_back( mParams->addParam( "Ring: Width", &mRingWidth ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );

	// Rounded Rect
	mPrimitiveParams[ROUNDEDRECT].push_back( mParams->addParam( "Corner Radius", &mRoundedRectRadius ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );

	// Torus
	mPrimitiveParams[TORUS].push_back( mParams->addParam( "Torus: Ratio", &mTorusRatio ).step( 0.01f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUS].push_back( mParams->addParam( "Torus: Twist", &mTorusTwist ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUS].push_back( mParams->addParam( "Torus: Twist Offset", &mTorusOffset ).step( 0.05f ).updateFn( [this] { createGeometry(); } ) );

	// Torus Knot
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Parameter P", &mTorusKnotP ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Parameter Q", &mTorusKnotQ ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Scale X", &mTorusKnotScale.x ).step( 0.1f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Scale Y", &mTorusKnotScale.y ).step( 0.1f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Scale Z", &mTorusKnotScale.z ).step( 0.1f ).updateFn( [this] { createGeometry(); } ) );
	mPrimitiveParams[TORUSKNOT].push_back( mParams->addParam( "Torus Knot: Radius", &mTorusKnotRadius ).step( 0.05f ).updateFn( [this] { createGeometry(); } ) );

	updateParams();
#endif
}
void ImageRetargetingApp::initGUI()
{
    linearScalingParams->addButton( "Reset Image", std::bind( &ImageRetargetingApp::linearResizeResetButtonClick, this ) );
    linearScalingParams->addSeparator();
    linearScalingParams->addParam("Original Width: ", &originalWidth, true);
    linearScalingParams->addParam("Original Height: ", &originalHeight, true);
    linearScalingParams->addParam( "Resize Width", &linearScaleWidth ).min( 1 ).max( 1200 ).step( 1 );
    linearScalingParams->addParam( "Resize Height", &linearScaleHeight ).min( 1 ).max( 750 ).step( 1 );
    linearScalingParams->addButton( "Resize", std::bind( &ImageRetargetingApp::linearResizeButtonClick, this ) );
    linearScalingParams->addSeparator();
    
    meshWarpingParams->addButton( "Reset Mesh", std::bind( &ImageRetargetingApp::meshWarperResetButtonClick, this ) );
    meshWarpingParams->addParam( "Quad Size", &(meshWarpRetargetter->quadSize) ).min( 5 ).max( 100 ).step( 1 );
    meshWarpingParams->addButton( "Toggle Wire Frame", std::bind( &ImageRetargetingApp::toggleWireFrameButtonClick, this ) );
    meshWarpingParams->addSeparator();
    meshWarpingParams->addText("Segmentation");
    meshWarpingParams->addParam( "Blur", &saliencySegmentor->segBlurDeviation ).min( 0.01f ).max( 1.00f ).step( 0.01f );
    meshWarpingParams->addParam( "K",&saliencySegmentor->segNeighborThreshold ).min( 0.0f ).max( 1500.0f ).step( 10.f );
    meshWarpingParams->addParam( "Min Size", &saliencySegmentor->segMinSize).min( 0 ).max( 1500 ).step( 10 );
    meshWarpingParams->addButton( "Segment Random", std::bind( &ImageRetargetingApp::segmentRandomButtonClick, this ) );
    meshWarpingParams->addButton( "Segment Color", std::bind( &ImageRetargetingApp::segmentColorButtonClick, this ) );
    meshWarpingParams->addSeparator();
    meshWarpingParams->addText("Saliency");
    meshWarpingParams->addParam( "Scale", &(saliencySegmentor->scale) ).min( 1 ).max( 10 ).step( 1 );
    meshWarpingParams->addButton( "Sobel Saliency", std::bind( &ImageRetargetingApp::sobelSaliencyButtonClick, this ) );
    meshWarpingParams->addButton( "Segment Saliency", std::bind( &ImageRetargetingApp::segmentSaliencyButtonClick, this ) );
    meshWarpingParams->addButton( "Edge Saliency", std::bind( &ImageRetargetingApp::getPatchEdgeClick, this ) );
    meshWarpingParams->addSeparator();
    meshWarpingParams->addText("Quad Warping");
    meshWarpingParams->addParam( "Resize Width", &(meshWarpRetargetter->resizeWidth) ).min( 1 ).max( 1200 ).step( 1 );
    meshWarpingParams->addParam( "Resize Height", &(meshWarpRetargetter->resizeHeight) ).min( 1 ).max( 750 ).step( 1 );
    meshWarpingParams->addParam( "Linear Weight", &(meshWarpRetargetter->transformationWeight) ).min( 0.f ).max( 1.f ).step( 0.1f );
    meshWarpingParams->addButton( "Resize Rect", std::bind( &ImageRetargetingApp::resizeMeshRect, this ) );
    meshWarpingParams->addButton( "Resize Ellipse", std::bind( &ImageRetargetingApp::resizeMeshEllipse, this ) );
    meshWarpingParams->addParam("Resize Time: ", &(meshWarpRetargetter->resizeTime), true);
    meshWarpingParams->addSeparator();
    
    seamCarvingParams->addButton( "Reset Image", std::bind( &ImageRetargetingApp::seamCarveResetButtonClick, this ) );
    seamCarvingParams->addSeparator();
    seamCarvingParams->addParam( "Scale", &(seamCarver->scale) ).min( 1 ).max( 20 ).step( 1 );
    seamCarvingParams->addButton( "Sobel Gradient", std::bind( &ImageRetargetingApp::sobelGradientButtonClick, this ) );
    seamCarvingParams->addSeparator();
    seamCarvingParams->addButton( "Show Vertical Seam", std::bind( &ImageRetargetingApp::verticalSeamGradientButtonClick, this ) );
    seamCarvingParams->addButton( "Show Horizontal Seam", std::bind( &ImageRetargetingApp::horizontalSeamGradientButtonClick, this ) );
    seamCarvingParams->addSeparator();
    seamCarvingParams->addButton( "Get Gradient", std::bind( &ImageRetargetingApp::sobelGradientButtonClick, this ) );
    seamCarvingParams->addButton( "Get Seam", std::bind( &ImageRetargetingApp::verticalSeamGradientButtonClick, this ) );
    seamCarvingParams->addButton( "Delete Seam", std::bind( &ImageRetargetingApp::deleteCurrentSeamButtonClick, this ) );
    //seamCarvingParams->addButton( "Add Seam", std::bind( &ImageRetargetingApp::addCurrentSeamButtonClick, this ) );
    seamCarvingParams->addSeparator();
    seamCarvingParams->addParam( "Resize Width", &(seamCarver->newWidth) ).min( 1 ).max( 1200 ).step( 1 );
    seamCarvingParams->addParam( "Resize Height", &(seamCarver->newHeight) ).min( 1 ).max( 750 ).step( 1 );
    seamCarvingParams->addButton( "Resize", std::bind( &ImageRetargetingApp::resizeSeamButtonClick, this ) );
    seamCarvingParams->addParam("Resize Time: ", &(seamCarver->carveTime), true);
    seamCarvingParams->addSeparator();
}
Ejemplo n.º 28
0
void hidTestApp::setup()
{
	mJsonManager				= heartbeat::JsonManager::create("test.json");
    mSvgManager                 = heartbeat::SvgManager::create();
    mSvgManager->initialize();
	mEventManager				= heartbeat::EventManager::create( "global", true );
	mInteractionZones			= heartbeat::InteractionZones::create();
	mInteractionZonesDebug		= heartbeat::InteractionDebugRenderable::create( mInteractionZones );
	mKioskManager				= heartbeat::KioskManager::create();
	mKioskManager->initialize();
	
	mInteractionZones->initialize();
	mInteractionZonesDebug->initialize();
	
	mInteractionZonesDebug->enableDistance();
	mInteractionZonesDebug->enableZone();
	
	using namespace heartbeat;
	
	mFar = mInteractionZones->getZoneScalar( InteractionZones::Zone::FAR );
	mApproach = mInteractionZones->getZoneScalar( InteractionZones::Zone::APPROACH );
	mDead = mInteractionZones->getZoneScalar( InteractionZones::Zone::DEAD );
	mTable = mInteractionZones->getZoneScalar( InteractionZones::Zone::TABLE );
	
	mParams = params::InterfaceGl::create( "Interaction Zone Debug", ivec2( 300, 400 ) );
	
	// Unsafe but needed.
	mParams->addButton( "Capture Table Barrier", [&]() {
		mInteractionZones->captureBarrier();
		mInteractionZonesDebug->enableZone();
	});
	mParams->addButton( "Write Table Barrier", [&]() {
		mInteractionZones->writeInteractionZone();
	});
	
	mParams->addButton( "Toggle Live Distance", [&](){
		mInteractionZonesDebug->enableDistance( ! mInteractionZonesDebug->isDistanceEnabled() );
	});
	mParams->addButton( "Toggle Table Barrier", [&](){
		mInteractionZonesDebug->enableZone( ! mInteractionZonesDebug->isZoneEnabled() );
	});
	mParams->addSeparator();
	mParams->addButton( "Query/Store Ignore Indices(Poles)", std::bind( &InteractionZones::queryIgnoreIndices, mInteractionZones ) );
	mParams->addButton( "Print Current Ignore Indices(Poles)", [&](){
		std::cout << "Printing ignore indices: ";
		auto ignoreIndices = mInteractionZones->getIgnoreIndices();
		int last = 0;
		for( auto & indice : ignoreIndices ) {
			if( last == 0 ) {
				last = indice;
			}
			if( last != indice-1 ) {
				cout << endl << "  New Ignore Zone: ";
			}
			cout << indice << ", ";
			last = indice;
		}
		std::cout << std::endl;
	});
	mParams->addButton( "Clear Current Ignore Indices(Poles)", [&](){
		const_cast<std::vector<uint32_t>&>(mInteractionZones->getIgnoreIndices()).clear();
	});
	mParams->addSeparator();
	mParams->addText("Zone Scalars (No Overlapping)");
	mParams->addParam("Set Far Zone", &mFar).updateFn( std::bind( &hidTestApp::updateFar, this ) );
	mParams->addParam("Set Approach Zone", &mApproach).updateFn( std::bind( &hidTestApp::updateApproach, this ) );
	mParams->addParam("Set Dead Zone", &mDead).updateFn( std::bind( &hidTestApp::updateDead, this ) );
	mParams->addParam("Set Table Zone", &mTable).updateFn( std::bind( &hidTestApp::updateTable, this ) );
	mParams->addButton("Submit Zone Changes", std::bind( &hidTestApp::updateZones, this ) );
	mParams->addSeparator();
	mParams->addText("Teensy Settings");
	mParams->addButton("Send Top Teensy Approach", [&](){
		mEventManager->queueEvent( EventDataRef( new ApproachEvent( KioskId::TOP_KIOSK ) ) );
	});
	mParams->addButton("Send Top Teensy Depart", [&](){
		mEventManager->queueEvent( EventDataRef( new DepartEvent( KioskId::TOP_KIOSK ) ) );
	});
	mParams->addButton("Send Middle Teensy Approach", [&](){
		mEventManager->queueEvent( EventDataRef( new ApproachEvent( KioskId::MIDDLE_KIOSK ) ) );
	});
	mParams->addButton("Send Middle Teensy Depart", [&](){
		mEventManager->queueEvent( EventDataRef( new DepartEvent( KioskId::MIDDLE_KIOSK ) ) );
	});
	mParams->addButton("Send Bottom Teensy Approach", [&](){
		mEventManager->queueEvent( EventDataRef( new ApproachEvent( KioskId::BOTTOM_KIOSK ) ) );
	});
	mParams->addButton("Send Bottom Teensy Depart", [&](){
		mEventManager->queueEvent( EventDataRef( new DepartEvent( KioskId::BOTTOM_KIOSK ) ) );
	});
	
//	mParams->addButton("Set Teensy TOP", );
}