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 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 wer were explained here already.

For this tutorial, we are going to change the "Loop Blend" to 4, set the "Direction Type" to static.

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 get gets down on the ground will be a good choisechoice.
In our case the start frame will be 6 21 and the end frame will be 3650.

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.


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 imath
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 = 621
    loopEnd = 3650
    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(imath.V3d(self.direction[0], self.direction[1], self.direction[2]))
        acPtr.setDirectionFromJoints(self.directionFromJoints[0], self.directionFromJoints[1])
        acPtr.setIdle(self.idle)