Got Problem when Loading MD5 Animation with Bulkloader

Software: Away3D 4.x

jtopaz, Member
Posted: 29 July 2011 04:45 PM   Total Posts: 53

I try to load MD5 model and animation into away3d with bulkloader.
I success load model:

**************************************************************************
var model:Loader3D = new Loader3D();
model.parseData(bulkLoader.getText(“model”), new MD5MeshParser);
scene.addChild(model.getChildAt(0));
**************************************************************************

But when it come to load animation, I try below code but fail because seq = null:

**************************************************************************
var anim:Loader3D = new Loader3D();
anim.parseData(bulkLoader.getText(“anim”), new MD5AnimParser);
var seq : SkeletonAnimationSequence = anim as SkeletonAnimationSequence;
**************************************************************************

Any idea how to solve it?
thanks alot.

   

Richard Olsson, Administrator
Posted: 29 July 2011 09:19 PM   Total Posts: 1192   [ # 1 ]

You can’t cast a Loader3D to SkeletonAnimationSequence, because they are two completely unrelated types. Actually, it makes little sense to use Loader3D to load something that is not visual (e.g. animation data). Use AssetLoader instead, and listen for the ANIMATION_COMPLETE event which should be dispatched when the animation sequence has finished parsing. Then get it through the asset property of the event object.

   

jtopaz, Member
Posted: 30 July 2011 09:33 AM   Total Posts: 53   [ # 2 ]

Thanks Richard, AssetLoader work.
The reason I use Bulkloader is to manage the loading activity, using extra AssetLoader and listener make loading activity complex.
Any ways to avoid using AssetLoader?

   

Richard Olsson, Administrator
Posted: 30 July 2011 10:11 AM   Total Posts: 1192   [ # 3 ]

I think you are misunderstanding. AssetLoader is not a replacement for BulkLoader (nor did I ever mean for you to replace BulkLoader with it.) It’s an alternative to Loader3D. Loader3D is meant to be a short-hand for loading things directly into the scene graph. AssetLoader is used in the exact same way, but without the added benefit of (and extra code for) automatically adding things to the scene graph.

What you should be doing is replacing your use of Loader3D with AssetLoader, and listen for the ANIMATION_COMPLETE event on it.

var anim:AssetLoader = new AssetLoader();
anim.addEventListener(AssetEvent.ANIMATION_COMPLETEonAnimComplete);
anim.parseData(bulkLoader.getText("anim"), new MD5AnimParser);

function 
onAnimComplete(ev AssetEvent) : void
{
  
var seq SkeletonAnimationSequence 
                
ev.asset as SkeletonAnimationSequence;

Your problem is that you’re trying to cast an instance of Loader3D to SkeletonAnimationSequence, which will never work because they are unrelated types. This is nothing specific to Away3D, and for the same reason that you can’t for example cast an Event to a MovieClip.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X