Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To build an animation clip event, open the Atoms UI and make sure to have selected the "AnimationClipEvents" tab.

Click on "Add" and you will be prompted with a dialog asking if you want to edit your clip in GUI or script mode.


GUI mode


Give a name to your animation clip (i.e. robotWalk).

Select the FBX file you exported previously. As soon as you select a file Atoms will look for its preview file and will load it on the right side of the GUI.

Most of the GUI options were explained here already.

For this tutorial, we are going to change the "Loop Blend" to 4.

The preview will be very handy now to find the loop start and end frames. Move the mouse over the preview and find two poses that are similar to each other. Generally the first frame where a foot gets down on the ground will be a good choice.
In our case the start frame will be 21 and the end frame will be 50.

Set the "Direction Type" to static.
In the preview you will also see the "Clip direction". It tells you how your skeleton root travels in space from the beginning to the end of your clip. In this case it's easy to see that the major movement axis for this clip is the X axis.
For this reason, you can set the "Direction" field to (1, 0, 0).

Click the "Register" button or press CTRL+S.

 Your Animation Clip is now ready to be used.

Image RemovedImage Added


Script mode

In case you selected the script mode, you should edit your script so it looks like the following.

Then hit CTRL+S or click on the "Register" button. 

Code Block
languagepy
themeEclipse
firstline1
titleAnimation Clip
linenumberstrue
import os
import AtomsMath
import AtomsCore
import Atoms
from Atoms import GLOBAL_NAMES


class AnimClipEvent6(Atoms.SimulationEvent):
    eventName = 'robotWalk'
    clipPath = 'D:/projects/atomsDemo/clips/walk.fbx'
    blendFramesAfterFootUp = 4
    loop = True
    loopStart = 21
    loopEnd = 50
    loopBlend = 4
    idle = False
    direction = [1.0,0.0,0.0]
    directionType = 1
    directionFromJoints = [0,1]

    def __init__(self):
        Atoms.SimulationEvent.__init__(self)
        self.setName(self.eventName)

    def load(self):
        CLIP = GLOBAL_NAMES.CLIP
        
        aClips = Atoms.AnimationClips.instance()
        aClips.addAnimationClip(self.eventName, self.clipPath, True)
        acPtr = aClips.animationClip(self.eventName)
        if acPtr is None:
            return
        metadataMap = acPtr.metadata()

        metadataMap[CLIP.BLEND_FRAMES_AFTER_FOOT_UP] = AtomsCore.IntMetadata(self.blendFramesAfterFootUp)
        metadataMap[CLIP.LOOP] = AtomsCore.BoolMetadata(self.loop)
        metadataMap[CLIP.LOOP_START] = AtomsCore.IntMetadata(self.loopStart)
        metadataMap[CLIP.LOOP_END] = AtomsCore.IntMetadata(self.loopEnd)
        metadataMap[CLIP.LOOP_NUM_BLEND_FRAMES] = AtomsCore.IntMetadata(self.loopBlend)

        if self.directionType == 1:
            acPtr.setDirectionType(Atoms.AnimationClip.DirectionType.Static)
        elif self.directionType == 0:
            acPtr.setDirectionType(Atoms.AnimationClip.DirectionType.Pelvis)
        else:
            acPtr.setDirectionType(Atoms.AnimationClip.DirectionType.Joints)
        acPtr.setDirection(AtomsMath.V3d(self.direction[0], self.direction[1], self.direction[2]))
        acPtr.setDirectionFromJoints(self.directionFromJoints[0], self.directionFromJoints[1])
        acPtr.setIdle(self.idle)