Page 1 of 1

Animation

Posted: Sat Feb 19, 2011 8:01 pm
by Kjell
:idea:

A attempt at putting together a animation road-map for ZGE. First off, a quick overview of the most prominent concepts.

---

F-Curve ( Function Curve )
A F-Curve is a 1D curve generated from a number of control points. Each point is indexed by its frame ( time-stamp ) and holds a value + 2 tangents.

Image
Visual representation of a F-Curve

Tree
A hierarchical tree ( parent-child relation ) provides a framework to simplify animating individual entities that influence each other.

Image
Visual representation of a hierarchical tree

FK ( Forward Kinematics )
FK is the default hierarchical behavior causing a "parent" to forward transformations to its "children".

IK ( Inverse Kinematics )
IK is a hierarchical behavior that causes a "child" to influence its "parent" ( influence can be multiple levels deep ).

Morph
Morph is a technique for deforming a mesh from one shape into another. Each shape ( aka morph-target ) contains the relative translation of all affected vertices.

Image
Single morph-target applied 100%

Bone
A bone is a basically a special purpose transformation matrix.

Skin
Skin ( aka Envelope ) is a technique to deform a mesh based on a bone-structure. The mesh requires a Weight-Map which connects each vertex to a number of bones at a certain percentage ( total of 100% ).

Image
Visual representation of a Weight-Map

K

Posted: Sat Feb 19, 2011 8:54 pm
by Kjell
:idea:

Maybe we could start with the simplest and most versatile feature .. F-Curves. Personally I think it would be good to keep things consistent and go with a approach like this.

Image

Additionally you would need a AnimatorCurve Component that has a Curve + Target property ( like AnimatorSimple ) and make it compatible with the Animators node of AnimatorGroup.

This also leaves room for CurveImport, CurveExpression etc.

K

great

Posted: Sun Feb 20, 2011 2:52 pm
by jph_wacheski
Nice summary Kjell!

It would be great if we do keep things consistant with the current paradigm, implementing the vaious elements as individual components, that work well to together,. in this way, they will have many uses unstead of one. That Curve editor setup looks smashing!

Posted: Sun Feb 20, 2011 3:29 pm
by Kjell
Hi jph,
That Curve editor setup looks smashing!
Thanks ~ It's not meant to be a editor though, just a visual preview :)

The idea of the new design is to have component specific editors in the bottom panel only* For example, when you have a Model that renders some geometry based on a Array, you can lock the preview onto the Model, but have the Array selected ( so you get the Array properties + editor ).

*Unlike the Sound / Graph Editor right now.

K

Posted: Sun Feb 20, 2011 3:33 pm
by VilleK
Good initiative Kjell and very nice with illustrations as well.

The Curve idea is excellent as it would be simple to use for things such as camera paths too. I believe it could be implemented quite quickly and I will start looking at this right away.

Just so I understand how we can take the next step after that, do you have any suggestion on how the Curve-component could be used for animating a mesh? Some sort of AnimateMesh-component that has Curve and Mesh properties maybe? Or simply using AnimateCurve to modify properties of a RenderTransform on different subtrees in a Model.OnRender?

Posted: Sun Feb 20, 2011 3:42 pm
by Kjell
Hej Ville,
The Curve idea is excellent as it would be simple to use for things such as camera paths too.
As long as you don't mean "paths" as in splines. Keep in mind that FCurves are basically 1D, so the X property of In can never be lower then 0, and X of Out never higher then 0.
Do you have any suggestion on how the Curve-component could be used for animating a mesh?
When animating a mesh using skinning, you're actually animating the underlying bone structure. So as soon as we've got hierarchy + bone ( + skeleton container ) support, we can start thinking about how to simplify assigning curves to various bone properties ( same thing with Morph ) :wink:

K

Posted: Sun Feb 20, 2011 4:25 pm
by VilleK
Aha, I see they are quite different from splines, I did not realize that at first. But I'm sure they can be useful for making smooth animation of a lot of things anyway.

Do you have the formula for calculating the value at a specific point? I find no obvious answer to that when I Google.

Posted: Sun Feb 20, 2011 4:30 pm
by Kjell
8)

I'm using this ..

Code: Select all

float solveCurve(int C, float T)
{
  float X1, Y1, X2, Y2, X3, Y3, X4, Y4, A, B, X, Y;

  if(Curve[C,CurveKey[C],0] > T)
  {
    CurveKey[C] = 0;
  }

  while(Curve[C,CurveKey[C]+1,0] < T)
  {
    ++CurveKey[C];
  }

  X1 = Curve[C,CurveKey[C]  ,0];
  Y1 = Curve[C,CurveKey[C]  ,1];

  X4 = Curve[C,CurveKey[C]+1,0];
  Y4 = Curve[C,CurveKey[C]+1,1];

  X2 = Curve[C,CurveKey[C]  ,4]+X1;
  Y2 = Curve[C,CurveKey[C]  ,5]+Y1;

  X3 = Curve[C,CurveKey[C]+1,2]+X4;
  Y3 = Curve[C,CurveKey[C]+1,3]+Y4;

  B = (T-X1)/(X4-X1);
  A = 1-B;

  X = X1*A*A*A+X2*3*A*A*B+X3*3*A*B*B+X4*B*B*B;

  B = (X-X1)/(X4-X1);
  A = 1-B;

  Y = Y1*A*A*A+Y2*3*A*A*B+Y3*3*A*B*B+Y4*B*B*B;

  return Y;
}
K

Posted: Sun Feb 20, 2011 10:58 pm
by keymasher
How would you go about binding bones to meshes who's vertices never had bones? some sort of proximity mapping?

sounds fairly heavy no?

Posted: Tue Feb 22, 2011 3:19 pm
by VilleK
Kjell, can you please rewrite your solveCurve in pseudo code indicating what the different array values correspond to.

Such as:

Code: Select all

TCurvePoint = class
  Frame,Value : single;
  InX,InY,OutX,OutY : single;
end;

...

var
  P1,P2 : TCurvePoint;  //The two points in the current interval

...

X1 := P1.InX;
etc. I'm not sure I will get it right otherwise :)

Posted: Tue Feb 22, 2011 3:47 pm
by Kjell
@Ville : Ehm, the confusion is probably caused by the fact that it's basically 2 functions in 1.

The first part determines which 2 points should be used for the calculation. Because I'm generally using animations with hundreds of points ( and don't need backward playback ), I keep a array ( CurveKey ) that holds at which point the animation is currently ( so I don't have to loop through all the points from the start every frame ).

Anyway, the actual curve solving part starts at "B = (T-X1)/(X4-X1)" .. this illustration should clear things up.

Image
P1 represents X1&Y1, P2 = X2&Y2 etc
sounds fairly heavy no?
@keymasher : There's a long and a short answer to that .. the short answer being "no" :)

Posted: Tue Feb 22, 2011 7:14 pm
by VilleK
Thanks for the explanation. First implementation checked in now. Nothing visual, just the basic components.

http://www.zgameeditor.org/files/ZGameEditor_beta.zip