3D그래픽2011. 10. 10. 18:23
Skinning is a technique for deforming geometry by linearly weighting vertices to a set of transformations, represented by <node> elements. Nodes that affect a particular geometry are usually organized into a single hierarchy called a “skeleton,” although the influencing nodes may come from unrelated parts of the hierarchy. The nodes of such a hierarchy represents the “joints” of the skeleton, which should not be confused with the “bones,” which are the imaginary line segments connecting two joints.

This section provides a description of and equations for skinning in COLLADA. 


Overview 

A skinning <controller> associates a geometry with a skeleton. The skeleton is considered to be in its resting position, or bind pose. The bind pose is the world-space position and orientation of each joint when the skeleton was bound to the geometry. This world space is also called the bind-pose space to distinguish it from other world-space coordinate systems. 

A skinning <instance_controller> instantiates a skinning <controller> and associates it with a run-time skeleton. COLLADA defines skinning in object space, so the <instance_controller>’s placement in the <node> hierarchy contributes to the final vertex location. Object-space skinning provides the maximum amount of flexibility. The output of object-space skinning is vertices in the object space of the <node> coordinate system that contains the <instance_controller>

When vertices are skinned in object space, it is easy and efficient to render the same skinned geometry in multiple locations. This is important when multiple actors are displayed simultaneously in the same pose but in different locations. Events like this happen most frequently in the animation of large crowds, parallel machines, and multiactor choreography. Each actor in the same pose shares the same skinned vertex data.  


Skinning Definitions

Definitions related to skinning in COLLADA:

* Bind shape: The vertices of the mesh referred to by the source attribute of the <skin> element.
* Bind-shape matrix: A single matrix that represents the transform of the bind-shape at the time when the mesh was bound to a skeleton. This matrix transforms the bind-shape from object space to bind-space.
* Joints: The bones of a skeleton are defined by their joints; the base of each bone extends to the next joint. In bind space, joints are in their bind pose: the position and orientation at the time the joints of the skeleton were bound to the bind shape. In the <visual_scene>, the joints are oriented according to the poses and animations of the actor. The world-space location of the joints may not directly match the mesh; it is dependent on the root matrix used to convert the mesh back into object-space.
* Weights: How much a joint influences the final destination of a vertex. A vertex is typically weighted to one or more joints, where the sum of the weights equals 1. A vertex is transformed by each joint independently. The multiply transformed vertex results are linearly combined according to their weights to generate the skinned vertex.
* Inverse bind-pose matrix: The inverse of the joint’s bind-space transformation matrix at the time the bind shape was bound to this joint.


Skinning Equations 

The skinning calculation for each vertex v in a bind shape is 

      outv=\sum_{i=0}^{n}\left \{ ((v*BSM)*IBMi*JMi)*JW \right \}

where: 
*  n: The number of joints that influence vertex v
*  BSM: Bind-shape matrix
*  IBMi: Inverse bind-pose matrix of joint i
*  JMi: Transformation matrix of joint i
*  JW: Weight of the influence of joint i on vertex v
Note: v, BSM, IBMi, and JW are constants with regards to some skeletal animation. Depending on your application, it may be beneficial to premultiply BSM with IBMi or v with BSM. 


Equation Notes 

The main difference between world-space skinning and object-space skinning lies in the definition of JMi:
 
* For world-space skinning, JMi is the transformation matrix of the joint from object space to world space.
* For object-space skinning, JMi is a transformation matrix of the joint from object space to another object space. The first object-space transformation is the geometry’s object-space transformation where the bind shape was originally defined. The second object-space transformation is the destination object space, which is selected by the <instance_controller><skeleton>.

It is easiest to conceptualize this transformation by considering the other spaces that may fall between these spaces to construct this final matrix. One method is to go from geometry object space to world space as you might see with world-space skinning, then transform from world space to the skeleton’s object space using the inverse of the skeleton’s world-space matrix. 

It is important to note that the skeleton’s matrix referred to here is not the bind-shape matrix. It is the <node> in the <visual_scene> referenced by <instance_controller><skeleton> and that might not have the same values. Using the <node> referenced by <instance_controller><skeleton> provides maximum flexibility for locating and animating skeletons in the scene. It removes all restrictions over the bind space of the skin and the object space of the skeleton in the scene. This is because the animation is always relative to what you pick as the root node. 

If you were to hypothetically use the bind-shape matrix instead, then the skeleton would always have to be located and animated relative to the bind-shape matrix’s location and orientation in the scene. If you are animating multiple characters at once, this can be disorienting because there is a high probability of overlap. It is worth noting that the node’s world-space matrix, referenced by <instance_controller><skeleton>, can be equal to a skin’s bind-shape matrix and that would match the behavior just mentioned; or it can be equal to an identity matrix to match the behavior of world-space skinning. Enabling these options makes object-space skinning the most flexible model. 

The result of the preceding equation is a vertex in skeleton-relative object space, so it must still be multiplied by a transform from object space to world space to produce the final vertex. This last step is typically done in a vertex shader and this matrix is the world-space transformation matrix for the node that owns the <instance_controller>. 

There is a simple trick to animating a skeleton and its <instance_controller> simultaneously. If you place the <instance_controller> inside the root of <skeleton> then the last two matrices cancel each other, which gives a solution much like world-space skinning. The mesh always follows the skeleton. 

'3D그래픽' 카테고리의 다른 글

The Cg Tutorial  (0) 2011.10.22
onDrawFrame에서의 고려사항 Android OpenGL ES 2.0  (0) 2011.10.22
GLSurfaceView.Renderer interface  (1) 2011.09.29
Build library with android NDK  (0) 2011.09.16
Phong Shading  (0) 2011.09.10
Posted by 세월의돌