do you update in enterframe your animation?
> the only example I have seen is the Minotaur in the labyrinth
Prefab does it (you can preview md2 animation following your path) and so does 
Away 3.5 and 3.6

Fabrice

On Feb 1, 2011, at 9:33 AM, bandy wrote:

> The error I was getting when using the PathAnimator with an animated
> md2 disappeared when the class was transferred to from 3.5 to 3.6. The
> md2 now glides around on the Path, but it does not execute its own
> animation, it is still. (The only way I can get it to change locations
> while animating is to change its x,y or z values in the Enterframe. )
> 
> Can someone say that they are able to do get an animated md2 to simply
> follow a Path using PathAnimator while still animating? The only
> example I have seen is the Minotaur in the labyrinth by Fabrice from a
> Extrude demo but that is using an old away3d version. I have used all
> sorts of combinations of classes exported from Prefab, different
> md2's, scene.updateTime, different methods to update the PathAnimator.
> Funnily, I see nothing on this subject anywhere, whereas I would have
> thought it would be the obvious thing to try to do before trying
> advanced character control. Is it because of limited usefulness that
> nobody is interested? Thanks for any help.
> 
> On Jan 27, 8:43 pm, bandy <[email protected]> wrote:
>> Thanks, I'll do so
>> 
>> On Jan 27, 8:22 pm, Fabrice3D <[email protected]> wrote:
>> 
>> 
>> 
>>> I do not have the time to test your code atm, but looking at your code, I 
>>> see few glitches...
>> 
>>> You feed the Path with Number3D's while its supposed to be Vector3D
>>> same applies to your init object where offset is as Number3D instead of 
>>> Vector3D
>>> property aligntoPath should be alignToPath.
>>> The jpg embed, why is it static?
>> 
>>> aside your main problem I do see lines such as  horseMesh = new Mesh();
>>> and next like its equal to the handle.
>> 
>>> if (_keyLeft) {_view.camera.x -= 
>>> 15*Math.cos(_view.camera.rotationY*Math.PI/180);
>>> don't you want to use moveLeft, moveRight here?
>> 
>>> I think you should clean up/check your code a bit first...
>>> then comment most of it, inclusif your mouse behaviours
>>> keep just view, camera and enterframe.
>> 
>>> first load and addchild the mesh, if no errors,
>>> generate material and asign to model, if ok
>>> generate Path object, if ok
>>> generate animator, if ok
>>> then start the animation update.
>>> if something move as expected, then add complexity with mouseEvents etc..
>> 
>>> if you proceed step wize like this, you will spare yourself headackes...
>> 
>>> Fabrice
>> 
>>> On Jan 27, 2011, at 8:12 AM, bandy wrote:
>> 
>>>> Fabrice, thank you for the reply. I did as you suggested and combined
>>>> the initPathAnimation code and the onModelLoaded method into one
>>>> method like below, but get
>>>> Error from ZoomFocusLens?
>> 
>>>> Error: isNaN(sz)
>>>>    at away3d.cameras.lenses::ZoomFocusLens/project()[C:\Users\admin
>>>> \Adobe Flash Builder 4\CITYWALKTHROUGH\src\away3d\cameras\lenses
>>>> \ZoomFocusLens.as:106]
>>>>    at away3d.core.project::MeshProjector/primitives()[C:\Users\admin
>>>> \Adobe Flash Builder 4\CITYWALKTHROUGH\src\away3d\core\project
>>>> \MeshProjector.as:152]
>>>>    at away3d.core.traverse::PrimitiveTraverser/apply()[C:\Users\admin
>>>> \Adobe Flash Builder 4\CITYWALKTHROUGH\src\away3d\core\traverse
>>>> \PrimitiveTraverser.as:103]
>>>>    at away3d.core.base::Object3D/traverse()[C:\Users\admin\Adobe Flash
>>>> Builder 4\CITYWALKTHROUGH\src\away3d\core\base\Object3D.as:1596]
>>>>    at away3d.containers::ObjectContainer3D/traverse()[C:\Users\admin
>>>> \Adobe Flash Builder 4\CITYWALKTHROUGH\src\away3d\containers
>>>> \ObjectContainer3D.as:353]
>>>>    at away3d.containers::View3D/render()[C:\Users\admin\Adobe Flash
>>>> Builder 4\CITYWALKTHROUGH\src\away3d\containers\View3D.as:964]
>>>>    at testpath/onEnterFrame()[C:\Users\admin\Adobe Flash Builder
>>>> 4\CITYWALKTHROUGH\src\testpath.as:211]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> .
>> 
>>>> Profuse apologies that this is elementary, but you said I should only
>>>> declare something when I am sure it is fully loaded. The onModelLoaded
>>>> method is only run when the
>>>> Loader3DEvent.LOAD_SUCCESS is fired, (and the md2 loads fine before
>>>> trying to add it to the pathAnimator). Should I be checking if the
>>>> pathAnimator is loaded? ( I haven't seen code doing that).
>> 
>>>> Code with  initPathAnimation code and the onModelLoaded method
>>>> combined, as suggested by you:
>> 
>>>> package
>>>> {
>>>>    import away3d.animators.PathAnimator;
>>>>    import away3d.animators.VertexAnimator;
>>>>    import away3d.cameras.Camera3D;
>>>>    import away3d.containers.ObjectContainer3D;
>>>>    import away3d.containers.Scene3D;
>>>>    import away3d.containers.View3D;
>>>>    import away3d.core.base.Mesh;
>>>>    import away3d.core.base.Object3D;
>>>>    import away3d.core.geom.*;
>>>>    import away3d.core.geom.Path;
>>>>    import away3d.core.math.*;
>>>>    import away3d.events.Loader3DEvent;
>>>>    import away3d.loaders.Loader3D;
>>>>    import away3d.loaders.Md2;
>>>>    import away3d.loaders.utils.AnimationLibrary;
>>>>    import away3d.materials.*;
>>>>    import away3d.primitives.Cube;
>>>>    import away3d.primitives.Plane;
>>>>    import away3d.primitives.Sphere;
>>>>    import away3d.primitives.Torus;
>> 
>>>>    import flash.display.*;
>>>>    import flash.events.*;
>>>>    import flash.geom.Point;
>>>>    import flash.utils.getTimer;
>> 
>>>>    [SWF(backgroundColor="#cccccc", frameRate="60", quality="LOW",
>>>> width="800", height="600")]
>>>>    public class testpath extends Sprite
>>>>    {
>>>>            [Embed(source="assets/dolphin_f.jpg" )]
>>>>            private static var horse:Class;
>> 
>>>>            private var scene:Scene3D;
>>>>            private var _view:View3D;
>>>>            private var cam:Camera3D;
>>>>            private var m_modelMaterial:BitmapFileMaterial;
>> 
>>>>            private var traveller:Object3D;
>>>>            private var travellerCont:ObjectContainer3D;
>>>>            private var horsePath:Path;
>> 
>>>>            private var _scrub:Boolean = false;
>> 
>>>>            private var _lastPoint:Point = new Point();
>> 
>>>>            private var horseMesh:Mesh;
>>>>            private var time:Number = 0;
>> 
>>>>            private var pathAnimator:PathAnimator;
>> 
>>>>            public function testpath(): void
>>>>            {
>>>>                    initEngine();
>> 
>>>>                    loadModel();
>>>>                    //initAnimations();
>>>>                    initListeners();
>> 
>>>>            }
>> 
>>>>            private function initEngine():void{
>>>>                    cam = new Camera3D();
>>>>                    ///cam.focus = 100;
>>>>                    //cam.zoom = 10;
>>>>                    //cam.x = 1000;
>>>>                    //cam.y = 200;
>>>>                    cam.z = -2000;
>>>>                    _view = new View3D();
>>>>                    _view.x = 400;
>>>>                    _view.y = 300;
>>>>                    scene = new Scene3D();
>>>>                    _view.scene = scene;
>>>>                    _view.camera = cam;
>> 
>>>>                    cam.lookAt(scene.position);
>> 
>>>>                    addChild(_view);
>> 
>>>>            }
>> 
>>>>            private function loadModel():void
>>>>            {
>>>>                    m_modelMaterial = new 
>>>> BitmapFileMaterial("assets/dolphin_f.jpg");
>> 
>>>>                    var loader:Loader3D = new Loader3D();
>>>>                    var md2:Md2 = new Md2();
>>>>                    md2.scaling = 8;
>>>>                    md2.material = m_modelMaterial;
>> 
>>>>                    loader.loadGeometry("assets/dolphin.md2", md2);
>> 
>>>>                    
>>>> loader.addEventListener(Loader3DEvent.LOAD_SUCCESS,onModelLoaded);
>>>>                    //scene.addChild(loader);
>>>>            }
>> 
>>>>            private function onModelLoaded(event:Loader3DEvent):void
>>>>            {
>>>>                    horseMesh = new Mesh();
>>>>                    horseMesh = event.loader.handle as Mesh ;
>>>>                    trace((horseMesh ).geometryLibrary);
>>>>                    var animdata:AnimationLibrary = 
>>>> horseMesh.animationLibrary;
>>>>                    var myAnim:VertexAnimator = 
>>>> animdata.getAnimation("jump").animator
>>>> as VertexAnimator;
>>>>                    myAnim.delay = 0;
>>>>                    myAnim.loop = true;
>>>>                    myAnim.fps = 5;
>>>>                    myAnim.interpolate = true;
>>>>                    myAnim.play();
>>>>                    //mesh.sortFaces = true;
>>>>                    //horseCont = new ObjectContainer3D(horseMesh);
>>>>                    horseMesh.z = 5000;
>> 
>>>>                    _view.scene.addChild(horseMesh);
>>>>                    var objectPath:Array = new Array();
>> 
>>>>                    objectPath.push(new Number3D(-2000, 200, 0), new 
>>>> Number3D(0, -400,
>>>> 600), new Number3D(2000, 200, 0));
>>>>                    objectPath.push(new Number3D(2000, 200, 0), new 
>>>> Number3D(0, 0,
>>>> -300), new Number3D(6000, 1500, 0));
>>>>                    objectPath.push(new Number3D(6000, 1500, 0), new 
>>>> Number3D(10000,
>>>> 1000, -600), new Number3D(16000, 700, 0));
>> 
>>>>                    //create the path object to be used again for the path 
>>>> animator
>>>>                    horsePath = new Path(objectPath);
>>>>                    //path = new HorsePath1();
>> 
>>>>                    var init:Object = {aligntoPath:true, offset:new 
>>>> Number3D(0,200,0),
>>>> rotations:null, fps:24, easein:false, easeout:false}
>>>>                    pathAnimator = new PathAnimator(horsePath, horseMesh , 
>>>> init);
>> 
>>>>            }
>> 
>>>>    private function initListeners():void
>>>>    {
>>>>            addEventListener( Event.ENTER_FRAME, onEnterFrame);
>>>>            stage.addEventListener(Event.RESIZE, onResize);
>>>>            stage.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
>>>>            stage.addEventListener(MouseEvent.MOUSE_UP,_onMouseUp);
>>>>            stage.addEventListener(MouseEvent.MOUSE_OUT, _onMouseLeave);
>>>>            onResize();
>>>>    }
>> 
>>>>    private function onResize(event:Event = null):void
>>>>    {
>>>>            _view.x = stage.stageWidth / 2;
>>>>            _view.y = stage.stageHeight / 2;
>>>>            //SignatureBitmap.y = stage.stageHeight - Signature.height;
>>>>    }
>> 
>>>>            /*private function initAnimations():void
>>>>            {
>> 
>>>>    
>> 
>> ...
>> 
>> read more ยป- Hide quoted text -
>> 
>> - Show quoted text -

Reply via email to