AWD playing basic animations.

Software: Away3D 4.x

Slurpy, Newbie
Posted: 18 January 2013 10:03 AM   Total Posts: 2

Hi

I am very new to 3d and Away3D. I have followed the example http://away3d.com/tutorials/3DS_Max_Workflow

A colleague has created his own 3DS animation. It does not use skeletons.

We successfully export the model (a simple teapot), He has made 2 animations: 1) the teapot lifts and pours 2) the lid is removed.

How do I play back these animations? I have looked at VertexAnimator but can’t quite figure out how to hook it up.

thanks

package {
 
 import away3d
.animators.AnimationSetBase;
 
import away3d.animators.AnimatorBase;
 
import away3d.animators.SkeletonAnimationSet;
 
import away3d.animators.VertexAnimator;
 
import away3d.containers.View3D;
 
import away3d.entities.Mesh;
 
import away3d.events.AssetEvent;
 
import away3d.events.LoaderEvent;
 
import away3d.library.AssetLibrary;
 
import away3d.library.assets.AssetType;
 
import away3d.loaders.Loader3D;
 
import away3d.loaders.parsers.AWD2Parser;
 
import away3d.loaders.parsers.Parsers;
 
import away3d.materials.MaterialBase;
 
import away3d.materials.TextureMaterial;
 
import away3d.primitives.PlaneGeometry;
 
import away3d.textures.BitmapTexture;
 
import away3d.textures.WebcamTexture;
 
import flash.display.BitmapData;
 
import flash.display.Sprite;
 
import flash.events.Event;
 
import flash.geom.Vector3D;
 
import flash.media.Camera;
 
import flash.media.Video;
 
import flash.net.URLRequest;
 
 public class 
Away3dScene extends Sprite {
  
private var mView:View3D;
  private var 
_plane:PlaneGeometry;
 
  private var 
mTotalAssets:int 0;
  private var 
mLoadedAssets:int 0;
  private var 
_teapot:Mesh;
  private var 
_cameraMesh:Mesh;
  private var 
animationSet:SkeletonAnimationSet;
  private var 
obj1:Mesh;
  
  public function 
Away3dScene(pAntiAlias:uint 4{
   mView 
= new View3D();
   
   
addChild(mView);
   
mView.camera.= -600;
   
mView.camera.500;
   
mView.camera.lookAt(new Vector3D());
   
mView.antiAlias pAntiAlias
   
   
   
//addBitmapData( new BitmapData(256, 256, false, 0xFF0000));
   
   //init3DCamera();
   
loadAWD("media/Anime_test_teapot.AWD");
   
   
   
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
  
}
  
  
  
private function initStageCamera() {
   
  }
  
  
/*private function init3DCamera() {
   var wcTex:WebcamTexture = new WebcamTexture();
   var mat:TextureMaterial = new TextureMaterial(wcTex);
   var mesh:Mesh = new Mesh(new PlaneGeometry(256, 256), mat);
   mView.scene.addChild(mesh); 
   GlobalApp.cTrace("camera")
   _cameraMesh = mesh;
   _cameraMesh.scale(2);
  }*/
  
  
public function addBitmapData(pBmp:BitmapData):Mesh {
   
//var dat:BitmapData = new BitmapData(256, 256, false, 0xADADAD);
   
var mMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(pBmp));   
   var 
mesh:Mesh = new Mesh(new PlaneGeometry(256256), mMaterial);
   
mView.scene.addChild(mesh);
   return 
mesh;
  
}
  
  
public function loadAWD(pAwdFile:String{
   mTotalAssets
++;
   
   
Parsers.enableAllBundled();
   
AssetLibrary.enableParser(AWD2Parser);
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
   
AssetLibrary.addEventListener(LoaderEvent.LOAD_ERRORonLoadError);
   
AssetLibrary.load(new URLRequest(pAwdFile));
   
//AssetLibrary.load(new URLRequest(MESH_URL));
   
  
}
  
  
private function onLoadError(event:LoaderEvent):void 
  {
   GlobalApp
.cTrace("Error loading: " event.url,event.message);
  
}
  
  
  
  
private function onAssetComplete(event:AssetEvent):void 
  {
   GlobalApp
.cTrace("Loaded Name: '" event.asset.name "' assetType: '" event.asset.assetType +"'");
  
}
  
  
private function onResourceComplete(event:LoaderEvent):void 
  {
   mLoadedAssets
++;
   if (
mLoadedAssets == mTotalAssets{
    GlobalApp
.cTrace("assets loaded");
    
//AssetLibrary.getAsset(
    //hero = ;
    
    
_teapot Mesh(AssetLibrary.getAsset("Teapot001"));
    
_teapot.scale(5);
    
    
//obj1 = Mesh(AssetLibrary.getAsset("Object001"));
    
    //obj1.rotationZ = 90;
    
    
    
    
    //modelTexture = BitmapTexture(AssetLibrary.getAsset("Teapot001"));
    //animationSet = new SkeletonAnimationSet(3);
    //animationSet.addAnimation(
    
    
    
mView.scene.addChild(_teapot);
   
}
   
  }
  
  
  
  
  
public function get view():View3D {
   
return mView;
  
}
  
private function _onEnterFrame(e:Event):void
  
  {
   
//_plane.rotationY += 1;
   
if (_teapot{
    _teapot
.rotationY +=1;
   
}
   
//_cameraMesh.x = 300;
   
   //_cameraMesh.rotationY++;
   
mView.render();
   
//GlobalApp.cTrace(_mesh.rotationY);
  
}
 }
   

Avatar
Fabrice Closier, Administrator
Posted: 18 January 2013 10:26 AM   Total Posts: 1265   [ # 1 ]

You cannot export scenespace animations or vertexanimations within the awd file format in its current state (2.0 specs).
Prefab offers alternative that would play back scenespace animations, but they would have to be defined within the app and exported as as3.
You could also generate vertexanimations from scratch in there, by loading external states and export either as md2 or as3 and use that within your project.
If you use skeletal animation, you could export as awd directly from max and away would play it back. Search this forum, there are many posts covering the subject.

We are busy working on extending animation capabilities.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X