Simple ND3D tutorial with flex + flash develop

Kali ini merupakan sebuah experiment dengan flash3D engine, yaitu ND3D.
Buat yang belum tau apa itu ND3D, bisa liat di sini.

ok langsung aja.

  1. Download ND3D terbaru,ingat ambil source terbaru disini, gunakan program svn untuk mendownloadnya, atau jika anda malas file ND3D terbaru sudah termasuk didalam file tutorial.
  2. Buka Flash Develop,pilih new project, dan pilih as3 project. jika anda sudah mendownload file ND3D,jangan lupa atur classhpathnya,untuk cara mengaturnya bisa liat di tutorial sebelumnya,https://thestudioindependent.wordpress.com/2010/03/05/simple-away3d-tutorial/
  3. Nah disini kita mulai Happy Coding, buka file Main.as ketik coding ini

  4. package
    {
    import de.nulldesign.nd3d.material.BitmapMaterial;
    import de.nulldesign.nd3d.objects.Sprite3D;
    import de.nulldesign.nd3d.utils.MaterialDefaults;
    import de.nulldesign.sound.SoundAnalyzer;
    import flash.display.BitmapData;
    import flash.display.GradientType;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;

    import de.nulldesign.nd3d.material.Material;
    import de.nulldesign.nd3d.objects.Mesh;
    import de.nulldesign.nd3d.objects.PointCamera;
    import de.nulldesign.nd3d.objects.SimpleCube;
    import de.nulldesign.nd3d.objects.Cube;
    import de.nulldesign.nd3d.renderer.Renderer;
    import de.nulldesign.nd3d.utils.MeshLoader;
    import de.nulldesign.nd3d.events.MeshEvent;
    import de.nulldesign.nd3d.utils.ASEParser;
    import de.nulldesign.nd3d.utils.MD2Parser;
    import de.nulldesign.nd3d.objects.MD2;
    import de.nulldesign.nd3d.objects.Object3D;

    /**
    * ...
    * @author Javax
    */
    public class Main extends Sprite
    {
    private var renderClip:Sprite;
    private var renderer:Renderer;
    private var cam:PointCamera;
    private var renderList:Array;
    private var c:SimpleCube;
    private var meshLoader:MeshLoader;
    private var heli:MD2;

    public function testNd()
    {
    var m:Matrix = new Matrix();
    m.rotate(Math.PI / 2);
    graphics.beginGradientFill(GradientType.LINEAR, [0x0000000, 0xFFFFFF], [100, 100], [125, 255], m);
    graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
    graphics.endFill();
    var gradient:Sprite = new Sprite();
    addChild(gradient);

    var rendererSprite:Sprite = new Sprite();
    addChild(rendererSprite);

    renderer = new Renderer(rendererSprite);

    renderList = [];

    cam = new PointCamera(600, 400);
    cam.zOffset = 1000;
    cam.angleY = 84.8;

    // minelayercorvette
    var mat:Material = new Material(0x7b7b7b, 1, false, true, false);
    var textures:Array = [];
    textures.push("textures/hheli.jpg");

    meshLoader = new MeshLoader(new MD2Parser());
    meshLoader.addEventListener(MeshEvent.MESH_LOADED, onMeshLoaded);
    meshLoader.loadMesh("models/hheli.md2", textures, new MaterialDefaults(true, true, false, false));

    addEventListener(Event.ENTER_FRAME, onRenderScene);
    }

    private function onMeshLoaded(evt:MeshEvent):void
    {
    heli = evt.mesh as MD2;
    heli.scale(3, 3, 3);
    renderList.push(heli);
    }

    public function onRenderScene(e:Event):void
    {
    heli.angleY += (mouseX - cam.vpX) * .0005;
    heli.angleX += (mouseY - cam.vpY) * .0005;
    renderer.render(renderList, cam);

    if(heli) heli.update();

    }

    }

    }

    Build dan jalankan,maka hasilnya seperti ini.

    Download Source http://filebin.gamedevid.org/get/100dl/tutorialND3D.rar.