Game Engine Architecture 11

1、three most-common techniques used in modern game engines.

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

  1)Cel Animation

  2)Rigid Hierarchical Animation

  3)Per-Vertex Animation and Morph Targets  

2、Cel Animation

  The precursor to all game animation techniques is known as traditional animation, or hand-drawn animation. This is the technique used in the earliest animated cartoons. 

  Cel animation is a specific type of traditional animation. A cel is a transparent sheet of plastic on which images can be painted or drawn.

  The electronic equivalent to cel animation is a technology known as sprite animation.

  Game Engine Architecture 11 随笔 第1张

3、Rigid Hierarchical Animation,刚体层次动画 / 刚体动画。

  a character is modeled as a collection of rigid pieces. A typical breakdown for a humanoid character might be pelvis(盆骨), torso(躯干), upper arms, lower arms, upper legs, lower legs, hands, feet and head.  

  A typical hierarchy has the pelvis at the root, with the torso and upper legs as its immediate children and so on as shown below:

    Game Engine Architecture 11 随笔 第2张

  The big problem with the rigid hierarchy technique is that the behavior of the character’s body is often not very pleasing due to “cracking” at the joints. This is illustrated in Figure 12.2.

    Game Engine Architecture 11 随笔 第3张

4、Per-Vertex Animation and Morph Targets

  per vertex animation is a data-intensive technique, since time-varying motion information must be stored for each vertex of the mesh. For this reason, it has little application to real-time games.

  morph target animation is used in some real-time games. Animations are produced by blending between two or more of these fixed poses at runtime. The morph target technique is often used for facial animation, because the human face is an extremely complex piece of anatomy, driven by roughly 50 muscles.

  As computing power continues to increase, some studios are using jointed facial rigs containing hundreds of joints as an alternative to morph targets. Other studios combine the two techniques, using jointed rigs to achieve the primary pose of the face and then applying small tweaks via morph targets. 

  Game Engine Architecture 11 随笔 第4张

5、Skinned Animation,蒙皮动画。

  In skinned animation, a skeleton is constructed from rigid “bones,” just as in rigid hierarchical animation. However, instead of rendering the rigid pieces on-screen, they remain hidden. A smooth continuous triangle mesh called a skin is bound to the joints of the skeleton; its vertices track the movements of the joints. Each vertex of the skin mesh can be weighted to multiple joints, so the skin can stretch in a natural way as the joints move.

  Rigid Hierarchical Animation 直接渲染 rigid piece,而 Skinned Animation 渲染的是 skin mesh。

6、Skeletons

  In the game industry, we often use the terms “joint” and “bone” interchangeably, but the term bone is actually a misnomer. Technically speaking, the joints are the objects that are directly manipulated by the animator, while the bones are simply

the empty spaces between the joints.

    Game Engine Architecture 11 随笔 第5张

7、SRT Transformations

  SRT transforms are widely used in computer animation because of their smaller size (eight floats for uniform scale, or ten floats for nonuniform scale, as opposed to the 12 floating-point numbers needed for a 4 x 3 matrix) and their ability to be easily interpolatefd.

  Game Engine Architecture 11 随笔 第6张

8、Representing a Skeleton in Memory

struct Joint
{
    Matrix4x3 m_invBindPos;

    const char* m_name; // human-readable joint name
    U8 m_iParent; // parent index or 0xFF if root
};

struct Skeleton
{
    U32 m_jointCount; // number of joints
    Joint* m_aJoint; // array of joints
};

9、Poses

  The pose of a joint is defined as the joint’s position, orientation and scale, relative to some frame of reference. A joint pose is usually represented by a 4x4 or 4x3 matrix, or by an SRT data structure (scale, quaternion rotation and vector translation). The pose of a skeleton is just the set of all of its joints’ poses and is normally represented as a simple array of SRTs.

  skeleton 的姿势就是其内所有 joint 的姿势 。

10、Bind Pose

  This is the pose of the 3D mesh prior to being bound to the skeleton. 3D mesh 绑定前的姿势。

  The bind pose is also called T-pose. This particular stance is chosen because it keeps the limbs away from the body and each other, making the process of binding the vertices to the joints easier.

11、Local Poses

  A joint’s pose is most often specified relative to its parent joint. Local poses are almost always stored in SRT format.

  many 3D authoring packages like Maya represent joints as small spheres. However, a joint has a rotation and a scale, not just a translation, so this visualization can be a bit misleading.

  The pose of an entire skeleton P^skel can be written as the set of all poses Pj, where j ranges from 0 to N-1:

    Game Engine Architecture 11 随笔 第7张

12、Representing a Joint Pose in Memory

struct JointPose
{
    Quaternion m_rot; // R
    Vector3 m_trans; // T
    F32 m_scale; // S (uniform scale only)
};

struct JointPose
{
    Quaternion m_rot; // R
    Vector4 m_trans; // T
    Vector4 m_scale; // S
};

struct SkeletonPose
{
    Skeleton* m_pSkeleton; // skeleton + num joints
    JointPose* m_aLocalPose; // local joint poses
};  

13、Representing a Global Pose in Memory

struct SkeletonPose
{
    Skeleton* m_pSkeleton; // skeleton + num joints
    JointPose* m_aLocalPose; // local joint poses
    Matrix44* m_aGlobalPose; // global joint poses
};

14、Clips

  game animations are almost never created as long, contiguous sequences of frames. Instead, a game character’s movement must be broken down into a large number of fine-grained motions. We call these individual motions animation clips, or sometimes just animations.

  The term FMV applies to sequences that have been prerendered to an MP4, WMV or other type of movie file and are played back at runtime by the engine’s full-screen movie player.

  quick time event (QTE). In a QTE, the player must hit a button at the right moment during an otherwise noninteractive sequence in order to see the success animation and proceed;

15、Frames, Samples and Looping Clips

  • If a clip is non-looping, an N-frame animation will have N + 1 unique samples.

  • If a clip is looping, then the last sample is redundant, so an N-frame animation will have N unique samples.

    Game Engine Architecture 11 随笔 第8张

16、A Simple Animation Data Format

    Game Engine Architecture 11 随笔 第9张

struct AnimationSample
{
    JointPose* m_aJointPose; // array of joint poses
};

struct AnimationClip
{
    Skeleton* m_pSkeleton;
    F32 m_framesPerSecond;
    U32 m_frameCount;
    AnimationSample* m_aSamples; // array of samples
    bool m_isLooping;
};

17、Relationship between Meshes, Skeletons and Clips

  Game Engine Architecture 11 随笔 第10张

  the skins are attached to the skeleton but don’t have any relationship with the animation clips. Likewise, the clips are targeted at a particular skeleton, but they have no “knowledge” of the skin meshes.

  Game Engine Architecture 11 随笔 第11张

  To provide the illusion of many different types of characters, it is usually better to create multiple meshes skinned to the same skeleton when possible, so that all of the characters can share a single set of animations.

18、

19、

20、

21、

22、

23、

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄