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.z = -600;
mView.camera.y = 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(256, 256), mMaterial);
mView.scene.addChild(mesh);
return mesh;
}
public function loadAWD(pAwdFile:String) {
mTotalAssets++;
Parsers.enableAllBundled();
AssetLibrary.enableParser(AWD2Parser);
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETE, onAssetComplete);
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
AssetLibrary.addEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
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);
}
}
}