void RDiffusionApp::setup() { mReactionU = 0.25f; mReactionV = 0.04f; mReactionK = 0.047f; mReactionF = 0.1f; mMousePressed = false; // Setup the parameters mParams = params::InterfaceGl::create( "Parameters", ivec2( 175, 100 ) ); mParams->addParam( "Reaction u", &mReactionU, "min=0.0 max=0.4 step=0.01 keyIncr=u keyDecr=U" ); mParams->addParam( "Reaction v", &mReactionV, "min=0.0 max=0.4 step=0.01 keyIncr=v keyDecr=V" ); mParams->addParam( "Reaction k", &mReactionK, "min=0.0 max=1.0 step=0.001 keyIncr=k keyDecr=K" ); mParams->addParam( "Reaction f", &mReactionF, "min=0.0 max=1.0 step=0.001 keyIncr=f keyDecr=F" ); mCurrentFBO = 0; mOtherFBO = 1; mFBOs[0] = gl::Fbo::create( FBO_WIDTH, FBO_HEIGHT, gl::Fbo::Format().colorTexture().disableDepth() ); mFBOs[1] = gl::Fbo::create( FBO_WIDTH, FBO_HEIGHT, gl::Fbo::Format().colorTexture().disableDepth() ); mRDShader = gl::GlslProg::create( loadResource( RES_PASS_THRU_VERT ), loadResource( RES_GSRD_FRAG ) ); mTexture = gl::Texture::create( loadImage( loadResource( RES_STARTER_IMAGE ) ), gl::Texture::Format().wrap(GL_REPEAT).magFilter(GL_LINEAR).minFilter(GL_LINEAR) ); gl::getStockShader( gl::ShaderDef().texture() )->bind(); resetFBOs(); }
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 ); }
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))); }
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 }
void AudioObjApp::initGui() { mParams = params::InterfaceGl::create( "Settings", Vec2f( 200, 250 ) ); mParams->addParam( "Obj color", &mObjColor ); mParams->addParam( "Wireframe", &mRenderWireframe ); mParams->addParam( "Data Gain", &mFeatureGain, "min=0.0 max=25.0 step=0.1" ); mParams->addParam( "Data Offset", &mFeatureOffset, "min=-1.0 max=1.0 step=0.01" ); mParams->addParam( "Data Damping", &mFeatureDamping, "min=0.0 max=0.99 step=0.01" ); mParams->addParam( "Spread", &mFeatureSpread, "min=0.0 max=1.0 step=0.01" ); mParams->addParam( "Spread Offset", &mFeatureSpreadOffset, "min=0.0 max=1.0 step=0.01" ); }
void BasicReceiverApp::initGui() { mParams = params::InterfaceGl::create( "Settings", Vec2f( 220, 200 ) ); mParams->addParam( "Data Gain", &mDataGain, "min=0.0 max=100.0 step=0.1" ); mParams->addParam( "Data Offset", &mDataOffset, "min=-1.0 max=1.0 step=0.01" ); mParams->addParam( "Data Damping", &mDataDamping, "min=0.0 max=0.99 step=0.01" ); mParams->addParam( "Use log", &mDataIsLog ); mParams->addParam( "Spread", &mDataSpread, "min=0.0 max=1.0 step=0.01" ); mParams->addParam( "Spread Offset", &mDataSpreadOffset, "min=0.0 max=1.0 step=0.01" ); mParams->addParam( "Feature", mAvailableFeatures, &mActiveFeature ); }
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 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(); }
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() ); }
void TessellationShaderApp::setup() { mTessLevelInner = mTessLevelOuter = 4; int maxPatchVertices = 0; glGetIntegerv( GL_MAX_PATCH_VERTICES, &maxPatchVertices ); app::console() << "Max supported patch vertices " << maxPatchVertices << std::endl; #if ! defined( CINDER_GL_ES ) fs::path glDir = "ogl"; mRadius = 200.0f; mParams = params::InterfaceGl::create( "Settings", ivec2( 200, 200 ) ); mParams->addParam( "Radius", &mRadius, "step=1.0" ); mParams->addParam( "Tess level inner", &mTessLevelInner, "min=0" ); mParams->addParam( "Tess level outer", &mTessLevelOuter, "min=0" ); #else fs::path glDir = "es31a"; mRadius = 400.0f; #endif try { mGlsl = gl::GlslProg::create( gl::GlslProg::Format() .vertex( loadAsset( glDir / "0_vert.glsl" ) ) .tessellationCtrl( loadAsset( glDir / "1_tess_ctrl.glsl" ) ) .tessellationEval( loadAsset( glDir / "2_tess_eval.glsl" ) ) #if defined( CINDER_GL_ES ) .geometry( loadAsset( glDir / "x_geom.glsl" ) ) #endif .fragment( loadAsset( glDir / "3_frag.glsl" ) ) ); } catch( const std::exception &ex ) { console() << ex.what() << endl; //quit(); } mBatch = gl::VertBatch::create( GL_PATCHES ); mBatch->color( 1.0f, 0.0f, 0.0f ); mBatch->vertex( vec2( 1, -1 ) ); mBatch->color( 0.0f, 1.0f, 0.0f ); mBatch->vertex( vec2( 0 , 1 ) ); mBatch->color( 0.0f, 0.0f, 1.0f ); mBatch->vertex( vec2( -1, -1 ) ); gl::patchParameteri( GL_PATCH_VERTICES, 3 ); }
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 }
void SlingshotSmokeApp::setup() { mVolumeMult = 5.0; mLastTime = 0; getWindowIndex(0)->getSignalDraw().connect([=]() { drawRender(); }); mAudioSource = AudioSource(); mAudioSource.setup(); vec2 fluidResolution = vec2(512); vec2 smokeResolution = app::getWindowSize(); mFluid = Fluid(fluidResolution); mSmokers.reserve(2); mSmokers.push_back(shared_ptr<FakeSmoker>(new FakeSmoker(fluidResolution, smokeResolution))); mSmokers.push_back(shared_ptr<PositionSmoker>(new PositionSmoker(fluidResolution, smokeResolution))); mSmokers.push_back(shared_ptr<TransitionSmoker>(new TransitionSmoker(fluidResolution, smokeResolution))); mSmokers.push_back(shared_ptr<BottomSmoker>(new BottomSmoker(fluidResolution, smokeResolution))); mCurrentSmoker = 0; mSmokers[mCurrentSmoker]->light(vec2(0.5, 0.2), mParams); gl::GlslProg::Format renderFormat; renderFormat.vertex(app::loadAsset("passthru.vert")); renderFormat.fragment(app::loadAsset("Smokers/smoke_draw.frag")); mRenderProg = gl::GlslProg::create(renderFormat); mRenderProg->uniform("i_resolution", smokeResolution); gl::Texture2d::Format texFmt; texFmt.setInternalFormat(GL_RGBA32F); texFmt.setDataType(GL_FLOAT); texFmt.setTarget(GL_TEXTURE_2D); texFmt.setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); gl::Fbo::Format fmt; fmt.disableDepth() .setColorTextureFormat(texFmt); mSmokeField = PingPongFBO(fmt, smokeResolution, 4); // Do params last so that all the FBOs are in the right context vec2 paramsSize = vec2(255, 512); auto format = Window::Format(); format.setSize(paramsSize + vec2(40, 20)); format.setPos(ivec2(100)); WindowRef paramsWindow = createWindow(format); paramsWindow->getSignalDraw().connect([=]() { drawParams(); }); mParams = params::InterfaceGl::create(paramsWindow, "Options", paramsSize); mParams->addParam("Volume", &mVolumeMult) .max(10.0) .min(0.0) .step(0.1); }
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 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(); }
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 ); }
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(); }
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 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(); } } ); }
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 ); }
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 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(); }
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() ); }
void MotionTrackingTestApp::setup(){ mDeviceManager = OpenNI::DeviceManager::create(); shapeUID = 0; mTrackedShapes.clear(); if( mDeviceManager->isInitialized() ){ try{ mDevice = mDeviceManager->createDevice( OpenNI::DeviceOptions().enableColor() ); } catch( OpenNI::ExcDeviceNotAvailable ex) { console() << ex.what() << endl; quit(); return; } if( mDevice ){ mDevice->connectDepthEventHandler( &MotionTrackingTestApp::onDepth, this ); mDevice->connectColorEventHandler( &MotionTrackingTestApp::onColor, this ); // mBackground = cv::Mat( 240,320, CV_16UC1 ); // mPreviousFrame = cv::Mat( 240,320, CV_16UC1 ); mDevice->start(); } } mThresh = 0.0; mMaxVal = 255.0; mNearLimit = 30; mFarLimit = 4000; mParams = params::InterfaceGl::create("Threshold", Vec2i( 255, 200 ) ); mParams->addParam("Thresh", &mThresh, "min=0.0f max=255.0f step=1.0 keyIncr=a keyDecr=s"); mParams->addParam("Maxval", &mMaxVal, "min=0.0f max=255.0f step=1.0 keyIncr=q keyDecr=w"); //mParams->addParam( "Black near", &mNearLimit, "min=10 max=100 step=1 keyIncr=t keyDecr=y" ); // mParams->addParam( "Black far", &mFarLimit, "min=200 max=1000 step=1 keyIncr=g keyDecr=h" ); mStepSize = 10; mBlurAmount = 10; }
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 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(); } }
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(); } }
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 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 }
// assumes that prevPv and curPv are not equal void GeoDeVisualizerApp::changeParameterWindow() { switch (mPrevParams.displayMode) { case Geography: break; case Colonies: { mParams->removeParam("colony"); mParams->removeParam("information"); break; } case Attributes: { mParams->removeParam("attributes"); const vector<string>& names = mWorld.attributeNames(); for (vector<string>::const_iterator nameRef = names.begin(); nameRef != names.end(); ++nameRef) { mParams->removeParam(*nameRef); } break; } case Resources: { mParams->removeParam("resources"); const vector<string>& names = mWorld.resourceNames(); for (vector<string>::const_iterator nameRef = names.begin(); nameRef != names.end(); ++nameRef) { mParams->removeParam(*nameRef); } break; } } switch (mCurParams.displayMode) { case Geography: break; case Colonies: { mParams->addParam("colony", mColonyDisplay, &mCurParams.displayColony); Colony& colRef = mWorld.mColonies[mCurParams.displayColony]; colRef.updateInfo(); mParams->addParam("information",&colRef.getInfo()); break; } case Attributes: { mParams->addText("attributes"); const vector<string>& names = mWorld.attributeNames(); string attrKey = "1"; for (u32 i = 0; i < names.size(); i++) { mParams->addParam(names[i], &(mCurParams.showAttributes[i]), "keyIncr="+attrKey); attrKey[0]++; } break; } case Resources: { mParams->addText("resources"); const vector<string>& names = mWorld.resourceNames(); string resKey = "a"; for (u32 i = 0; i < names.size(); i++) { mParams->addParam(names[i], &(mCurParams.showResources[i]), "keyIncr="+resKey); resKey[0]++; } break; } } }
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(); }