void StarsApp::update() { double elapsed = getElapsedSeconds() - mTime; mTime += elapsed; // animate camera mCamera.update(elapsed); // update background and user interface mBackground.setCameraDistance( mCamera.getCamera().getEyePoint().length() ); mUserInterface.setCameraDistance( mCamera.getCamera().getEyePoint().length() ); }
void StarsApp::update() { double elapsed = getElapsedSeconds() - mTime; mTime += elapsed; double time = getElapsedSeconds() / 200.0; if(mSoundEngine && mMusic && mPlayMusic) time = mMusic->getPlayPosition() / (double) mMusic->getPlayLength(); // animate camera mCamera.setDistanceTime(time); mCamera.update(elapsed); // adjust content based on camera distance float distance = mCamera.getCamera().getEyePoint().length(); mBackground.setCameraDistance( distance ); mLabels.setCameraDistance( distance ); mConstellations.setCameraDistance( distance ); mConstellationLabels.setCameraDistance( distance ); mUserInterface.setCameraDistance( distance ); // if(mSoundEngine) { // send camera position to sound engine (for 3D sounds) Vec3f pos = mCamera.getPosition(); mSoundEngine->setListenerPosition( vec3df(pos.x, pos.y, pos.z), vec3df(-pos.x, -pos.y, -pos.z), vec3df(0,0,0), vec3df(0,1,0) ); // if music has finished, play next track if( mPlayMusic && mMusic && mMusic->isFinished() ) { playMusic( getNextFile(mMusicPath) ); } } }