void GeometryPlotterApp::resize () { // Adjust the camera CameraPersp cam = m_mayaCam.getCamera (); cam.setAspectRatio (getWindowAspectRatio ()); m_mayaCam.setCurrentCam (cam); m_gui.resize ((float)getWindowWidth (), (float)getWindowHeight ()); }
void GeometryPlotterApp::setup() { CameraPersp cam; cam.setEyePoint (Vec3f (5.0f, 10.0f, 10.0f)); cam.setCenterOfInterestPoint (Vec3f (0.0f, 2.5f, 0.0f)); cam.setPerspective (60.0f, getWindowAspectRatio (), 0.01f, 1000.0f); m_mayaCam.setCurrentCam (cam); buildGUI (); }
//-------------------------------------------------------------- void FingerTracker::addToFluid( Vec2f pos, Vec2f vel, bool addColor, bool addForce ) { float speed = vel.x * vel.x + vel.y * vel.y * getWindowAspectRatio() * getWindowAspectRatio(); if(speed > 0) { pos.x = constrain(pos.x, 0.0f, 1.0f); pos.y = constrain(pos.y, 0.0f, 1.0f); const float colorMult = 100; const float velocityMult = 30; int index = fluidSolver.getIndexForPos(pos); if(addColor) { Color drawColor( CM_HSV, ( getElapsedFrames() % 360 ) / 360.0f, 1, 1 ); fluidSolver.addColorAtIndex(index, drawColor * colorMult); if(drawParticles) { particleSystem.addParticlesWithVelc( pos*Vec2f(getWindowSize()), vel*Vec2f(getWindowSize()), 2 ); } } if(addForce) fluidSolver.addForceAtIndex(index, vel * velocityMult); } }
void ParamApp::setup() { gl::enableDepthRead(); gl::enableAlphaBlending(); param = cinder::params::InterfaceGl("Param Test", Vec2i(300, 200)); param.addParam("Camera", &camera_rotate); param.addParam("Rotate", &rotate); camera.setPerspective(60.0f, getWindowAspectRatio(), 5.0f, 2000.0f); camera.lookAt(Vec3f(0, 0, 300), Vec3f::zero(), Vec3f::yAxis()); }
void msaFluidParticlesApp::update() { if( resizeFluid ) { fluidSolver.setSize(fluidCellsX, fluidCellsX / getWindowAspectRatio() ); fluidDrawer.setup(&fluidSolver); resizeFluid = false; } fluidSolver.update(); renderSceneToFbo(); }
void HodginDidItApp::setupCiCamera() { PXCPointF32 cFOV; mPXC.QueryCapture()->QueryDevice()->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH,&cFOV); mFOV.x = math<float>::atan(mDepthW/(cFOV.x*2))*2; mFOV.y = math<float>::atan(mDepthH/(cFOV.y*2))*2; mNIFactors.x = math<float>::tan(mFOV.x/2.0f)*2.0f; mNIFactors.y = math<float>::tan(mFOV.y/2.0f)*2.0f; float cVFov = (float)toDegrees(mFOV.y); float cAspect = getWindowAspectRatio(); mCamera.setPerspective(cVFov,cAspect,0.1f,100.0f); mCamera.lookAt(Vec3f(0,0,0), Vec3f::zAxis(), Vec3f::yAxis()); }
void msaFluidParticlesApp::draw() { gl::clear( Color( 1.0f, 1.0f, 1.0f ) ); CameraPersp cam( getWindowWidth(), getWindowHeight(), 60.0f ); cam.setPerspective( 60, getWindowAspectRatio(), 1, 1500 ); cam.lookAt( Vec3f( 2.6f, 1.6f, -2.6f ), Vec3f::zero() ); gl::setMatrices( cam ); gl::rotate( mArcball.getQuat() ); // set the viewport to match our window gl::setViewport( getWindowBounds() ); gl::enableDepthRead(); gl::enableDepthWrite(); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK); //mFbo.bindTexture(); gl::Texture txFluid = mFbo.getTexture(0); mShader->bind(); txFluid.enableAndBind(); mShader->uniform( "displacementMap", 0 ); mShader->uniform( "colorMap", 0 ); gl::drawSphere(Vec3f::zero(), 1.0, 254); txFluid.unbind(); mShader->unbind(); //mFbo.unbindTexture(); gl::disable(GL_CULL_FACE); gl::disableDepthRead(); gl::disableDepthWrite(); gl::setMatricesWindow( getWindowSize()); if(drawFluidTex){ glEnable( GL_TEXTURE_2D ); txFluid.setFlipped(true); gl::draw( txFluid, Rectf( 0, 0, 256, 256)); glDisable(GL_TEXTURE_2D); } }
void DOFFilter::drawFullscreen() { mGlslProg->uniform("uRenderedTexture", 0); mGlslProg->uniform("uDepthTexture", 1); mGlslProg->uniform("uFocalDepth", mManualFocalDepth); mGlslProg->uniform("uMaxBlur", mMaxBlur * displayScale()); #ifdef ADVANCED_SHADER mGlslProg->uniform("uRenderedTextureWidth", (float)mSceneFBO->getWidth()); mGlslProg->uniform("uRenderedTextureHeight", (float)mSceneFBO->getHeight()); mGlslProg->uniform("uUseAutofocus", mUseAutofocus); mGlslProg->uniform("uAutofocusCenter", mAutofocusCenter); mGlslProg->uniform("uNumRings", mNumRings); mGlslProg->uniform("uNumSamples", mNumSamples); mGlslProg->uniform("uHighlightThreshold", mHighlightThreshold); mGlslProg->uniform("uHighlightGain", mHighlightGain); mGlslProg->uniform("uBokehEdgeBias", mBokehEdgeBias); mGlslProg->uniform("uBokehFringe", mBokehFringe); mGlslProg->uniform("uAperture", mAperture / displayScale()); #else mGlslProg->uniform("uAspectRatio", getWindowAspectRatio()); mGlslProg->uniform("uAperture", mAperture / displayScale() / 15); #endif gl::ScopedTextureBind tex0(mSceneFBO->getColorTexture(), 0); gl::ScopedTextureBind tex1(mSceneFBO->getDepthTexture(), 1); const gl::ScopedViewport scopedViewport(ivec2(0), toPixels(getWindowSize())); const gl::ScopedMatrices scopedMatrices; gl::setMatricesWindow(toPixels(getWindowSize())); gl::translate(toPixels(getWindowSize() / 2)); gl::scale(toPixels(getWindowSize())); gl::disableDepthRead(); gl::disableDepthWrite(); gl::clear(Color::black()); mQuadBatch->draw(); }
void Skinning::draw() { gl::clear( Color( 1.0f, 1.0f, 1.0f ) ); mCam.lookAt( gConfigScene.eye, Vec3f::zero() ); mCam.setPerspective( 60, getWindowAspectRatio(), 0.01, 500 ); gl::setMatrices( mCam ); glEnable(GL_LIGHT0); GLfloat pos[] = {0.0, 2.0, 15.0, 1.0}; GLfloat diff[] = {1.0, 1.0, 1.0, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_DIFFUSE, diff); mShaderPhong.bind(); mShaderPhong.uniform("shininess",128.0f); mShaderPhong.uniform("tex",0); drawGeometry(); mShaderPhong.unbind(); glDisable(GL_LIGHT0); if (mDrawNormals) drawNormals(); // Params if (mShowParams){ params::InterfaceGl::draw(); } }
/* setupScene() impelmented by user as if it where a normal application*/ void SystemCinderApp::setupScene() { /* Following scene was created from Cinder's sample application CubeMappingApp */ mCamFbo.setFov(45.0f); mCamFbo.setAspectRatio(getWindowAspectRatio()); mCamFboUi = CameraUi(&mCamFbo, getWindow()); mCubeMap = gl::TextureCubeMap::create(loadImage(loadAsset("env_map.jpg")), gl::TextureCubeMap::Format().mipmap()); #if defined (CINDER_GL_ES) auto envMapGlsl = gl::GlslProg::create(loadAsset("env_map_es2.vert"), loadAsset("env_map_es2.frag")); auto skyBoxGlsl = gl::GlslProg::create(loadAsset("sky_box_es2.vert"), load Asset("sky_box_es2.frag")); #else auto envMapGlsl = gl::GlslProg::create(loadAsset("env_map.vert"), loadAsset("env_map.frag")); auto skyBoxGlsl = gl::GlslProg::create(loadAsset("sky_box.vert"), loadAsset("sky_box.frag")); #endif mTeapotBatch = gl::Batch::create(geom::Teapot().subdivisions(7), envMapGlsl); //send uniform to a shader mTeapotBatch->getGlslProg()->uniform("uCubeMapTex", 0); mSkyBoxBatch = gl::Batch::create(geom::Cube(), skyBoxGlsl); mSkyBoxBatch->getGlslProg()->uniform("uCubeMapTex", 0); }
void Wormhole3ContinuousOutputs::setup() { setupParams(); mReceived = vec3(1); mCamera.setPerspective(60.0f, getWindowAspectRatio(), 0.1f, 10.f); mCamera.lookAt(vec3(0, kEyeDepth, 0), vec3(), vec3(0, 1, 0)); mShader = gl::GlslProg::create(loadAsset("shaders/wormhole.vert"), loadAsset("shaders/wormhole.frag")); auto mesh = gl::VboMesh::create(geom::Torus().center(vec3()).radius(0.5f, 0.49f).subdivisionsAxis(64).subdivisionsHeight(4)); geom::BufferLayout attribs; attribs.append(geom::CUSTOM_0, 4, sizeof(Ring), offsetof(Ring, Tint), 1); attribs.append(geom::CUSTOM_1, 3, sizeof(Ring), offsetof(Ring, Position), 1); attribs.append(geom::CUSTOM_2, 2, sizeof(Ring), offsetof(Ring, Size), 1); mRings.push_back(Ring(Color(1, 0, 0), vec2(mReceived.x, mReceived.y))); mData = gl::Vbo::create(GL_ARRAY_BUFFER, mRings, GL_DYNAMIC_DRAW); mesh->appendVbo(attribs, mData); mDraw = gl::Batch::create(mesh, mShader, { {geom::CUSTOM_0, "i_Tint"},{ geom::CUSTOM_1, "i_Position" },{ geom::CUSTOM_2, "i_Size" } }); setupListener(); }
void NanoApp::resize() { camera.setPerspective (60.0f, getWindowAspectRatio(), 0.1f, 1000.0f); cameraUI.setCamera (&camera); gui->resize (getWindowSize()); }
void SplatTestApp::resize() { camera.setAspectRatio(getWindowAspectRatio()); }
void Genetic_AlgorithmApp::setup() { m_appPath = getArgs()[0]; m_appPath = m_appPath.parent_path(); /* App */ m_renderCurrentImage = false; /* === */ /* Algo Gen */ m_pixelPerSticky = 15; m_numberGapPixel = 0; m_isStarted = false; m_isPaused = false; /* === */ /* Image Load*/ m_currentImageLoadedIndex = 0; /* === */ /* Camera capture */ setupCapture(); m_hasCaptureCamera = false; m_realTime = false; /* === */ /* IHM */ m_ihmParam = cinder::params::InterfaceGl::create("Sticky", cinder::Vec2i(245, 340)); m_ihmParam->setPosition(cinder::Vec2i(20, 20)); m_camParam = cinder::params::InterfaceGl::create("Camera", cinder::Vec2i(250, 150)); m_camParam->setPosition(cinder::Vec2i(getWindowWidth() - 300, 20)); m_ihmShader = cinder::params::InterfaceGl::create("Shader", cinder::Vec2i(150, 50)); m_ihmShader->setPosition(cinder::Vec2i(getWindowWidth() - 200, 190)); m_ihmStats = cinder::params::InterfaceGl::create("Stats", cinder::Vec2i(200, 100)); m_ihmStats->setPosition(cinder::Vec2i(getWindowWidth() - 200, 260)); m_ihmStats->hide(); setupIHM(); /* === */ /* THREAD */ m_threadRunning = false; m_computeFPS = 0.0; m_computeHeightFPS = 0.0; m_numberOfPopulation = 100; /* Camera */ m_camera.setup(60.0f, getWindowAspectRatio(), 5.0f, 300000.0f, 500.f); /* shader */ m_neighbors = 1; try { m_shader = gl::GlslProg::create(loadResource(SHADER_VERT), loadResource(SHADER_FRAG)); } catch (gl::GlslProgCompileExc& e) { console() << e.what() << std::endl; quit(); } catch (...) { console() << "Shader error" << std::endl; quit(); } m_isBuilder = false; //console() << m_shader->getShaderLog(m_shader->getHandle()) << std::endl; }