void cApp::setup(){ mExp.setup(1920, 1080, 0, 100-1, GL_RGB, mt::getRenderPath(), 0, "test" ); setWindowSize( 1920, 1080 ); setWindowPos(0, 0); mPln.setSeed( 345 ); mPln.setOctaves( 4 ); cam = CameraPersp(1920, 1080, 55, 0.1, 100000); eye = vec3(0,0,1000); cam.lookAt(eye, vec3(0,0,0)); camui.setCamera(&cam); }
void GeometryApp::mouseDown( MouseEvent event ) { mRecenterCamera = false; mCamUi.mouseDown( event ); if( getElapsedSeconds() - mLastMouseDownTime < 0.2f ) { mPrimitiveSelected = static_cast<Primitive>( static_cast<int>( mPrimitiveSelected ) + 1 ); createGeometry(); } mLastMouseDownTime = getElapsedSeconds(); }
void cApp::setup(){ setWindowPos( 0, 0 ); float w = 1920; float h = 1080; setWindowSize( w, h ); cam = CameraPersp(w, h, 55.0f, 1, 10000 ); cam.lookAt( vec3(0,0,1200), vec3(0,0,0) ); cam.setLensShift( 0,0 ); camUi.setCamera( &cam ); fftCheck(); // dftCheck(); }
void cApp::setup(){ setWindowPos( 0, 0 ); float w = 1920; float h = 1080*3; setWindowSize( w*0.2, h*0.2 ); mExp.setup( w, h, 0, 550-1, GL_RGB, mt::getRenderPath(), 0); cam = CameraPersp(w, h, 55.0f, 0.1, 1000000 ); if(0){ cam.lookAt( vec3(0,0,800), vec3(0,0,0) ); cam.setLensShift( 0,0 ); }else{ cam.setNearClip(0.100000); cam.setFarClip(1000000.000000); cam.setAspectRatio(0.592593); cam.setFov(55.000000); cam.setEyePoint(vec3(326.924622,-381.081604,259.431519)); cam.setWorldUp(vec3(0.000000,1.000000,0.000000)); cam.setLensShift(vec2(0.000000,0.000000)); cam.setViewDirection(vec3(-0.578462,0.674288,-0.459040)); cam.lookAt(vec3(326.924622,-381.081604,259.431519)+vec3(-0.578462,0.674288,-0.459040)); } camUi.setCamera( &cam ); mPln.setSeed(123); mPln.setOctaves(4); for( int i=0; i<6; i++){ Ramses r(eSimType,i); rms.push_back( r ); } makeGui(); #ifdef RENDER mExp.startRender(); #endif }
void cApp::setup(){ mPln.setSeed( 345 ); mPln.setOctaves( 4 ); openDir(); fs::path path = dir/("f_00000.png"); sur = Surface8u( loadImage( path) ); int w = sur.getWidth(); int h = sur.getHeight(); pcam = CameraPersp(w, h, 50, 1, 10000); camUi.setCamera( &pcam ); mExp.setup( w, h, 0, 3000-1, GL_RGB, mt::getRenderPath(), 0 ); setWindowSize( w*0.5, h*0.5 ); setWindowPos(0, 0); #ifdef RENDER mExp.startRender(); #endif }
void cApp::draw(){ glPointSize(1); glLineWidth(1); gl::enableAlphaBlending(); mExp.begin(camui.getCamera());{ gl::clear(); mt::drawCoordinate(100); vbo.draw(); } mExp.end(); mExp.draw(); gl::pushMatrices(); { gl::color(1, 1, 1); gl::drawString("fps " + to_string( getAverageFps()), vec2(20,20) ); gl::drawString("frame " + to_string( frame ), vec2(20,35) ); } gl::popMatrices(); }
void AudioVisualizerApp::mouseDrag( MouseEvent event ) { // handle mouse drag mCameraUi.mouseDrag( event.getPos(), event.isLeftDown(), event.isMiddleDown(), event.isRightDown() ); }
void AudioVisualizerApp::setup() { // initialize signals signalChannelEnd = false; // make a list of valid audio file extensions and initialize audio variables const char* extensions[] = { "mp3", "wav", "ogg" }; mAudioExtensions = vector<string>( extensions, extensions + 2 ); mAudioPath = getAssetPath( "" ); mIsAudioPlaying = false; // setup camera mCamera.setPerspective( 50.0f, 1.0f, 1.0f, 10000.0f ); mCamera.lookAt( vec3( -kWidth / 4, kHeight / 2, -kWidth / 8 ), vec3( kWidth / 4, -kHeight / 8, kWidth / 4 ) ); mCameraUi.setCamera( &mCamera ); // create channels from which we can construct our textures mChannelLeft = Channel32f( kBands, kHistory ); mChannelRight = Channel32f( kBands, kHistory ); memset( mChannelLeft.getData(), 0, mChannelLeft.getRowBytes() * kHistory ); memset( mChannelRight.getData(), 0, mChannelRight.getRowBytes() * kHistory ); // create texture format (wrap the y-axis, clamp the x-axis) mTextureFormat.setWrapS( GL_CLAMP_TO_BORDER ); mTextureFormat.setWrapT( GL_REPEAT ); mTextureFormat.setMinFilter( GL_LINEAR ); mTextureFormat.setMagFilter( GL_LINEAR ); mTextureFormat.loadTopDown( true ); // compile shader try { mShader = gl::GlslProg::create( loadAsset( "shaders/spectrum.vert" ), loadAsset( "shaders/spectrum.frag" ) ); } catch( const std::exception& e ) { console() << e.what() << std::endl; quit(); return; } // create static mesh (all animation is done in the vertex shader) std::vector<vec3> positions; std::vector<Colorf> colors; std::vector<vec2> coords; std::vector<uint32_t> indices; for( size_t h = 0; h < kHeight; ++h ) { for( size_t w = 0; w < kWidth; ++w ) { // add polygon indices if( h < kHeight - 1 && w < kWidth - 1 ) { size_t offset = positions.size(); indices.emplace_back( offset ); indices.emplace_back( offset + kWidth ); indices.emplace_back( offset + kWidth + 1 ); indices.emplace_back( offset ); indices.emplace_back( offset + kWidth + 1 ); indices.emplace_back( offset + 1 ); } // add vertex positions.emplace_back( vec3( float( w ), 0, float( h ) ) ); // add texture coordinates // note: we only want to draw the lower part of the frequency bands, // so we scale the coordinates a bit const float part = 0.5f; float s = w / float( kWidth - 1 ); float t = h / float( kHeight - 1 ); coords.emplace_back( vec2( part - part * s, t ) ); // add vertex colors colors.emplace_back( Color( CM_HSV, s, 0.5f, 0.75f ) ); } } gl::VboMesh::Layout layout; layout.usage( GL_STATIC_DRAW ); layout.attrib( geom::Attrib::POSITION, 3 ); layout.attrib( geom::Attrib::COLOR, 3 ); layout.attrib( geom::Attrib::TEX_COORD_0, 2 ); mMesh = gl::VboMesh::create( positions.size(), GL_TRIANGLES, { layout }, indices.size(), GL_UNSIGNED_INT ); mMesh->bufferAttrib( geom::POSITION, positions.size() * sizeof( vec3 ), positions.data() ); mMesh->bufferAttrib( geom::COLOR, colors.size() * sizeof( vec3 ), colors.data() ); mMesh->bufferAttrib( geom::TEX_COORD_0, coords.size() * sizeof( vec2 ), coords.data() ); mMesh->bufferIndices( indices.size() * sizeof( uint32_t ), indices.data() ); // play audio using the Cinder FMOD block FMOD::System_Create( &mFMODSystem ); mFMODSystem->init( 32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL ); mFMODSound = nullptr; mFMODChannel = nullptr; playAudio( findAudio( mAudioPath ) ); mIsMouseDown = false; mMouseUpDelay = 30.0; mMouseUpTime = getElapsedSeconds() - mMouseUpDelay; // the texture offset has two purposes: // 1) it tells us where to upload the next spectrum data // 2) we use it to offset the texture coordinates in the shader for the scrolling effect mOffset = 0; }
void Choreo3DApp::update() { setFrameRate(frameRate); //DISABLE CAMERA INTERACTION IF MOUSE IS OVER UI REGION if (getMousePos().x > 3 * getWindowWidth()/4. && camActive) { camActive = false; mCamUi.disconnect(); mCamUi.disable(); cout << "disabling camera UI" << endl; } else { if (!camActive) { mCamUi.connect(getWindow()); mCamUi.enable(); } camActive = true; cout << "enabling camera UI" << endl; } mGlsl->uniform("uColor", markerColour ); if (!paused) { //UPDATE POSITIONS //MAP INSTANCE DATA TO VBO //WRITE NEW POSITIONS //UNMAP glm::vec3 *newPositions = (glm::vec3*)mInstanceDataVbo->mapReplace(); for( int i = 0; i < jointList.size(); ++i ) { float instanceX = jointList[i].jointPositions[FRAME_COUNT].x; float instanceY = jointList[i].jointPositions[FRAME_COUNT].y; float instanceZ = jointList[i].jointPositions[FRAME_COUNT].z; vec3 newPos(vec3(instanceX,instanceY, instanceZ)); //CREATE A NEW VEC3 FOR UPDATING THE VBO framePositions[i] = newPos; } //REPLACE VEC3s IN VBO BY INCREMENTING THE POINTER for (int i = 0; i < framePositions.size(); i++){ *newPositions++ = framePositions[i]; } handTrail.update(framePositions[26], dancerColor); // std::cout << framePositions[17] << std::endl; skeleton.update(framePositions); mInstanceDataVbo->unmap(); // std::cout << "position: " << positions[0] << std::endl; if (ribbonsActive)updateRibbons(); //MANUALLY INCREMENT THE FRAME, IF THE FRAME_COUNT EXCEEDS TOTAL FRAMES, RESET THE COUNTER if (FRAME_COUNT < TOTAL_FRAMES) { FRAME_COUNT += 1; } else { FRAME_COUNT = 0; } //std::cout << getAverageFps() << std:: endl; // std::cout << "frame rate: " << getAverageFps() << ", frame count: " << FRAME_COUNT << std::endl; //define changed color // Color temp = Color(dancerColor[0],dancerColor[1],dancerColor[2]); mCurrentFrame++; //MANUALLY ADVANCE THE CURRENT FRAME - WITH RESPECT TO THE DANCERS } updateGui(); }
void TextParticlesApp::mouseWheel( MouseEvent event ) { mCamUi.mouseWheel( event ); }
void cApp::resize(){ CameraPersp & cam = const_cast<CameraPersp&>(camUi.getCamera()); cam.setAspectRatio( getWindowAspectRatio() ); camUi.setCamera( &cam ); }
void cApp::mouseDrag( MouseEvent event ){ camUi.mouseDrag( event.getPos(), event.isLeftDown(), event.isMiddleDown(), event.isRightDown() ); }
void cApp::mouseDown( MouseEvent event ){ camUi.mouseDown( event.getPos() ); }
void ViewportArrayApp::mouseUp( MouseEvent event ) { if( currentViewport != -1 ) mCameraUi.setCamera( &mCameras[currentViewport] ); mCameraUi.mouseUp( event ); }
void GeometryApp::mouseDrag( MouseEvent event ) { mCamUi.mouseDrag( event ); }
void TextParticlesApp::mouseUp( MouseEvent event ) { mCamUi.mouseUp( event ); }
void ArmyDemoApp::mouseDrag( MouseEvent event ) { mCamUi.mouseDrag( event.getPos(), event.isLeftDown(), event.isMiddleDown(), event.isRightDown() ); }
void ViewportArrayApp::mouseWheel( MouseEvent event ) { int viewport = getViewportAt( mViewports, event.getPos() ); if( viewport != -1 ) mCameraUi.setCamera( &mCameras[viewport] ); mCameraUi.mouseWheel( event ); }
void PointCloudApp::draw() { gl::viewport( getWindowSize() ); gl::clear(); gl::setMatrices( mCamUi.getCamera() ); gl::enableAlphaBlending(); gl::enableDepthRead(); gl::enableDepthWrite(); if ( mSurfaceColor ) { if ( mTextureColor ) { mTextureColor->update( *mSurfaceColor ); } else { mTextureColor = gl::Texture::create( *mSurfaceColor ); } mTextureColor->bind( 0 ); } if ( mChannelDepth ) { if ( mTextureDepth ) { gl::ScopedTextureBind scopeTextureBind( mTextureDepth->getTarget(), mTextureDepth->getId() ); glTexSubImage2D( mTextureDepth->getTarget(), 0, 0, 0, mTextureDepth->getWidth(), mTextureDepth->getHeight(), GL_RED_INTEGER, GL_UNSIGNED_SHORT, mChannelDepth->getData() ); } else { mTextureDepth = gl::Texture::create( mChannelDepth->getWidth(), mChannelDepth->getHeight(), gl::Texture::Format().dataType( GL_UNSIGNED_SHORT ).internalFormat( GL_R16UI ) ); } mTextureDepth->bind( 1 ); } if ( mSurfaceDepthToCameraTable && !mTextureDepthToCameraTable ) { mTextureDepthToCameraTable = gl::Texture::create( *mSurfaceDepthToCameraTable ); mTextureDepthToCameraTable->bind( 2 ); } if ( mSurfaceDepthToColorTable ) { if ( mTextureDepthToColorTable ) { mTextureDepthToColorTable->update( *mSurfaceDepthToColorTable ); } else { mTextureDepthToColorTable = gl::Texture::create( *mSurfaceDepthToColorTable, gl::Texture::Format().dataType( GL_FLOAT ) ); } mTextureDepthToColorTable->bind( 3 ); } gl::ScopedGlslProg scopeGlsl( mGlslProg ); gl::setDefaultShaderVars(); mGlslProg->uniform( "uTextureColor", 0 ); mGlslProg->uniform( "uTextureDepth", 1 ); mGlslProg->uniform( "uTextureDepthToCameraTable", 2 ); mGlslProg->uniform( "uTextureDepthToColorTable", 3 ); gl::draw( mVboMesh ); if ( mTextureColor ) { mTextureColor->unbind(); } if ( mTextureDepth ) { mTextureDepth->unbind(); } if ( mTextureDepthToCameraTable ) { mTextureDepthToCameraTable->unbind(); } if ( mTextureDepthToColorTable ) { mTextureDepthToColorTable->unbind(); } mParams->draw(); }
void PointCloudApp::mouseDrag( MouseEvent event ) { bool middle = event.isMiddleDown() || ( event.isMetaDown() && event.isLeftDown() ); bool right = event.isRightDown() || ( event.isControlDown() && event.isLeftDown() ); mCamUi.mouseDrag( event.getPos(), event.isLeftDown() && !middle && !right, middle, right ); }