Dev:Bones

From Synfig Studio :: Documentation
Revision as of 18:44, 2 November 2010 by Genete (Talk | contribs) (Value Node Bone, BoneInfluence, BoneWeightPair, Skeleton)

Jump to: navigation, search

Introduction

One of the most wanted features for a 2D animation software is the bones feature. The original developer didn't implement bones in Synfig because it could become a restriction to the freedom of the animator to give expression to the creation. Finally, the decision of include the bones feature was taken and a core bones implementation is already available in the Synfig code.

Bones feature has two main parts. The core of the bones feature and the graphical user interface of the bones feature. At the time of writing this article, only the core of the bone feature is implemented with a very primitive user interface.

This article will introduce you in the knowledge of how are currently the bones feature implemented and how should it continue its development. Once finished the bones development, this pages should be moved to the talk page and the Dev namespace should be removed from the article to turn it into a regular documentation page.

The firsts seeds of the bones development are the notations in the Bone Layer. At first stage the idea of a Bone layer was around because most of the features of Synfig are applied in the form of layer on a stack. During the bones development we realized that the concept of bone layer is not strictly needed. Currently it is possible to not have any Skeleton layer (this is how it is called in the Bone Layer page) and the bones can be working on a Synfig document.

Basic concepts

Bones affect points (blinepoints or individual vertexes). This means that when a bone is modified it can affect to points that are under its influence.

Bones have:

  • Origin
  • Angle
  • Local Width Scale
  • Local Length Scale
  • Recursive Width Scale
  • Recursive Length Scale
  • Setup Origin
  • Setup Angle
  • Setup Length

Although they can look to be a lot of parameters, we can concentrate only on some of them: origin, angle, length/width (we will talk later about the recursive ones). Let's see how do those parameters affect to a point that is under the influence of a bone:

  • When a bone modifies its angle, the point rotates around the origin.
  • When a bone modifies its origin, the point translates the same amount than the bone's origin.
  • When a bone modifies its length or width, the point scales in the length or width direction of the bone relative to the bone's origin.

All the above point modifications under bone influence needs some other information to allow know the exact position of the point after the influence. For example, when the bone rotates, the distance of the point to the bone's origin is very important, because it determines the rotation radius.

So, there must be a "setup" position of the point relative to the bone where the calculations are made from. Following that reasoning, the bone should have two sets of values, the setup values and the animated values. And so, the points should have a setup values and a calculated values when the bone influence is applied.

Those two set of values (setup and animated or calculated) are representation of the same object in two states, the setup state and the animated state.

Apart of the single bone -> point influence it is possible that a point were influenced more than one bone. If only one bone could affect to a point, then we would be talking about cutout animation. But bones are much more than cutout animation. The points can be influenced by more than one bone at a time. To solve this problem we implemented the concept of weighted influence. A point is influenced by a the pair of the bone an its weight so each single bone influence is multiplied by its weight and then added to all the other weighted bones and finally divided by the sum of weights. This is known as linear combination of bones.

Value Node Bone, BoneInfluence, BoneWeightPair, Skeleton

To calculate the bone influenced animated position of a point, we take the setup position (point and bone) and apply the animated values of the bones (the bone influence transformation to calculate the modified value of the point. This is performed for each bone and then linearly combined with the bones weights. The higher the weight is, the more influence the bone has on the particular point.

But, how are those operations performed in the current design?

Initially we can think on bones as layers: "All the context below the layer is affected by the bone layer". A design like that implies to scrubb the layer stack and apply the bones effect to all the layers below in the bone's scope. That leads some problems because maybe you don't want to affect by a bone some kind of layers (i.e. filters) or perhaps you don't want to apply the bones influence to all the geometry layers that are below the bone layer. For one reason or other, the user would like to decide which layers are affected by the bones and even which parameters should be affected. That breaks the layer concept of Synfig and needs to use other Synfig feature: The Value Node.

So the decision on what parameter is influenced by a bone is taken converting the subject of the influence (vertex or blinepoint) into a BoneInfluence Value Node Convert type. The conversion offers the following sub parameters:

ValueNode_BoneInfluence:

  • ValueNode_BoneWeightPair List: This is a list of ValueNode_BoneWeightPair value node types
  • Link: This is the point at setup position

And Value Node Bone Weight Pair has the following subparameters:

ValueNode_BoneWeightPair:

  • bone: This is the ID of a bone
  • weight: this is the weight of this bone over the value node.

Appendix: How does bones feature work?

This is a description of the internal of how does bones work (write link here). It is not necessary to understand/read this part to understand the usage of the bones from the point of view of the user interaction.