Away3d 4.0-4.1 Tianji HD car case analysis away3d 4.0.9gold learning notes camera and camera controller (7)

Source: Internet
Author: User

Away3d 4.1 Alpha tutorial Model <1> full analysis of away3d 4.0 Tianji high definition car Cases

 

 

 

1. Full Analysis of garage

 

Package objects3d. environments {import away3d. containers. objectcontainer3d; import away3d. entities. mesh; import away3d. events. assetevent; import away3d. library. assets. assettype; import away3d. lights. directionallight; import away3d. loaders. loader3d; import away3d. materials. texturematerial; import away3d. materials. lightpickers. staticlightpicker; import away3d. materials. methods. terraindiffusemethod; import away3d. primitives. planegeometry; import away3d. textures. bitmaptexture; public class garage extends objectcontainer3d {[embed (Source = "Garage/floormap.jpg")] private var floormapasset: Class; [embed (Source = "Garage/garagemap.jpg")] private var garagemapasset: Class; [embed (Source = "Garage/floorshadowmap.png", mimetype = "image/PNG")] private var floorshadowmapasset: class; [embed (Source = "Garage/garage.3ds", mimetype = "application/octet-stream")] private var garageasset: Class; private var garagemesh: mesh; private var floormesh: mesh; private var floorshadowmesh: mesh; Public Function garage (param1: directionallight = NULL) {var floormaptexture: bitmaptexture = new bitmaptexture (New this. floormapasset (). bitmapdata); var floormap: texturematerial = new texturematerial (floormaptexture, true, true); // texture, smooth, repeated floormap. specular = 1; // reflection floormap. lightpicker = new staticlightpicker ([param1]); // map to pick up the floormap. diffusemethod = new terraindiffusemethod ([floormaptexture], new bitmaptexture (New this. floorshadowmapasset (). bitmapdata), [10]); // Add a concave/convex texture var floorshadow: texturematerial = new texturematerial (New bitmaptexture (New this. floorshadowmapasset (). bitmapdata); // creates a shadow texture PNG floorshadow. alpha = 0.9; this. floormesh = new mesh (New planegeometry (3800,380 0), floormap); // create a ground surface and paste the ground texture generated above this. floormesh. y =-238; this. floormesh. rotationy =-95; this. floorshadowmesh = new mesh (New planegeometry (3800,380 0), floorshadow); // create a shadow patch and paste the shadow texture PNG this. floorshadowmesh. y =-237; // place the shadow patch on the ground. This. floorshadowmesh. rotationy =-95; var garageloader: loader3d = new loader3d (); // instance model loader garageloader. addeventlistener (assetevent. asset_complete, this. complete); garageloader. loaddata (New this. garageasset (), null, null); super. addchildren (this. floormesh, this. floorshadowmesh);} private function complete (Event: assetevent): void {If (event. asset. assettype = assettype. mesh) {garagemesh = event. asset as mesh; // converts the model to garagemesh. material = new texturematerial (New bitmaptexture (New this. garagemapasset (). bitmapdata), true); // map garagemesh to the loaded model. roll (180); // rotate around 180 degrees garagemesh. geometry. scale (3); super. addchild (this. garagemesh); super. y = 188 ;}}}}

 

2. Camera Control orbitcontrollerextended.

In fact, camera control is what I previously sorted out.

Away3d 4.0.9gold learning notes camera and camera controller (7)

Here I will look at the usage in this class and make a summary again.

Orbitcontrollerextended.

package controllers{import away3d.cameras.*;import away3d.containers.*;import away3d.controllers.*;import flash.display.*;import flash.events.*;public class OrbitControllerExtended extends Object{    private var _camera:Camera3D;    private var _stage:DisplayObject;    private var _target:ObjectContainer3D;    private var isMouseDown:Boolean = false;    private var lastPanAngle:Number;    private var lastTiltAngle:Number;    private var lastMouseX:Number;    private var lastMouseY:Number;    public var fov:Number = 800;    public var mainController:HoverController;    private var _activate:Boolean = true;    public function OrbitControllerExtended(param1:Camera3D, param2:DisplayObject, param3:ObjectContainer3D = null)    {        this._camera = param1;        this._stage = param2;        this._target = param3;        this.mainController = new HoverController(this._camera, this._target, 180, 20, this.fov, 0, 35, NaN, NaN, 6, 1);    }    public function set activate(param1:Boolean):void    {        this._activate = param1;    }    public function get activate():Boolean    {        return this._activate;    }    private function activateController(param1:Boolean):void    {        if (param1)        {            this._stage.addEventListener(MouseEvent.MOUSE_DOWN, this.stageMouseDown);            this._stage.addEventListener(MouseEvent.MOUSE_UP, this.stageMouseUp);            this._stage.addEventListener(MouseEvent.MOUSE_WHEEL, this.stageMouseWheel);        }        else        {            this._stage.removeEventListener(MouseEvent.MOUSE_DOWN, this.stageMouseDown);            this._stage.removeEventListener(MouseEvent.MOUSE_UP, this.stageMouseUp);            this._stage.removeEventListener(MouseEvent.MOUSE_WHEEL, this.stageMouseWheel);        }    }    private function stageMouseDown(event:MouseEvent):void    {        this.lastPanAngle = this.mainController.panAngle;        this.lastTiltAngle = this.mainController.tiltAngle;        this.lastMouseX = this._stage.mouseX;        this.lastMouseY = this._stage.mouseY;        this.isMouseDown = true;    }    private function stageMouseUp(event:MouseEvent):void    {        this.isMouseDown = false;    }    private function stageMouseWheel(event:MouseEvent):void    {        var value:Number = this.fov - event.delta / 0.5;        if (value < 590)        {            value = 590;        }        if (value > 950)        {            value = 950;        }        this.fov = value;    }    public function update():void    {        if (this._activate)        {            this.activateController(true);            this.mainController.update();            this.mainController.distance = this.mainController.distance + (this.fov - this.mainController.distance) / 8;            if (this.isMouseDown)            {                this.mainController.panAngle = 0.3 * (this._stage.mouseX - this.lastMouseX) + this.lastPanAngle;                this.mainController.tiltAngle = 0.3 * (this._stage.mouseY - this.lastMouseY) + this.lastTiltAngle;            }        }        else        {            this.activateController(false);        }    }}}

 

 

3. Create a vehicle

4. How to Use dynamic reflection of version 4.1 for this case

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.