Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
animations [2019/03/08 12:03] – admin | animations [2019/09/09 09:25] – [Model-Animation caching] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Animations ====== | + | ====== |
- | If you load a model from DAE or X3D with embedded animations, Gorilla3D will automatically load and add all animations to the model. | + | If you load a model from G3D, DAE or X3D with embedded animations, Gorilla3D will automatically load and add all animations to the model. |
Animations are handled by the TGorillaAnimationManager inside of a TGorillaModel component. | Animations are handled by the TGorillaAnimationManager inside of a TGorillaModel component. | ||
Line 7: | Line 7: | ||
- | ===== Post-Loading | + | ===== Post-loading |
In case you separated the model data from animations, you can load animations after loading the model. | In case you separated the model data from animations, you can load animations after loading the model. | ||
Line 17: | Line 17: | ||
**This is only supported for DAE files!** | **This is only supported for DAE files!** | ||
- | ===== Playing | + | ===== Playing |
- | ==== Play/Stop current animation ==== | + | ==== Play/stop current |
The " | The " | ||
Line 34: | Line 34: | ||
</ | </ | ||
- | ==== Iterating | + | ==== Iterating |
- | To iterate | + | To iterate the animation |
<file pascal Form1.pas> | <file pascal Form1.pas> | ||
Line 64: | Line 64: | ||
</ | </ | ||
+ | ==== Playback by model-animation name ==== | ||
+ | |||
+ | At the moment animation names are set by the order of adding. | ||
+ | So the first animation is called " | ||
+ | |||
+ | You are allowed to browse an animation by its name, by using the provided hashmap component inside of the AnimationManager. | ||
+ | |||
+ | <file pascal Form1.pas> | ||
+ | procedure TForm1.Playback(const AName : String); | ||
+ | var LAnim : TGorillaAnimation | ||
+ | begin | ||
+ | if not GorillaModel1.AnimationManager.Animations.TryGetValue(AName, | ||
+ | LAnim := nil; | ||
+ | | ||
+ | if Assigned(LAnim) then | ||
+ | LAnim.Start(); | ||
+ | end; | ||
+ | </ | ||
+ | |||
+ | ===== Model-Animation caching ===== | ||
+ | |||
+ | To animate models with a large number of vertices is very slow. Using the same animated model multiple times is also extremely slow. | ||
+ | Due to those performance needs, Gorilla3D offers some caching techniques for model animations. | ||
+ | |||
+ | As you've seen in the previous examples for loading a model, there was a supplied parameter for animation caching: " | ||
+ | |||
+ | Gorilla3D offers a configurable caching mechanism to suite your needs. | ||
+ | |||
+ | List of animation caching flags: | ||
+ | |||
+ | ^ Flag ^ Notes ^ | ||
+ | | TAnimationCachingFlag.AllAttributes | ||
+ | | TAnimationCachingFlag.Compressed | ||
+ | | TAnimationCachingFlag.VertexPosition | Cached frames will ONLY contain the vertex position. The rest of the vertex data will come from a static mesh buffer (not animatable). This is the recommend setting for caching, because in 95% of all cases you only transform vertex position on an animation skin. | | ||
+ | |||
+ | The constant value " | ||
+ | < | ||
+ | GORILLA_ANIMATION_CACHING_DEFAULT : TAnimationCachingFlags = [VertexPosition]; | ||
+ | </ | ||
+ | |||
+ | === Hint === | ||
+ | It is possible to combine compressed and vertex-position caching flags to reduce the number of data compressed. Otherwise on compressed caching, full vertex data will be cached. | ||
+ | |||
+ | < | ||
+ | GORILLA_ANIMATION_CACHING_COMPRESSEDEX = TAnimationCachingFlags = [TAnimationCachingFlag.Compressed, | ||
+ | </ | ||
+ | |||
+ | === Framerate === | ||
+ | |||
+ | The caching framerate used is currently fixed to 60 FPS. | ||
+ | But in future you should be allowed to configure this setting to reduce memory usage. | ||
+ | |||
+ | Next step: [[materials|Materials]] |