Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've already read, that you've data sampled at 200Hz, which you want to play back at natural speed. I.e. one second of sampled data shall be rendered over one second time.</p> <p>First: Forget about using timers to coordinate your rendering, this is unlikely to work properly. Instead you should measure the time a full rendering cycle (including v-sync) takes and advance the animation time-counter by this. Now 200Hz is already some very good time resolution, so if the data is smooth enough, then there should be no need to interpolate at all. So something like this (Pseudocode):</p> <pre><code>objects[] # the objects, animated by the animation animation[] # steps of the animation, sampled at 200Hz ANIMATION_RATE = 1./200. # Of course this shouldn't be hardcoded, # but loaded with the animation data animationStep = 0 timeLastFrame = None drawGL(): timeNow = now() # time in seconds with (at least) ms-accuracy if timeLastFrame: stepTime = timeNow - timeLastFrame else: stepTime = 0 animationStep = round(animationStep + stepTime * ANIMATION_RATE) drawObjects(objects, animation[animationStep]) timeLastFrame = timeNow </code></pre> <p>It may be, that your rendering is much faster than the time between screen refreshs. In that case you may want to render some of the intermediate steps, too, to get some kind of motion blur effect (you can also use the animation data to obtain motion vectors, which can be used in a shader to create a vector blur effect), the render loop would then look like this:</p> <pre><code>drawGL(): timeNow = now() # time in seconds with (at least) ms-accuracy if timeLastFrame: stepTime = timeNow - timeLastFrame else: stepTime = 0 timeRenderStart = now() animationStep = round(animationStep + stepTime * ANIMATION_RATE) drawObjects(objects, animation[animationStep]) glFinish() # don't call SwapBuffers timeRender = now() - timeRenderStart setup_GL_for_motion_blur() intermediates = floor(stepTime / timeRender) - 1 # subtract one to get some margin backstep = ANIMATION_RATE * (stepTime / intermediates) if intermediates &gt; 0: for i in 0 to intermediates: drawObjects(objects, animation[animationStep - i * backstep]) timeLastFrame = timeNow </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload