/** * Do not call manually. * Callback from ContextListener. */ public void update(){ // Make sure the audio renderer is available to callables AudioContext.setAudioRenderer(audioRenderer); if (prof!=null) prof.appStep(AppStep.QueuedTasks); runQueuedTasks(); if (speed == 0 || paused) return; timer.update(); if (inputEnabled){ if (prof!=null) prof.appStep(AppStep.ProcessInput); inputManager.update(timer.getTimePerFrame()); } if (audioRenderer != null){ if (prof!=null) prof.appStep(AppStep.ProcessAudio); audioRenderer.update(timer.getTimePerFrame()); } // user code here.. }
/** * Sets the Timer implementation that will be used for calculating * frame times. By default, Application will use the Timer as returned * by the current JmeContext implementation. */ public void setTimer(Timer timer){ this.timer = timer; if (timer != null) { timer.reset(); } if (renderManager != null) { renderManager.setTimer(timer); } }
/** * Returns the time in seconds. The timer starts * at 0.0 seconds. * * @return the current time in seconds */ public float getTimeInSeconds() { return getTime() / (float) getResolution(); }
/** * Internal use only. Called by the RenderManager at the beginning of a * new application frame. */ public void newFrame() { // Avoid per-material Float allocations and lock in the // time for this frame to avoid inter-frame drift. time = timer.getTimeInSeconds(); tpf = timer.getTimePerFrame(); } }
@Override public void update(float tpf) { if (showFps) { secondCounter += app.getTimer().getTimePerFrame(); frameCounter ++; if (secondCounter >= 1.0f) { int fps = (int) (frameCounter / secondCounter); fpsText.setText("Frames per second: " + fps); secondCounter = 0.0f; frameCounter = 0; } } }
break; case Time: u.setValue(VarType.Float, timer.getTimeInSeconds()); break; case Tpf: u.setValue(VarType.Float, timer.getTimePerFrame()); break; case FrameRate: u.setValue(VarType.Float, timer.getFrameRate()); break;
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf);//To change body of generated methods, choose Tools | Templates. for (int i = 0; i < 3; i++){ PointLight pl = pls[i]; float angle = (float)Math.PI * (i + (timer.getTimeInSeconds() % 6)/3); // 3s for full loop pl.setPosition( new Vector3f(FastMath.cos(angle)*3f, 0, FastMath.sin(angle)*3f)); } } public void initialize(RenderManager rm, ViewPort vp) {
break; case FrameRate: u.setValue(VarType.Float, timer.getFrameRate()); break;
@Override public void update(){ super.update(); // do some animation float tpf = timer.getTimePerFrame(); stateManager.update(tpf); stateManager.render(renderManager); // render the viewports renderManager.render(tpf, context.isRenderable()); }
/** * Internal use only. Called by the RenderManager at the beginning of a * new application frame. */ public void newFrame() { // Avoid per-material Float allocations and lock in the // time for this frame to avoid inter-frame drift. time = timer.getTimeInSeconds(); tpf = timer.getTimePerFrame(); } }
if(timer.getTimeInSeconds()>=coreTime2){ coreTime2=timer.getTimeInSeconds()+10; if(difficulty<=lowCap){ difficulty=lowCap;
break; case FrameRate: u.setValue(VarType.Float, timer.getFrameRate()); break;
timer.update(); inputManager.update(timer.getTimePerFrame()); audioRenderer.update(timer.getTimePerFrame()); float tpf = timer.getTimePerFrame() * speed;
@Override public void update(){ super.update(); // do some animation float tpf = timer.getTimePerFrame(); boxGeom.rotate(tpf * 2, tpf * 4, tpf * 3); // dont forget to update the scenes boxGeom.updateLogicalState(tpf); boxGeom.updateGeometricState(); // render the viewports renderManager.render(tpf, context.isRenderable()); }
/** * Sets the {@link Timer} implementation that will be used for calculating * frame times.<br><br> * By default, Application will use the Timer as returned by the current {@link JmeContext} implementation. * @param timer the timer to use. */ public void setTimer(Timer timer){ this.timer = timer; if (timer != null) { timer.reset(); } if (renderManager != null) { renderManager.setTimer(timer); } }
public void sync(int fps) { long timeNow; long gapTo; long savedTimeLate; gapTo = timer.getResolution() / fps + timeThen; timeNow = timer.getTime(); savedTimeLate = timeLate; try { while (gapTo > timeNow + savedTimeLate) { Thread.sleep(1); timeNow = timer.getTime(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } if (gapTo < timeNow) { timeLate = timeNow - gapTo; } else { timeLate = 0; } timeThen = timeNow; }
if (timer.getTimeInSeconds() >= coreTime){ coreTime = timer.getTimeInSeconds() + 20;
private void applicationUpdate() { AudioContext.setAudioRenderer(audioRenderer); runQueuedTasks(); if (speed == 0 || paused) { return; } timer.update(); if (inputEnabled) { inputManager.update(timer.getTimePerFrame()); } if (audioRenderer != null) { audioRenderer.update(timer.getTimePerFrame()); } }