it does... trace before the rotationY and after you apply...
//-->90
//-->0
on screen indeed you see no difference, but all the vertexes are rotated in the Mesh space.

for exports,
if you export only one mesh, you can use the Mesh to as3 handler
if you export one mesh with animated mesh, like a md2, use the mesh to as3 handler with animated boolean set to true
if you want export whole object3D or mesh use the AS3Exporter
at this time of development, the As3Exporter do not support animated mesh and bones.

to export
just onLoaderSucess(event.LoaderEvent)

new AS3Exporter(event.handle, "MyClassname", "mypackage");
open a texteditor, paste and save as MyClassname.as

to loadback,
just import mypackage.MyClassname;

[..code..]

var meshholder: MyClassName =  new MyClassName(view.scene);
var mymesh:Mesh = meshholder.meshes[0];

Note that the as3exporter output is not an object3D, its more like a dataHolder. So you do not attach it, it reproduces, addChild everything you have exporter with the exception of the material information, while If you use the Mesh to as3 exporter you will need to addChild the class, since its a Mesh extend.


Fabrice
On Nov 30, 2008, at 12:16 AM, cellis wrote:


        private function rotateMeshY90(object3d:Object3D, angle:Number=
90):void
                {
                        if (object3d is ObjectContainer3D)
                        {
                                trace("no mesh");
                                var obj:ObjectContainer3D = (object3d as 
ObjectContainer3D);

                                for (var i:int = 0; i < obj.children.length; 
i++)
                                {
                                        if (obj.children[i] is 
ObjectContainer3D)
                                        {
                                                trace("no mesh");
                                                rotateMeshY90(obj.children[i]);
                                        }
                                        else
                                        {
                                                (obj.children[i] as 
Mesh).rotationY = angle;
                                                (obj.children[i] as 
Mesh).applyRotations();
                                        }
                                }
                        }
                        else
                        {
                                trace("found some mesh!");
                                (obj.children[i] as Mesh).rotationY = angle;
                                (obj.children[i] as Mesh).applyRotations();
                        }
                }

Ok, i tried this... didn't seem to change the rotational property at
all... however i was able to fix the 'sideways' problem by reexporting
a reoriented (perpendicular) angle.

Do you think if i saved the ObjectContainer3D from Collada to AS3 i
would be able to use the class as a mesh?

On Nov 29, 1:49 pm, Fabrice <[EMAIL PROTECTED]> wrote:
thats because its not a mesh, but an Object3d of type ObjectContainer3D.
The error is generated because the ObjectContainer do not have
vertexes and no geometry property. One of the two triggers that error.
Its a Mesh class method.

If the first child is indeed of type Mesh...

try:
this.Model.children[0].rotationY = 90;
this.Model.children[0].applyRotations();

if you need to automate, look at Mirror class or ObjExporter loop...
There are similar codes in there....

Fabrice

On Nov 29, 2008, at 6:22 PM, cellis wrote:



Ok it appears to be working that way, however i am not able to say
(Model as Mesh).applyRotations(); ... it throws an null reference
error because (Model as Mesh) returns null:

private function onLoaderSuccess(event:LoaderEvent):void
           {

this.Model = event.loader.handle as ObjectContainer3D;
                           this.Model.rotationY = 90;
(this.Model as Mesh).applyRotations();
                   trace(this.Model.rotationY);
                   initAnimations();

           }

is there a reason for this? I also tried it in the enterFrame event ,
with the same result.

On Nov 29, 10:46 am, Fabrice <[EMAIL PROTECTED]> wrote:
well, thats because you say to lookat but pass a null targetobject
and
you say to the PathAnimator to set the aligntopath to true.
so by default the class asumes you just want to move an item along
the
path without altering its orientation.
because you can't look at something and align to path at the same
time.

http://away3d.com/tutorials/tutorial-how-to-use-the-pathanimator-
class
take a closer look at the examples at the end of the tut.

Fabrice

On Nov 29, 2008, at 3:48 PM, cellis wrote:

Hey fabrice,

I have an example uploaded of what i'm trying to do.

http://away3d-dev.googlegroups.com/web/Applied3DGameProject.zip?gda=p
...

feel free to edit the points as you like. Basically the dog (thanks
Katopz!) doesn't point in the direction of motion.

Do you see what i mean now?

On Nov 22, 5:33 am, Fabrice <[EMAIL PROTECTED]> wrote:
I understand you want the car ispathdriven but I'm not sure I
have a
clear picture of what you want the car be able to do.
There are tons of options, but here a few directions that might
help
you.

Say you want it stays free, yet within the bounderies of the road,
witch is defined by thepath.

1/ to use a container or a dummy object. they are driven by
thepath.
in container case, the car would be in  it.
2/ just define a distance. then when you move the car just check
the
distance from the car to the dummy or container position.

this allows you to check direction, like for instance "you're going wrong way", you just need to compare pathanimator.time with actual
time.
the increase the time, just make your acceleration angular, based
on
the rotations of the object into the container. since the container
is  pathdriven with an align topath,
the direction vector is equal to the rotations props of the
container.

you can also, if your road is not pathextruded, just ask positions
based on time and apply the result to your object.
getPositionOnPath( p:Number3D, t:Number). But here you miss indeed
the
directional vector. I will add a getter for the directional vector.
It
will return the last generated one of the animated object.
if you want to do it yourself just save the vector in the
orientateAt
handler.

Say now that you want car to follow a randompath. define just 3
segments.
add a segmentListener.
on event, just calculate a radius from actual object position, set
first segment end to a random angle based on that radius.
then push(shift) thepathinfo, smoothpath. If done right, thepath
should "scroll" itself under the car.

if the car just drives arround and you want to save power by not
recalculating a new segment each event, just pop shift thepathinfo,
and give a longerpathdefinition with enough variation.

Hope it helps a bit.

Fabrice

On Nov 22, 2008, at 9:38 AM, cellis wrote:

ok it is starting to make some sense now...

in regards to thepathanimation and rotations... perhaps this will
clarify what i am trying to do

1. generate a randompathfor the car to follow ... this is simple,
just a series of Number3D points (for instance a road)
2. pass generatedpathto 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 apathanimator, 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
thepath
at the start of a CurveSegment.
but since you use the align topath, 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
pathand having a rotation arround thepathdirection.
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 topathwith a 20, in middel at -20
and will exit thepathwith ) 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 yourpath.
Onepathgoing in z would be affected another way than apathdefine
along the x axis.
That's why thePathhas a WorldAxis property.

to rotate your model if its sidewards, use first
model.rotationY = 90;
  (model as Mesh).applyRotations();

now its pointing on thepathusing 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 yourpath
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 thepathData, 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 apathdata 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 thepath.
say you have an aircraft, you define apaththat goes from air to
ground where you want it crash.
when align topathprop is set the aircraft would point at
thepath
direction.
but if you want the aircraft has also some roll influence while
following thepath, just pass a rotations array, a series of
Number3d,
acting per CurveSegments

...

read more »

Reply via email to