雖然JiglibFlash 3D 物理引擊效能比不上AwayPhysics, 但基本功能齊全, 運算不會進行域內存操作, 無需考慮高級功能許可證 (Premium Features License) 問題. 若不是要求極高效能, 這是我們其中的一個好選擇.
大家可以到官方網頁下載最新範例試試.
請按 [觀看] 範例 |
請按 [觀看] 範例 |
private function setUpView():void { // <----- define variable _view = new View3D(); // <----- set View3d _view.width = width; _view.height = height; _view.backgroundColor = 0xffffff; _view.antiAlias = 16; //抗鋸齒有效設值為 0,2,4和16 // <----- set camera _view.camera.position = new Vector3D( 0, 1400, -1000); _view.camera.lookAt(new Vector3D(0, 400, 0)); _view.camera.lens.near = 0.2; (_view.camera.lens as PerspectiveLens).fieldOfView = 60; // <----- add object addChild(_view); addChild(new AwayStats(_view)); }
private function setUpLights():void { var light1:DirectionalLight = new DirectionalLight(0,-2,1); var light2:DirectionalLight = new DirectionalLight(0,2,-2); _lightPicker = new StaticLightPicker([light1, light2]); _view.scene.addChild(light1); _view.scene.addChild(light2); }
private function initMesh():void { Loader3D.enableParser(Max3DSParser); _loader = new Loader3D(); _loader.addEventListener(AssetEvent.MESH_COMPLETE, meshCompleteHandler); _loader.loadData(MyMesh, new AssetLoaderContext(false), null, new Max3DSParser()); _loader.scale(1); _view.scene.addChild(_loader); }
private function meshCompleteHandler(event:AssetEvent):void{ // <----- define materials var m1:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(Skin01Texture)); var m2:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(Skin02Texture)); // <----- set materials m1.specular = 0.4; m1.lightPicker = _lightPicker; m2.specular = 0.9; m2.lightPicker = _lightPicker; // <----- apply materials to mesh for (var i:int = 0; i < _loader.numChildren; i++){ var mesh:Mesh = Mesh(_loader.getChildAt(i)); if(mesh.name.indexOf("polySurfac")>-1) mesh.material = m1; else mesh.material = m2; } }
_ | 選擇安裝OpenNI, 過程較為複雜, 需要順序安裝以下驅動程序 (Device driver):
|
_ | 選擇安裝Kinect for Windows SDK 過程較為簡單, 大家在Microsoft [下載] 最新的SDK 便可以. |
3D Character Demo |
Basic Demo |
package { import flash.display.Sprite; import flash.events.Event; [SWF(backgroundColor="#000000", frameRate="30", quality="LOW", width="1024", height="768")] //public class Main extends Advanced_ShallowWaterDemo //public class Main extends Intermediate_CharacterAnimation //public class Main extends Intermediate_Globe //public class Main extends Intermediate_Head //public class Main extends Intermediate_MD5Animation //public class Main extends Intermediate_MouseInteraction //public class Main extends Basic_View //public class Main extends Basic_Tweening3D //public class Main extends Basic_SkyBox //public class Main extends Basic_Shading public class Main extends Basic_LoadMD2 //public class Main extends Basic_Load3DS //public class Main extends Advanced_FractalTreeDemo { public function Main() { super(); } } }
Hello Racer |
+360º - Car Visualizer |
Neema |
view3d.background = new FLARWebCamTexture(captureWidth, captureHeight);