Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
animations [2019/03/12 12:18] adminanimations [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== Model-Animations ====== 
  
-If you load a model from 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. 
-By the animation manager you are allowed to browse through all available animations and to playback or stop those. 
- 
- 
-===== Post-loading of model-animations ===== 
- 
-In case you separated the model data from animations, you can load animations after loading the model. 
- 
-<file pascal Form1.pas> 
-  GorillaModel1.AddAnimationFromFile('Bellydancing.dae', GORILLA_ANIMATION_CACHING_DEFAULT); 
-</file> 
- 
-**This is only supported for DAE files!** 
- 
-===== Playing model-animations ===== 
- 
-==== Play/stop current model-animation ==== 
- 
-The "Current" property of the AnimationManager represents the currently active animation or if not set yet, it will 
-automatically select the first animation from the internal animation map. 
- 
-You can simply start and stop animations by the provided methods. 
- 
-<file pascal Form1.pas> 
-  GorillaModel1.AnimationManager.Current.Start(); 
-</file> 
- 
-<file pascal Form1.pas> 
-  GorillaModel1.AnimationManager.Current.Stop(); 
-</file> 
- 
-==== Iterating through model-animations ==== 
- 
-To iterate through the animations list and playback you can use the provided methods **PlayNextAnimation()** and **PlayPreviousAnimation()**. 
- 
-<file pascal Form1.pas> 
-procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; 
-  Shift: TShiftState); 
-begin 
-  if not Assigned(GorillaModel1) then 
-    Exit; 
- 
-  if (KeyChar = 'e') then 
-  begin 
-    // next animation if exists 
-    if (GorillaModel1.AnimationManager.Animations.Count > 0) then 
-    begin 
-      GorillaModel1.AnimationManager.PlayNextAnimation(); 
-    end; 
-  end 
-  else if (KeyChar = 'q') then 
-  begin 
-    // previous animation if exists 
-    if (GorillaModel1.AnimationManager.Animations.Count > 0) then 
-    begin 
-      GorillaModel1.AnimationManager.PlayPreviousAnimation(); 
-    end; 
-  end; 
-end; 
-</file> 
- 
-==== Playback by model-animation name ==== 
- 
-At the moment animation names are set by the order of adding. 
-So the first animation is called "Animation1", the second "Animation2" and so on. 
- 
-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) then 
-    LAnim := nil; 
-     
-  if Assigned(LAnim) then 
-    LAnim.Start(); 
-end; 
-</file> 
- 
-===== 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: "GORILLA_ANIMATION_CACHING_DEFAULT". 
- 
-Gorilla3D offers a configurable caching mechanism to suite your needs. 
- 
-List of animation caching flags: 
- 
-^ Flag ^ Notes ^ 
-| TAnimationCachingFlag.AllAttributes     | All attributes of each vertex are cached. This may be the fastest method, but memory usage is enormous! If possible use TAnimationCachingFlag.VertexPosition instead. |  
-| TAnimationCachingFlag.Compressed    | Compressed caching is recommend for large models and long animations, but will not create a framebuffer directly in GPU memory. | 
-| TAnimationCachingFlag.VertexPosition | Cached frames will be compressed inside the application memory. On MSWINDOWS x86 we use LZ4 compression for enourmous performance boost. On all other platforms we use ZLib compression algorithms by default. | 
- 
-Next step: [[materials|Materials]]