3dsmax & SkeletonAnimation - strange behaviour

Software: Away3D 4.x

timTaylor, Newbie
Posted: 18 January 2013 08:49 AM   Total Posts: 4

in my 3dsmax scene i do have a sliding door (mesh) which i want to animate.
i added a single bone to the scene, animated it and applied a skin modifier to my door and added the bone.
i prepared a sequences.txt file:

slidingDoorOpen 0 15
slidingDoorClose 15 30 

i’d done the setup for the animation:

private function onAssetComplete(event:AssetEvent):void
  {
   
   
var _loc_2:Mesh null;
   var 
_loc_3:* = null;
   
//var _loc_4:AnimationN= null;
   
   
trace("loaded asset: " "[" event.asset.assetType "] " event.asset.name);
   
   if (
event.asset.assetType == AssetType.MESH)
   
{
    _loc_2 
Mesh(event.asset);
    
_loc_3 _loc_2.material as TextureMaterial;
    
    
// add events to clickable objects
    
asignMeshClickListener(_loc_2);
    
    
// setup special materials (glass...)    
    
if (_loc_3)
    
{
     
if (_loc_2.material.name == "matGlass")
     
{
      _loc_3
.alpha 0.25;
     
}
    }
    
    
// asign local var pointers
    
if( event.asset.name=="house1doorFrameLeft" )
    
{
     _mesh_house1doorFrameLeft 
_loc_2;
    
}
   }
   
else if (event.asset.assetType == AssetType.SKELETON)
   
{
    
if (event.asset.name == "Bone001")
    
{
     _skeleton_bone001_animationSet 
= new SkeletonAnimationSet(3);
     
_skeleton_bone001_animator = new SkeletonAnimator(_skeleton_bone001_animationSetevent.asset as Skeleton);
     
    
}
   }
   
else if (event.asset.assetType == AssetType.ANIMATION_NODE)
   
{    
    
if (_skeleton_bone001_animationSet.animationNames.indexOf(event.asset.name)<0)
    
{
     trace
("added animation state: " event.asset.name);
     
_skeleton_bone001_animationSet.addAnimation(event.asset as AnimationNodeBase);
    
}    
   }
      

  }
  
  
private function onResourceComplete(e:LoaderEvent):void
  {
   _view
.scene.addChild(this._loader);
   
   
// animator bindings
   
_mesh_house1doorFrameLeft.animator _skeleton_bone001_animator;
   
   
//setup the render loop
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
   
_stage.addEventListener(Event.RESIZEonResize);
   
_stage.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
_stage.addEventListener(MouseEvent.MOUSE_UPonMouseUp);
   
_stage.addEventListener(MouseEvent.MOUSE_WHEELonMouseWheel);
   
   
onResize();   
  
}
  
private function asignMeshClickListener(loc_2:Mesh):void
  {
   
switch (loc_2.name)
   
{
    
case "house1doorWindowLeft"
    case 
"house1doorWindowRight"
    case 
"house1doorFrameLeft"
    case 
"house1doorFrameRight"
     
loc_2.mouseEnabled true;
     
loc_2.addEventListener(MouseEvent3D.CLICKanimateHouse1Doors_doOpen);     
     break;
   
}
  }
  
  
private function animateHouse1Doors_doOpen(e:MouseEvent3D):void
  {
   _skeleton_bone001_animator
.play("slidingDoorOpen");
  

now, if my scene starts up, some other meshes which are not affected by the animation are corrupted.
the click handler works fine and the animation starts to play. but it takes the door from its position away to the 0,0,0 point of my scene and animates it there.
some other strange things:
1) the animation never stops - it should stop at frame 15!?!?
2) every animation node gets loaded twice!! i fixed this strange problem with this code:

if (_skeleton_bone001_animationSet.animationNames.indexOf(event.asset.name)<0)
    
{
     trace
("added animation state: " event.asset.name);
     
_skeleton_bone001_animationSet.addAnimation(event.asset as AnimationNodeBase);
    

but is this usual???

is there a bug in the awd-exporter or i’m doing something wrong?

   

Avatar
loth, Sr. Member
Posted: 18 January 2013 05:48 PM   Total Posts: 236   [ # 1 ]

for that you don’t need animator
why just apply rotation to your door ?

anyway to play one time animation add
else if (event.asset.assetType == AssetType.ANIMATION_NODE) {
  var animationNode : SkeletonClipNode = event.asset as SkeletonClipNode;
  _animationSet.addAnimation(animationNode);
  // disable animation loop*
  if (animationNode.name == “TrowGrenade”) animationNode.looping = false;
}

you can close door by add negative speed
_animator.playbackSpeed = - 1

 

   

timTaylor, Newbie
Posted: 19 January 2013 06:51 AM   Total Posts: 4   [ # 2 ]

thanks for the answer!

i know i could do such simple animations in flash but:
1) i want to understand, how to set up animations and use them.
2) as far as possible i want to keep away from hardcoding animations because of the development workflow, where it should be possible to do all animations in 3dsmax and only call anims from flash.

your example helps me, to assign my animation right. (SkeletonClipNode instead of AnimationNodeBase). it’s very hard to figure out anything at away3d because of missing any examples at the docs.

to minimize my problems, i’ve set up a new, very simple scene:
2 boxes, converted to editable mesh.
1st box with the name ‘Box001’,
2nd box with the name ‘house1doorFrameLeft’,
created a single bone, named ‘Bone001’.
applied a skin modifier to the ‘Box001’ and added the ‘Bone001’.
key-frame-animated the ‘Bone001’ with a movement along the x-axis.
exported all as awd-file with usage of my sequences.txt file.

after building my swf i get the same result as in my complex scene:

on clicking the ‘house1doorFrameLeft’ box:

- ‘house1doorFrameLeft’ box starts animating from 0,0,0 and not from it’s original location (36.5,-31.9,0.0)
- ‘Box001’ also moves quite a few pixels (doesn’t have any animations or skin modifiers applied to it!!)
- after the animation of ‘house1doorFrameLeft’ has finished, both objects disappear from the scene!

i’m using 3dsmax2012 x64 with the ‘maxawd_2012_64_v1.0.2.zip’ plugin.

 

 

File Attachments
simpleBoxAnim.max  (File Size: 208KB - Downloads: 0)
   

Avatar
loth, Sr. Member
Posted: 19 January 2013 02:27 PM   Total Posts: 236   [ # 3 ]

yes for position is ‘normal’ if object is link or animated is move to 0.0.0
create new bone at 0.0.0 and link your door bone to them and your door keep the right place.
for other probleme i don’t see is strange your box001 move
maybe you link object ?
for animation end ? maybe your animation txt have a frame after end.

compress your file in zip i can look if i have same error

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X