void BouncingBalls3dApp::setup() { for (int i = 0; i < NUM_BALLS; i++) { mBalls.push_back( BouncingBall::create( randVec3() * 3.f) ); } mBox = AxisAlignedBox( vec3(-25), vec3(25) ); mCamera.setPerspective(60, getWindowAspectRatio(), .1, 10000); mCamera.lookAt(vec3(0,0,30), vec3(0)); mUI.connect(getWindow()); mUI.setCamera(&mCamera); gl::enableDepthRead(); gl::enableDepthWrite(); }
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(); }