Looping SkeletonAnimation shifts mesh up

Software: Away3D 4.x

altunsercan, Newbie
Posted: 12 January 2013 05:59 PM   Total Posts: 6

Hi,

I imported an animated model that i exported from Maya using AWD Exporter. I can see the model and the animation however model slightly shifts up at every loop. Here is the code:

package
{
 import away3d
.animators.SkeletonAnimationSet;
 
import away3d.animators.SkeletonAnimationState;
 
import away3d.animators.SkeletonAnimator;
 
import away3d.animators.data.Skeleton;
 
import away3d.cameras.Camera3D;
 
import away3d.cameras.lenses.PerspectiveLens;
 
import away3d.containers.Scene3D;
 
import away3d.containers.View3D;
 
import away3d.entities.Mesh;
 
import away3d.events.LoaderEvent;
 
import away3d.library.AssetLibrary;
 
import away3d.library.AssetLibraryBundle;
 
import away3d.loaders.parsers.Parsers;
 
 
import flash.display.Sprite;
 
import flash.display.StageAlign;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
import flash.geom.Vector3D;
 
import flash.net.URLRequest;
 
 public class 
AnimationTest extends Sprite
 {
  
private var bundleLoadCounter:int;
  private var 
view:View3D;
  public function 
AnimationTest()
  
{
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
AssetLibrary.enableParsersParsers.ALL_BUNDLED );
   
   var 
bundle:AssetLibraryBundle AssetLibrary.getBundle("ninjaOutfit1");
   
bundle.addEventListener(LoaderEvent.RESOURCE_COMPLETEonBundleLoaded );
   
bundleLoadCounter 2;
   
bundle.load( new URLRequest"outfit.awd" ), null);
   
bundle.load( new URLRequest"idle.awd" ), null);
   
  
}
  
  
public function onBundleLoaded_e:LoaderEvent ):void
  {
   bundleLoadCounter
--;
   if( 
bundleLoadCounter != )
   
{
    
return;
   
}
   
//// Setup Scene
   
var camera:Camera3D = new Camera3D(); 
   var 
scene:Scene3D = new Scene3D();
   
view = new View3D();
   
view.backgroundColor 0x7AA8E6;
   
view.antiAlias 16;
   
view.scene scene;
   
view.camera camera;
   
   
camera.lens = new PerspectiveLens();
   
camera.lens.near 10;
   
camera.lens.far 500;
   
camera.30;
   
camera.30;
   
camera.= -60;
   
   
camera.lookAt( new Vector3D() );
   
this.addChildview );
   
   
this.addEventListenerEvent.ENTER_FRAMEonEvent );
   
   
// Create object
   
var bundle:AssetLibraryBundle AssetLibrary.getBundle("ninjaOutfit1");
   
   var 
ninjaMesh:Mesh Meshbundle.getAsset("ninja") );
   var 
ninjaSkeleton:Skeleton Skeletonbundle.getAsset("skeleton") );
   
   var 
ninjaAnimSet:SkeletonAnimationSet = new SkeletonAnimationSet);
   
   var 
idleState:SkeletonAnimationState SkeletonAnimationStatebundle.getAsset"idle" ) );
   
idleState.looping true;
   
   
ninjaAnimSet.addState("idle"idleState );
   
   var 
visual:Mesh MeshninjaMesh.clone() );
   var 
skelAnimator:SkeletonAnimator = new SkeletonAnimator(  ninjaAnimSetninjaSkeleton );
   
visual.animator skelAnimator;
   
   
visual.animator.play"idle" );
   
   
   
scene.addChildvisual );
  
}
  
  
protected function onEvent(event:Event):void
  {
   view
.render();
  
}  
  
 }

I commented out “applyRootDelta();” in SkeletalAnimator to see if it is the problem. Shifting stopped however no movement on the hips make it look floaty.

Is this a bug?

 

   

altunsercan, Newbie
Posted: 12 January 2013 08:23 PM   Total Posts: 6   [ # 1 ]

A little update:

I looked around in source code and found these lines in SkeletonClipNode class.

if ((_timeDir && _nextFrame _oldFrame) || (_timeDir && _nextFrame _oldFrame)) {
 _rootPos
.-= _totalDelta.x*_timeDir;
 
_rootPos.-= _totalDelta.y*_timeDir;
 
_rootPos.-= _totalDelta.z*_timeDir;

Now this appears to be something that is intended to fix shifted rootPosition before animation returned to first frame ( _nextFrame < _oldFrame ). However this seams to be causing my problem, i commented it out and now there is no shifting.

   

Avatar
Rob Bateman, Administrator
Posted: 12 January 2013 10:18 PM   Total Posts: 120   [ # 2 ]

Hey altunsercan


I can’t be sure but the problem you describe doesn’t sound like a bug, more like a mismatch between the ground-plane positions of your start and end frames of the walk cycle which over time will add up to a significant offset on the y axis. can you check that your root node positions for these frames are at identical y values?

Removing the lines you mention will stop movement on all axis after the loop reaches its end, in theory causing an abrupt jump back to the position of the first frame of animation, which would remove the overal distance the character had travelled up to that point. This doesn’t sound like its happening to you, but its probably not a recommended solution long term

   

altunsercan, Newbie
Posted: 13 January 2013 09:08 AM   Total Posts: 6   [ # 3 ]

Well i guess it is more about how we produce and handle animations. Our team creates animation cycles that looks like hovering people. We handle movement programmaticaly. So not adding up travelled distance is exactly what we want.

May be this should be optional. Jumping back to first frame is the behaviour i want.

   

altunsercan, Newbie
Posted: 20 January 2013 03:30 PM   Total Posts: 6   [ # 4 ]

I am having similar problems when transitioning between animations now. Is there a way to reset animation state to its initial values?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X