ok it is starting to make some sense now...
in regards to the path animation and rotations... perhaps this will
clarify what i am trying to do
1. generate a random path for the car to follow ... this is simple,
just a series of Number3D points (for instance a road)
2. pass generated path to pathanimation
so i cannot do the rotations by hand ... these need to be setup
dynamically on the fly and then passed to the rotations.
then, if the series define a curve (not a straight line), i need to
calculate direction using either Atan2(), Catmull - Rom (splines), or
something else (i'm open to suggestions, these are just what books and
other people have been telling me). For instance...this from another
forum--
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
"In general terms, the direction the car is pointing is along its
velocity vector, which is the first derivative of its position vector.
For example, if the car is going in a circle (of radius r) around the
origin every n seconds then the x component of the car's position is
given by:
x = r.sin(2πt/n)
and the x component of its velocity vector will be:
vx = dx/dt = r.(2π/n)cos(2πt/n)
Do this for all of the x, y and z components, normalize the resulting
vector and you have your direction."
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
^^ Do you have some insight has to how that formula can be applied
with a path animator, or should i set up a custom tween/animation?
On Nov 16, 1:37 pm, Fabrice <[EMAIL PROTECTED]> wrote:
> The rotations property is an array of number3D's, each one is the
> representation of the rotation for the animated object along the path
> at the start of a CurveSegment.
> but since you use the align to path, you have only one axis free. 2
> others being used by the code.
>
> so say you have 2 curveSegments defined and want your object align on
> path and having a rotation arround the path direction.
> rotations property would be for instance
>
> var a:Array = [new Number3D(20, 0,0), new Number3D(-20, 0,0), new
> Number3D(0, 0,0) ];
> rotations = a;
>
> so your object will start align to path with a 20, in middel at -20
> and will exit the path with ) rotation.
>
> The reason it might look like its a Z rotation while its a X one, is
> the direct result of the way you define your path.
> One path going in z would be affected another way than a path define
> along the x axis.
> That's why the Path has a WorldAxis property.
>
> to rotate your model if its sidewards, use first
> model.rotationY = 90;
> (model as Mesh).applyRotations();
>
> now its pointing on the path using the pathanimator. And it has
> nothing to do with the rotations applied while its animated.
> Its a rotation at mesh level.
>
> also not that in some cases, changing of world quadrants can also
> influence the behavior. To avoid those, just be sure your path
> definition gets an offset big enough
> to stay within one quadrant. mmm I stop now, don't want to confuse
> you :)
>
> Fabrice
>
> On Nov 16, 2008, at 5:43 PM, cellis wrote:
>
>
>
> > Hey fabrice,
>
> > i tried passing
>
> > rotations:[90,90,90]; //to the path Data, but i'm not sure it
> > worked...
>
> > i'm not quite sure of the syntax to use here: should it be an
> > anonymous object?
>
> > could you please post an example of a path data object declared? here
> > is mine
>
> > var animInit:Object =
> > {
> > duration:5000,
> > lookat:false,
> > aligntopath:true,
> > targetobject:null,
> > offset:new Number3D(0, 100, 0),
> > rotations:[90,90,90],
> > fps:30,
> > easein:false,
> > easeout:false
> > }
>
> > Again, thanks alot!
>
> > On Nov 15, 11:16 am, Fabrice <[EMAIL PROTECTED]> wrote:
> >> Sure you can,
>
> >> just say
> >> object.rotationY = 90; //--> or whatever is needed
> >> then
> >> (object as Mesh).applyRotations();//rotates internally the mesh
> >> geometry
> >> //--> rotationY is now back to zero if you trace, while your mesh is
> >> remains rotated on the Y axis
>
> >> the rotations property on the PathAnimator are there to allow to have
> >> rotations along the path.
> >> say you have an aircraft, you define a path that goes from air to
> >> ground where you want it crash.
> >> when align to path prop is set the aircraft would point at the path
> >> direction.
> >> but if you want the aircraft has also some roll influence while
> >> following the path, just pass a rotations array, a series of
> >> Number3d,
> >> acting per CurveSegments
> >> the Number3d are representing in this case the rotational influence
> >> (rotx, roty, rotz). they are applyed or a linear fashion between
> >> start
> >> and end of the segments.
> >> if less Number3D's are passed than the length of the path, the last
> >> influence is kept until the end of the path.
>
> >> Note that it can work pretty confusing, so I suggest you start with
> >> just 2 segments and play,
> >> best way would be to comment all other segments into your path
> >> definition, then gradually add rotations and path segments.
>
> >> Fabrice
>
> >> On Nov 15, 2008, at 4:41 PM, cellis wrote:
>
> >>> Awesome!
>
> >>> That worked Fabrice.
>
> >>> Now i have another problem and i'm not sure if i have to bust out
> >>> the
> >>> trig for this. My object animates along the path, but doesn't
> >>> point in
> >>> that direction. For instance if it was a Car object, instead of
> >>> looking like it is driving forward on that path, it looks instead
> >>> like
> >>> it is drifting along the path. Are there any built in functions for
> >>> this or do i have to do the rotation by hand?
>
> >>> I was unsure as to how to use the rotations property on the path
> >>> data...
>
> >>> Thanks alot!
>
> >>> On Nov 15, 7:14 am, Fabrice <[EMAIL PROTECTED]> wrote:
> >>>> I've posted a tutorial on this a few days ago...
>
> >>>>http://away3d.com/tutorials/tutorial-how-to-use-the-pathanimator-
> >>>> class
>
> >>>> More are coming on how to mixe this class with other Path based
> >>>> classes.
> >>>> So keep an eye on the tutorial section at away3d.com.
>
> >>>> Fabrice
>
> >>>> On Nov 15, 2008, at 10:21 AM, paullaster wrote:
>
> >>>>> Wanted to post this helpful doc about PathAnimator to the Google
> >>>>> group community.