If the objectcontainer3d doesn't work for you. then I would use a
transformation Matrix. I did something similar for a SphereTree
collision class to orient it to my model. Place all the planes /orient
them how you want. Clone each of their transform at their DEFAULT
ORIGINAL position without any of the rotation(other than to make the
cube) and store it in another transformation matrix called
originalTransform . Create another transformation matrix that is
positioned(translated) at the center of the cube/planes. Now you
rotate your planes with respect to this center transformation matrix
by doing


var quat:Quaternion = MatrixAway3D.eulerToQuaternion(rotationX,
rotationY, rotationZ)
centerTransform.quaternionToMatrix(quat);

plane.transform.multiply4x4(originalTransform, centerTransform);

My code used Number3D's rather than transforms since my spheres aren't
oriented but I think the above is how you do it without a container.
I think the ObjectContainer3D does some weird things such as
autocentering so I decided not to use it since I couldn't figure out
how to turn it off.

On Jan 4, 11:22 am, Ghislain Flandin <[email protected]> wrote:
> Do you have an example of Quaternions use ?
>
> thanks !!!
>
> Ghislain
>
> On Jan 4, 8:19 pm, Michael Iv <[email protected]> wrote:
>
> > use Quaternions ( more Math but very powerful)
>
> > On Mon, Jan 4, 2010 at 8:42 PM, Ghislain Flandin <[email protected]>wrote:
>
> > > I d like not to use applyRotations method but i don't know how to do
> > > without it !!!
>
> > > On Jan 4, 7:13 pm, "Joshua Granick" <[email protected]> wrote:
> > > > What does it do when you use applyRotations like this?
>
> > > > Does it rotate everything as one object, or is it applying the same
> > > rotation to each child object?
>
> > > > Would it work to leave out applyRotations, and simple set the correct
> > > rotation and then render?
>
> > > > On Mon, 04 Jan 2010 10:02:14 -0800, Ghislain Flandin <
> > > [email protected]> wrote:
> > > > > Hello !!!
>
> > > > > Thanks for your answer but i really really need to separate planes ...
> > > > > I ve tried with a Cube primitive ... it works ... i d like to know if
> > > > > there is an easy way to do that !!!
>
> > > > > Thanks again for your help !!!
>
> > > > > On Jan 4, 6:56 pm, "Joshua Granick" <[email protected]> wrote:
> > > > >> Have you tried using away3d.primitives.Cube, or is there a reason why
> > > you need to use seperate planes?
>
> > > > >> On Mon, 04 Jan 2010 09:10:51 -0800, Ghislain Flandin <
> > > [email protected]> wrote:
> > > > >> > Hello guys ... Happy New Year ...
>
> > > > >> > I'm trying to make a 6-planes-cube rotate but i have a problem ...
>
> > > > >> > I used the applyRotations method on the container but the result is
> > > > >> > not good ...
>
> > > > >> > Maybe you can help me ...
>
> > > > >> > Here is the code :
>
> > > > >> > package
> > > > >> > {
> > > > >> >    import away3d.containers.ObjectContainer3D;
> > > > >> >    import away3d.containers.View3D;
> > > > >> >    import away3d.core.base.Vertex;
> > > > >> >    import away3d.core.math.Number3D;
> > > > >> >    import away3d.geom.Explode;
> > > > >> >    import away3d.geom.Mirror;
> > > > >> >    import away3d.materials.ColorMaterial;
> > > > >> >    import away3d.materials.utils.SimpleShadow;
> > > > >> >    import away3d.primitives.Cube;
> > > > >> >    import away3d.primitives.Plane;
> > > > >> >    import away3d.primitives.ReflectivePlane;
> > > > >> >    import away3d.primitives.Sphere;
> > > > >> >    import flash.display.Bitmap;
> > > > >> >    import flash.display.BitmapData;
> > > > >> >    import flash.display.BlendMode;
> > > > >> >    import flash.display.Sprite;
> > > > >> >    import flash.display.StageAlign;
> > > > >> >    import flash.display.StageScaleMode;
> > > > >> >    import flash.events.Event;
> > > > >> >    import flash.events.KeyboardEvent;
> > > > >> >    import flash.filters.BitmapFilterQuality;
> > > > >> >    import flash.filters.BlurFilter;
> > > > >> >    import flash.geom.Matrix;
> > > > >> >    import flash.geom.Rectangle;
> > > > >> >    import flash.text.TextField;
> > > > >> >    import gs.TweenMax;
>
> > > > >> >    public class Main extends View3D
> > > > >> >    {
> > > > >> >            private var container:ObjectContainer3D;
> > > > >> >            private var planes:Array;
>
> > > > >> >            public function Main():void
> > > > >> >            {
> > > > >> >                    if (stage) init();
> > > > >> >                    else addEventListener(Event.ADDED_TO_STAGE,
> > > init);
> > > > >> >            }
>
> > > > >> >            private function init(e:Event = null):void
> > > > >> >            {
> > > > >> >                    removeEventListener(Event.ADDED_TO_STAGE, init);
>
> > > > >> >                    //stage setup
> > > > >> >                    stage.scaleMode = StageScaleMode.NO_SCALE;
> > > > >> >                    stage.align = StageAlign.TOP_LEFT;
>
> > > > >> >                    //position setup
> > > > >> >                    x = this.stage.stageWidth / 2;
> > > > >> >                    y = this.stage.stageHeight / 2;
>
> > > > >> >                    //camera setup
> > > > >> >                    camera.x = 300;
> > > > >> >                    camera.z = -900;
> > > > >> >                    camera.y = 100;
>
> > > > >> >                    //planes'array
> > > > >> >                    planes = new Array();
>
> > > > >> >                    //containers instances
> > > > >> >                    container = new ObjectContainer3D();
> > > > >> >                    for (var i:int = 0; i < 6; i+=1)
> > > > >> >                            {
> > > > >> >                            var col:uint = Math.random() * 0xFFFFFF;
> > > > >> >                            var mat:ColorMaterial = new
> > > ColorMaterial(col);
> > > > >> >                            var p:Plane = new Plane({ width:100,
> > > height:100, material:mat,
> > > > >> > segmentsW:8, segmentsH:8,bothsides:true } );
>
> > > > >> >                            if (i == 0)
> > > > >> >                                    {
> > > > >> >                                    p.z = -50;
> > > > >> >                                    p.rotationX = 90;
> > > > >> >                                    }
> > > > >> >                            if (i == 1)     p.y = 50;
> > > > >> >                            if (i == 2)
> > > > >> >                                    {
> > > > >> >                                    p.z = 50;
> > > > >> >                                    p.rotationX = 90;
> > > > >> >                                    }
> > > > >> >                            if (i == 3) p.y = -50;
> > > > >> >                            if (i == 4)
> > > > >> >                                    {
> > > > >> >                                    p.x = 50;
> > > > >> >                                    p.rotationX = 90;
> > > > >> >                                    p.rotationY = 90;
> > > > >> >                                    }
> > > > >> >                            if (i == 5)
> > > > >> >                                    {
> > > > >> >                                    p.x = -50;
> > > > >> >                                    p.rotationX = 90;
> > > > >> >                                    p.rotationY = 90;
> > > > >> >                                    }
> > > > >> >                            container.addChild(p);
> > > > >> >                            planes.push(p);
> > > > >> >                            }
> > > > >> >                    //scene feed
> > > > >> >                    scene.addChild(container);
>
> > > > >> >                    camera.lookAt(new Number3D());
>
> > > > >> >                    //handlers
> > > > >> >                    addEventListener(Event.ENTER_FRAME, enterFrame,
> > > false, 0, true);
> > > > >> >                    stage.addEventListener(KeyboardEvent.KEY_UP,
> > > onPressKey, false, 0,
> > > > >> > true);
> > > > >> >            }
>
> > > > >> >            private function onPressKey(e:KeyboardEvent):void
> > > > >> >                    {
> > > > >> >                    switch(e.keyCode)
> > > > >> >                            {
> > > > >> >                            case 37: //left
> > > > >> >                                    TweenMax.to(container, 0.3, {
> > > rotationY:"-90",
> > > > >> > onComplete:rotationComplete,onCompleteParams:["y",-90],
> > > > >> > overwrite:false } );
>
> > > > >> >                                    break;
>
> > > > >> >                            case 39: //right
> > > > >> >                                    TweenMax.to(container, 0.3, {
> > > rotationY:"90",
> > > > >> > onComplete:rotationComplete,onCompleteParams:["y",90],
> > > > >> > overwrite:false } );
> > > > >> >                                    break;
>
> > > > >> >                            case 38: //up
> > > > >> >                                    TweenMax.to(container, 0.3, {
> > > rotationX:"-90",
> > > > >> > onComplete:rotationComplete,onCompleteParams:["x",-90],
> > > > >> > overwrite:false } );
> > > > >> >                                    break;
>
> > > > >> >                            case 40: //down
> > > > >> >                                    TweenMax.to(container, 0.3, {
> > > rotationX:"90",
> > > > >> > onComplete:rotationComplete,onCompleteParams:["x",90],
> > > > >> > overwrite:false } );
> > > > >> >                                    break;
> > > > >> >                            }
> > > > >> >                    }
> > > > >> >            private function
> > > rotationComplete(rotation:String,angle:Number):void
> > > > >> >                    {
> > > > >> >                    container.applyRotations();
> > > > >> >                    }
> > > > >> >            private function enterFrame(e:Event):void
> > > > >> >                    {
> > > > >> >                    var diffX:Number = (this.stage.mouseX -
> > > Math.round
> > > > >> > (this.stage.stageWidth / 2)) / Math.round(this.stage.stageWidth /
> > > 2);
> > > > >> >                    var diffY:Number = (this.stage.mouseY -
> > > Math.round
> > > > >> > (this.stage.stageHeight/ 2)) / Math.round(this.stage.stageHeight /
> > > 2);
> > > > >> >                    render();
>
> ...
>
> read more »

Reply via email to