Difference between revisions of "Creating animations"

From XStoryPlayer Wiki
Jump to: navigation, search
Line 172: Line 172:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Save the <code>init/std/base/char/char_base.dat</code> file.
 
Save the <code>init/std/base/char/char_base.dat</code> file.
 +
</li>
 +
<li>What remains is triggering the new animation. We will do this by simply replacing the jiggle pose with this new pose.<br>
 +
Of course a new script needs to be added for this pose in the future, but for this tutorial replacing the jiggle pose is good enough.<br>
 +
Open the <code>jiggle0_state.dat</code> and change the pose code to:
 +
<syntaxhighlight lang="cpp">
 +
// Jiggle
 +
loc.sp.pose_type = BENDOVER;
 +
loc.sp.pose_id  = 0;
 +
loc.sp.exact    = 0;
 +
loc.sp.par      = 0.5;
 +
SetPose(loc.sp);
 +
</syntaxhighlight>
 +
<li>Now run the changed dungeon scene and say to Saiko: 'jiggle'. She now should take on the bend pose.<br>
 +
[[file:adding_animation2.jpg|400px]]
 
</li>
 
</li>
 
</ol>
 
</ol>

Revision as of 11:38, 25 July 2015

In this tutorial you will learn how to add an animation to a character.

Steps

  1. Make sure you have downloaded and installed the Character Packs. We are using them in this tutorial.
    Also make sure you have the dungeon scene unpacked. We will use that scene as a test scene.
  2. Open the character6/body.ma file in Maya. You see the poses are stored in keyframes.
    Also check out character6/body.ini file. It contains a lot of movies. We will be adding a movie pose that lets the character bend over.
  3. Now we will create a new pose. Use the following Mel script to select all joints (Best is to create a button for it by dragging the script to the toolbar):
    select -r character ;
    select -add hip_left ;
    select -add hip_lrot ;
    select -add knee_left ;
    select -add foot_left ;
    select -add hip_right ;
    select -add hip_rrot ;
    select -add knee_right ;
    select -add foot_right ;
    select -add spine_bottom ;
    select -add spine_mid ;
    select -add spine_top ;
    select -add neck_joint ;
    select -add head_joint ;
    select -add shoulder_left ;
    select -add arm_left ;
    select -add arm_lrot ;
    select -add elbow_left ;
    select -add hand_left ;
    select -add shoulder_right ;
    select -add arm_right ;
    select -add arm_rrot ;
    select -add elbow_right ;
    select -add hand_right ;

    Select frame 300 and to Right Mouse Click - Copy.
    Select free frame 11500 and do Right Mouse Click - Paste (Paste).

    Now we created a new pose frame and we can adjust the new pose.
  4. Create a bending pose by rotating the joints. To something like this:
    Adding animation1.jpg
    When you are finished run this Mel script (Best is to create a button for it by dragging the script to the toolbar):
    select -r hip_left ;
    setKeyframe "hip_left.rotateY";
    setKeyframe "hip_left.rotateZ";
     
    select -r knee_left ;
    setKeyframe "knee_left.rotateY";
     
    select -r foot_left ;
    setKeyframe "foot_left.rotateY";
    setKeyframe "foot_left.rotateZ";
     
    select -r hip_right ;
    setKeyframe "hip_right.rotateY";
    setKeyframe "hip_right.rotateZ";
     
    select -r knee_right ;
    setKeyframe "knee_right.rotateY";
     
    select -r foot_right ;
    setKeyframe "foot_right.rotateY";
    setKeyframe "foot_right.rotateZ";
     
    select -r spine_bottom ;
    setKeyframe "spine_bottom.rotateY";
    setKeyframe "spine_bottom.rotateZ";
     
    select -r spine_mid ;
    setKeyframe "spine_mid.rotateY";
    setKeyframe "spine_mid.rotateZ";
     
    select -r spine_top ;
    setKeyframe "spine_top.rotateY";
     
    select -r neck_joint ;
    setKeyframe "neck_joint.rotateY";
    setKeyframe "neck_joint.rotateZ";
     
    select -r head_joint ;
    setKeyframe "head_joint.rotateX";
    setKeyframe "head_joint.rotateY";
     
    select -r shoulder_left ;
    setKeyframe "shoulder_left.rotateX";
    setKeyframe "shoulder_left.rotateZ";
     
    select -r arm_left ;
    setKeyframe "arm_left.rotateY";
    setKeyframe "arm_left.rotateZ";
     
    select -r elbow_left ;
    setKeyframe "elbow_left.rotateY";
     
    select -r hand_left ;
    setKeyframe "hand_left.rotateX";
    setKeyframe "hand_left.rotateZ";
     
    select -r shoulder_right ;
    setKeyframe "shoulder_right.rotateX";
    setKeyframe "shoulder_right.rotateZ";
     
    select -r arm_right ;
    setKeyframe "arm_right.rotateY";
    setKeyframe "arm_right.rotateZ";
     
    select -r elbow_right ;
    setKeyframe "elbow_right.rotateY";
     
    select -r hand_right ;
    setKeyframe "hand_right.rotateX";
    setKeyframe "hand_right.rotateZ";
     
    select -r arm_rrot;
    setKeyframe "arm_rrot.rotateX";
     
    select -r arm_lrot;
    setKeyframe "arm_lrot.rotateX";
     
    select -r hip_rrot;
    setKeyframe "hip_rrot.rotateX";
     
    select -r hip_lrot;
    setKeyframe "hip_lrot.rotateX";
     
    select -r character ;
    setKeyframe "character.translateX";
    setKeyframe "character.rotateX";
    setKeyframe "character.rotateY";
    setKeyframe "character.translateY";
    setKeyframe "character.rotateZ";
    setKeyframe "character.translateZ";

    This will set the new keyframe and fix the pose.
    Save the character6/body.ma file.

  5. Open the character6/body.ini file. Add this code after the jiggle_0 movie to create the movie pose:
    movie "bendover_0"
    {  
      frame[11500] = 0;
    }

    This will add the frame to the character. Save the character6/body.ini file.

  6. Run the filemaker character6 creation script (see Character Packs).
    This will create the character object with the pose added.
    Copy the character6/characterShape.obj to the dungeon pack.
  7. Now we need to describe how the animation is used. Open the dungeon init/std/base/char/char_base.dat file and add the following at the end:
    pose_type[126]
    {
      type = BENDOVER;      // The pose name
      id   = 0;             // The pose id
      name = "*bendover_0"; // The pose animation
     
      need_type = STAND; // Need this pose before starting
      need_id   = 0;
     
      go_type   = STAND; // Goto this pose when ready
      go_id     = 0;
     
      fade_in = 1.5; // Fade in
     
      damp = 3; // Damping
     
      loop = false; // No loop
    }

    Save the init/std/base/char/char_base.dat file.

  8. What remains is triggering the new animation. We will do this by simply replacing the jiggle pose with this new pose.
    Of course a new script needs to be added for this pose in the future, but for this tutorial replacing the jiggle pose is good enough.
    Open the jiggle0_state.dat and change the pose code to:
    // Jiggle
    loc.sp.pose_type = BENDOVER;
    loc.sp.pose_id   = 0;
    loc.sp.exact     = 0;
    loc.sp.par       = 0.5;
    SetPose(loc.sp);
  9. Now run the changed dungeon scene and say to Saiko: 'jiggle'. She now should take on the bend pose.
    Adding animation2.jpg