Need help on pivot around a point. I want all cube rotate around this
'cube'. Not sure how to pivot it. This away3d version is 3.3.3 flash
player 10. This deal with vertex point.

package
{
        //{
    import away3d.containers.View3D;
        import away3d.core.base.Object3D;
        import away3d.core.math.MatrixAway3D;
        import away3d.core.math.Number3D;
        import away3d.primitives.Cube;
    import flash.display.Sprite;
        import flash.events.Event;
    //}

        [SWF(width="464", height="464", backgroundColor="#FFFFFF",
frameRate="30")]
    public class Away3DMatrixRotatePivot2 extends Sprite
    {
                // create a viewport
                public var view:View3D = new View3D( { x:200, y:200 } );
                public var cube:Cube = new Cube( { width:8, height:8, depth:8 } 
);
                public var cube1:Cube = new Cube( { width:8, height:8, depth:8 
} );
                public var cube2:Cube = new Cube( { width:8, height:8, depth:8 
} );
                public var cube3:Cube = new Cube( { width:8, height:8, depth:8 
} );
                public var cube4:Cube = new Cube( { width:8, height:8, depth:8 
} );

        public function Away3DMatrixRotatePivot2(){
            addChild(view);
                        view.camera.y = 100;
                        view.camera.z = 100;
                        view.camera.lookAt(new Number3D(0, 0, 0));
                        addEventListener(Event.ENTER_FRAME, render);
                        cube.x = 0;
                        cube.z = 16;
                        view.scene.addChild(cube);
                        cube1.x = -16;
                        cube1.z = 16;
                        view.scene.addChild(cube1);
                        cube2.x = 16;
                        cube2.z = 16;
                        view.scene.addChild(cube2);
                        cube3.x = 16;
                        cube3.z = -16;
                        view.scene.addChild(cube3);
                        cube4.x = -16;
                        cube4.z = -16;
                        view.scene.addChild(cube4);
        }

                public function render(event:Event):void {
                        rotate(cube);
                        rotate(cube1);
                        rotate(cube2);
                        rotate(cube3);
                        rotate(cube4);
                        view.render();
                }

                public function rotate(mesh:Object3D):void {
                        var pointv:Number3D = new Number3D(mesh.x, mesh.y, 
mesh.z);
                        var mat:MatrixAway3D = new MatrixAway3D();
                        mat.rotationMatrix(0, 1, 0, 0.05);
                        pointv.transform(pointv, mat);
                        mesh.x = pointv.x;
                        mesh.y = pointv.y;
                        mesh.z = pointv.z;

                }
    }
}

Reply via email to