共用方式為


Animation

Note:  this entry references code for an older version of VE3D.  The newest code samples are here.

Smoothly animated objects make for a more compelling 3D world, and in this entry we'll learn about using them.  In the X File entry, the model that we loaded could be rotated around a point.  This is pretty easy, but is limited.  You can move the model around, rotate it, make it bigger or smaller, but can't change its basic shape and appearance.  For complex animations like that, you may need to change the actual vertices or indices used to draw the model.  To support that, we have the concept of dynamic buffers.  These are buffers that are expected to be frequently recalculated, and are internally handled to make that more efficient.  The attached sample shows how to use this in SurfaceActor, but it's pretty much the same as using static buffers.  The only difference is that we Set the values in the buffer in every call to Update rather than just Add them once.

Get The Code.

Video: Bezier Surface in Virtual Earth 3D

When the code is normally running it does not draw a new frame as frequently as it could.  This is to conserve CPU and other resources on the client machine when nothing is really happening.  But when animating, this presents a problem because the aniamtion can look stuttery and inconsistent.  The solution is to tell the system it needs to draw more frequently by calling

Host.NeedUpdate();

This can be called as many times per frame as you like, and simply sets a flag telling the system to render the next frame as soon as possible.  It's a good idea to only call this when you have an animation actively running.  In this case, it is called only when a ControlPoint is actually changing.

This sample also has some code demonstrating more usage of bindings to control user input in a custom fashion, similar to the Geometry sample but a little more complex.

Comments

  • Anonymous
    July 08, 2008
    PingBack from http://blog.a-foton.ru/2008/07/animation/

  • Anonymous
    November 10, 2008
    This sample was released before , but didn't have a version that could run on the web without an install.