예제 #1
0
파일: MASOSApp.cpp 프로젝트: ltowarek/MASOS
void MASOSApp::setup()
{
    mShouldQuit = false;
    reset();

    mParams = params::InterfaceGl::create(getWindow(), "Parameters", toPixels(ivec2(250, 300)));

    mParams->addParam("Initial Velocity [m/s]", &mInitialVelocity, "min=0");
    mParams->addParam("Angle [']", &mAngle, "min=0, max=90");
    mParams->addParam("Terminal Velocity [m/s]", &mTerminalVelocity, "min=1");
    mParams->addParam("Current time [s]", &mCurrentTime, "min=0");
    mParams->addParam("Delta time [ms]", &mDeltaTime, "step=25");
    mParams->addParam("Start time [s]", &mStartTime, "min=0");
    mParams->addParam("End time [s]", &mEndTime, "min=0");
    mParams->addButton("Start", bind(&MASOSApp::buttonStart, this));
    mParams->addButton("Pause", bind(&MASOSApp::buttonPause, this));
    mParams->addButton("Reset", bind(&MASOSApp::buttonReset, this));

    mParams->addParam("Scale", &scale);
    mParams->addParam("Pos X", &currX);
    mParams->addParam("Pos Y", &currY);

    mIsPlaying = false;
    mThreadPlay = shared_ptr<thread>(new thread(bind(&MASOSApp::playLoop, this)));
}
예제 #2
0
void PointCloudApp::setup()
{
    mCamUi = CameraUi(&mCam);

	gl::enable( GL_TEXTURE_2D );
	
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mTimeStamp		= 0L;
	mTimeStampPrev	= mTimeStamp;
	
	loadGlsl();

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame& frame )
	{
		mSurfaceColor	= frame.getSurface();
	} );
	mDevice->connectDepthEventHandler( [ & ]( const Kinect2::DepthFrame& frame )
	{
		mChannelDepth	= frame.getChannel();
		mTimeStamp		= frame.getTimeStamp();
	} );

	//////////////////////////////////////////////////////////////////////////////////////////////

	ivec2 sz = Kinect2::DepthFrame().getSize();
	vector<vec2> vertices;
	for ( int32_t x = 0; x < sz.x; ++x ) {
		for ( int32_t y = 0; y < sz.y; ++y ) {
			vertices.push_back( vec2( x, y ) / vec2( sz ) );
		}
	}

	gl::VboRef vbo = gl::Vbo::create( GL_ARRAY_BUFFER, vertices.size() * sizeof( vec2 ), &vertices[ 0 ], GL_STATIC_DRAW );

	geom::BufferLayout layout;
	layout.append( geom::Attrib::POSITION, 2, sizeof( vec2 ), 0 );
	vector<pair<geom::BufferLayout, gl::VboRef>> vertexArrayBuffers = { make_pair( layout, vbo ) };

	mVboMesh = gl::VboMesh::create( vertices.size(), GL_POINTS, vertexArrayBuffers );

	//////////////////////////////////////////////////////////////////////////////////////////////
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 120 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,				"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Load GLSL",	[ & ]() { loadGlsl(); },	"key=g" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },		"key=q" );

	resize();
}
예제 #3
0
파일: ForestApp.cpp 프로젝트: UIKit0/forest
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);
}
예제 #4
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 MPEBouncingBallApp::setup()
{
    mClient = MPEClient::Create(this, USE_THREADED);

    // 3D
    mClient->setIsRendering3D(true);
    mCamZ = -900.0f;
    mClient->set3DCameraZ(mCamZ);
    mFOV = mClient->get3DFieldOfView();
    mAspectRatio = mClient->get3DAspectRatio();
    
    mParams = params::InterfaceGl::create("Camera Params", vec2(getWindowSize()) * getWindowContentScale());
    mParams->setPosition(ivec2(0,0));
    mParams->addParam("Field of View", &mFOV).min(1.f).max(180.f).step(0.5);
    mParams->addParam("Camera Z", &mCamZ).min(-1500.f).max(0.f);
    mParams->addParam("Aspect Ratio", &mAspectRatio).min(0.f).max(2.f);
    mParams->addButton("Reset", [&](){ this->buttonResetClicked(); } );
    mParams->addButton("Render Mode (2D/3D)", [&](){ this->buttonRenderModeClicked(); } );

    mFont = Font( "Helvetica Bold", 12 );
    mTextureFont = gl::TextureFont::create( mFont );
}
예제 #6
0
파일: MeshViewApp.cpp 프로젝트: zulis/Imrod
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();
}
예제 #7
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() );
}
예제 #8
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();
        }
    } );

}
예제 #9
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" );
    
    
    
    
}
void OpenNI2xCinderBlockSample::setup()
{
	m_OpenNI2xBlock.init(true);
	for(int i=0; i<m_OpenNI2xBlock.getDevicesConnected(); i++)
		m_OpenNI2xBlock.startDevice(i);
	
	m_bMirrored=true;		//this is default for openni
	m_bAlign=false;
	m_bSubtractBg=false;
	m_bIsRecording=false;
	m_iRecording=0;
	m_bIsPlaying=false;

	// Setup the parameters
	m_Params = params::InterfaceGl::create( getWindow(), "OpenNI parameters", toPixels( Vec2i( 200, 400 ) ) );
	m_Params->addButton( "Mirrored", std::bind( &OpenNI2xCinderBlockSample::setMirrored, this ) );
	m_Params->addButton( "Reset", std::bind( &OpenNI2xCinderBlockSample::resetStreams, this ) );
	m_Params->addButton( "Align Depth/RGB", std::bind( &OpenNI2xCinderBlockSample::alignDepthRGB, this ) );
	m_Params->addButton( "Subtract Background", std::bind( &OpenNI2xCinderBlockSample::subtractBg, this ) );
	m_Params->addButton( "Start/Stop Record", std::bind( &OpenNI2xCinderBlockSample::record, this ) );
	m_Params->addButton( "Play", std::bind( &OpenNI2xCinderBlockSample::play, this ) );
	m_Params->addButton( "Stop", std::bind( &OpenNI2xCinderBlockSample::stop, this ) );
	m_Params->addButton( "Pause", std::bind( &OpenNI2xCinderBlockSample::pause, this ) );
}
예제 #11
0
void TextParticlesApp::setup()
{
	// SET UP camera
	mCam  = CameraPersp( getWindowWidth(), getWindowHeight(), 60, 1.0, 10000.0  );
	mCamUi = CameraUi( &mCam );
	
	// LOAD fonts
	mFont = Font( loadAsset( "SourceSansPro-Bold.ttf" ), 120 );
	mTextureFont = gl::TextureFont::create( mFont );
	
	// DEFINE FBO
	mTextFbo = gl::Fbo::create( getWindowWidth(), getWindowHeight(), true );
	
	// LOAD shaders
	mRenderProg = gl::getStockShader( gl::ShaderDef().color() );
	try {
		mUpdateProg = gl::GlslProg::create( gl::GlslProg::Format().vertex( loadAsset( "shaders/particleUpdate.vs" ) )
			.feedbackFormat( GL_INTERLEAVED_ATTRIBS )
			.feedbackVaryings( { "position", "pposition", "color", "damping", "texcoord", "invmass" } )
			.attribLocation( "iPosition", 0 )
			.attribLocation( "iColor", 1 )
			.attribLocation( "iPPosition", 2 )
			.attribLocation( "iDamping", 3 )
			.attribLocation( "iTexCoord", 4 )
			.attribLocation( "iInvMass", 5 )
		);
	}catch( ci::gl::GlslProgCompileExc &exc ) {
		std::cout << "Shader compile error: " << endl;
		std::cout << exc.what();
	}
	catch( Exception &exc ) {
		std::cout << "Unable to load shader" << endl;
		std::cout << exc.what();
	}
	
	// LOAD perlin texture to use in the shaders
	mPerlin3dTex = gl::Texture::create( loadImage( loadAsset( "shaders/perlin3d.png" ) ) );
	mPerlin3dTex->setWrap( GL_REPEAT, GL_REPEAT );
	
	// SET UP param defaults
	mCenter			= vec3( 0, 0, -10.0 );
	mStartVelocity	= 5.0;
	mStepMax		= 10.0;
	mDampingSpeed	= 0.003;
	mDampingBase	= 0.45f;
	mNoiseOffset	= vec3( 1.0f, 1.0f, 0.0 );
	mEndColor		= Color( 1.0, 1.0, 1.0 );
	
	// SET UP params
	mParams = params::InterfaceGl::create( app::getWindow(), "Params", vec2( 400, 350 ) );
	mParams->addParam( "Center", &mCenter ).updateFn( bind( &TextParticlesApp::setupVBO, this ) );
	mParams->addParam( "Start Velocity", &mStartVelocity ).updateFn( bind( &TextParticlesApp::setupVBO, this ) );
	mParams->addParam( "Step Max", &mStepMax );
	mParams->addParam( "Damping Speed", &mDampingSpeed ).precision( 4 ).step( 0.0005 ).min( 0.0 ).max( 0.04 );
	mParams->addParam( "Damping Base", &mDampingBase ).precision( 2 ).step( 0.05 ).min( 0.0 ).max( 1.0 );
	mParams->addParam( "Noise Offset", &mNoiseOffset );
	mParams->addParam( "EndColor", &mEndColor );
	mParams->addButton( "Enter Edit Mode", bind( &TextParticlesApp::editMode, this ) );
	mParams->addButton( "EXPLODE!", bind( &TextParticlesApp::setupVBO, this ) );
	
	mStep = 1.0;
	mActive = false;
}
예제 #12
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.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();
        
    }
}
예제 #13
0
void FiretrailApp::setup()
{
    mCamera.lookAt(vec3(.0f, .0f, -1.0f), vec3(.0f));
    
    mParams = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( ivec2( 200, 300 ) ) );
    mParams->addParam("FPS", &mFps);
    mParams->addParam("Max D Slice",  &mMaxDSlice);
    mParams->addParam("Time Factor",  &mTimeFactor);
    mParams->addParam("Gain",         &mGain      ).updateFn( [this] { mGlsl->uniform("gain", mGain);} );
    mParams->addParam("Lacunarity",   &mLacunarity).updateFn( [this] { mGlsl->uniform("lacunarity", mLacunarity);} );
    mParams->addParam("Magnitude",    &mMagnitude ).updateFn( [this] { mGlsl->uniform("magnitude", mMagnitude);} );
    mParams->addParam("Frag Mul",     &mFragMul   ).updateFn( [this] { mGlsl->uniform("fragMul", mFragMul);} );
    mParams->addParam("Noise Scale",  &mNoiseScale).updateFn( [this] { mGlsl->uniform("noiseScale", mNoiseScale);} );
    mParams->addParam("Layer Offset", &mLayerOffset).updateFn( [this] { mGlsl->uniform("layerOffset", mLayerOffset);} );
    
    mParams->addButton("Start Recording", [this]
    {
        if (!mRecordingMovie) startMovieRecording();
    });
    
    mParams->addButton("End Recording", [this]
    {
        if (mRecordingMovie) endMovieRecording();
    });
    
    gl::Texture::Format mTexFormat;
    mTexFormat.magFilter( GL_LINEAR ).minFilter( GL_LINEAR ).internalFormat( GL_RGBA );//.wrap(GL_REPEAT);
    mFireTex = gl::Texture::create( loadImage( loadAsset( "flame6.png" ) ), mTexFormat );
    
    mTexFormat.wrap(GL_REPEAT);
    mNoiseTex = gl::Texture::create( loadImage( loadAsset( "nzw.png" ) ), mTexFormat );
    
    mGlsl = gl::GlslProg::create(gl::GlslProg::Format()
                                 .vertex( loadAsset( "fire.vert" ) )
                                 .fragment( loadAsset( "fire.frag" ) )
                                 .geometry( loadAsset( "fire.geom" )).attrib( geom::CUSTOM_0, "vSize" ) );

    mGlsl->uniform("fireTex", 0);
    mGlsl->uniform("noiseTex", 1);
    mGlsl->uniform("fragMul", mFragMul);
    mGlsl->uniform("gain", mGain);
    mGlsl->uniform("magnitude", mMagnitude);
    mGlsl->uniform("lacunarity", mLacunarity);
    mGlsl->uniform("noiseScale", mNoiseScale);
    mGlsl->uniform("layerOffset", mLayerOffset);

    // compute texture coordinates
    vector<float> amp( NUM_SPLINE_NODES );
    amp.resize(NUM_SPLINE_NODES);
    
    for (size_t i = 0; i < NUM_SPLINE_NODES; ++i)
    {
        const auto t = (float)i / (float)(NUM_SPLINE_NODES - 1);
        amp[i] = 1.0f - easeInOutSine(t);
    }
    
    mVboMesh = gl::VboMesh::create( NUM_SPLINE_NODES, GL_POINTS, {
        gl::VboMesh::Layout().usage( GL_DYNAMIC_DRAW ).attrib( geom::POSITION, 3 ),
        gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::CUSTOM_0, 1 ),
    });
    
    mVboMesh->bufferAttrib(geom::Attrib::CUSTOM_0, amp);
    
    mBatch = gl::Batch::create(mVboMesh, mGlsl);
    
    resize();
}
예제 #14
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.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();
    }
}
예제 #15
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();
            });
        }
    }
}
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();
}
예제 #17
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", );
}