May be you should ask at StackOverflow.com ? ;) ( just kidding )

Sent from my iPhone

On Apr 17, 2011, at 2:22 AM, Leo <[email protected]> wrote:

> base class:
> //////////////////////////
> /////////////////////////
> package  {
>    import flash.display.Sprite;
>    import away3d.containers.View3D;
>    import away3d.cameras.HoverCamera3D;
>    import flash.events.Event;
> 
>    public class Chapter07SampleBase extends Sprite {
>        protected var _view:View3D;
>        protected var _camera:HoverCamera3D;
> 
>        public function Chapter07SampleBase() {
>            _createView();
>            _createScene();
>        }
> 
>        protected function _createView():void
>        {
>            _camera = new HoverCamera3D();
>            _camera.distance = 1000;
>            _camera.tiltAngle = 10;
>            _camera.panAngle = 180;
>            _view = new View3D();
>            _view.x = 400;
>            _view.y = 300;
>            _view.camera = _camera;
> 
>            addChild(_view);
>            addEventListener(Event.ENTER_FRAME, _onEnterFrame);
>        }
> 
>        protected function _createScene():void
>        {
>            var pyramid:Pyramid = new Pyramid();
>            pyramid.width = 200;
>            pyramid.height = 200;
>            _view.scene.addChild(pyramid);
>        }
> 
>        protected function _onEnterFrame(ev:Event):void
>        {
>            _camera.panAngle -= (stage.mouseX - stage.stageWidth/2)/100;
>            _camera.hover();
>            _view.render();
>        }
> 
>    }
> }
> ////////////////////////////
> // Custom Primitive Class
> ///////////////////////////
> package
> {
>    import away3d.arcane;
>    import away3d.primitives.AbstractPrimitive;
>    import away3d.core.base.Vertex;
> 
>    use namespace arcane;
> 
>    public class Pyramid extends AbstractPrimitive
>    {
>        private var _height:Number;
>        private var _width:Number;
>        private var _depth:Number;
> 
>        public function Pyramid(init:Object = null)
>        {
>            super(init);
>            buildPrimitive();
>            _height = ini.getNumber('height', 180, {min: 1});
>            _width = ini.getNumber('width', 180, {min: 1});
>            _depth = ini.getNumber('depth', 180, {min: 1});
>        }
>        /////////////////////////////////
>        // getters and setters
>        /////////////////////////////////
>        public function get width():Number
>        {
>            return this._width;
>        }
> 
>        public  function set width(val:Number):void
>        {
>            if (this._width == val) return;
>            this._width = val;
>            _primitiveDirty = true;
>        }
>        /////////////////////////////////
>        public function get height():Number
>        {
>            return this._height;
>        }
> 
>        public  function set height(val:Number):void
>        {
>            if (this._height == val) return;
>            this._height = val;
>            _primitiveDirty = true;
>        }
>        /////////////////////////////////
>        public function get depth():Number
>        {
>            return this._depth;
>        }
> 
>        public  function set depth(val:Number):void
>        {
>            if (this._depth == val) return;
>            this._depth = val;
>            _primitiveDirty = true;
>        }
>        /////////////////////////////
>        // end getter and setters
>        ////////////////////////////
>        protected override function buildPrimitive():void
>        {
>            var a:Vertex = createVertex(0, _height/2, 0);
>            var b:Vertex = createVertex(-_width/2, -_height/2, _depth/2);
>            var c:Vertex = createVertex(_width/2, -_height/2, _depth/2);
>            var d:Vertex = createVertex(_width/2, -_height/2, -_depth/2);
>            var e:Vertex = createVertex(-_width/2, -_height/2, _depth/2);
>            addFace(createFace(a, c, b));
>            addFace(createFace(a, d, c));
>            addFace(createFace(a, e, d));
>            addFace(createFace(a, b, e));
>            addFace(createFace(b, d, e));
>            addFace(createFace(b, c, d));
>        }
> 
>    }
> }

Reply via email to