Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By the way, you should really make the ascension time dependent (framerate aware). All the answers here depend on the code being called at a specific interval; which it is not. If some process kicks in, Virtual Earth comes under stress somehow, if you minimize Virtual Earth, or if something that affects the performance of Virtual Earth happens the movement will be anything but smooth. Even if 'nothing' happens to Virtual Earth sometimes your 3D card will stall which means potentially you will get a jump every once in a while.</p> <p>In particular if the user has VSync turned off you will get some really nasty things cropping up:</p> <ul> <li>On slow machine the ascension will take forever (even with VSync on).</li> <li>On fast machines it will be so fast you might not even notice it.</li> </ul> <p>In your class:</p> <pre><code>private int lastTime; </code></pre> <p>In your loop/event:</p> <pre><code>if(lastTime == 0) { lastTime = Environment.TickCount; return; } int curTime = Environment.TickCount; // store this baby. int timeDiff = lastTime - curTime; if(timeDiff == 0) return; curAlt += (maxAlt - curAlt) * timeDiff / (150000); // TickCount reports // time in Ticks // (1000 ticks per second) lastTime = curTime; </code></pre> <p>If you want to get fancy you could plug the code from the DX SDK. Environment.TickCount has a resolution of 15ms (reason I check for the timeDiff being zero, because it could easily be). The managed DX SDK sample framework has a class called DxTimer (or sorts) that has a better resolution.</p> <p><a href="http://www.kalme.de/index.php?option=com_content&amp;task=view&amp;id=18&amp;Itemid=26&amp;limit=1&amp;limitstart=1" rel="nofollow noreferrer" title="Article">There is an article that uses the same API</a>.</p>
 

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