<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    creating a 3D model in Flex using Blender and Papervision3D - a beginning tutorial

    This tutorial is for beginners using papervision3d with flex. I’m not an expert, but I’ve been experimenting with it, and here’s a way to get started with collada files in Flex. Here we will be creating a 3D model from the very beginning.

    First, a few notes:
    It seems that papervision3D/Flex are finicky with the collada files, so they must be exported in a very specifc way in order to import properly. In this example I’m using Blender. With other apps (like sketchup) there will be a different method to create and acceptable collada file, and some will need to be edited manually in order to work (I’ll do a tutorial on that later)

    I haven’t gone into depth with textures/materials here, but I put in a real basic bitmap texture that works for this example. I’ll do more on textures later ….


    To create the model in flex, we need a few things:
    1) the papervision3D class package : you can find it here: http://blog.papervision3d.org/
    2) a properly prepared .collada file - here we use Blender - found here: http://www.blender.org
    3) an actionscript file to load and control the collada1) First make sure that your papervision class folders are in the appropriate path. For now you can just drag the org folder in to your flex project folder.2) open Blender and delete the default cube. (press x)
    3)click add->mesh->torus4) in the editing window, click new material, then new UV texture
    5)click the textures button, and select texture type->image
    6) load a bitmap image to use as your texture
    7) goto file->export->collda1.4in the export window, the following items are selected: (the rest are deselected)
    triangles
    only export selection
    disable physics
    use relative paths

    export the file and rename it torus.dae

    8) open the dae file in a text editor and scroll until you see a line similar to this:
    <instance_material symbol=”Material_001″ target=”#Material_001″>
    this is the name of your material you need to reference in your as file, here it is “Material_001″ if yours is different, write it down.

    9) create an image called grid.png (or use the downloaded one)

    10)make sure the .dae file and the image file are in your flex project folder (or write the full path to where they are in the as file.)

    The flex Project:
    open a new actionscript project, name it ColladaBlender, and add the following code:

    If you are unfamiliar with what’s going on in the code read it carefully - it’s not commented, but if you are familiar at all with Acstionscript 3.0 classes, you should see what’s going on here.

    package {
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.events.Event;

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.BitmapMaterial;
    import org.papervision3d.materials.MaterialsList;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.objects.Collada;

    [SWF(backgroundColor=”#000000″, frameRate=”40″)]
    public class BlenderCollada extends Sprite
    {
    /* this reference to an image file overrides whatever image file is referenced in the collada file as long as the material name is the same*/
    [Embed(source=”./grid.png”)] private var Material_001:Class;
    [Embed(source=”./torus.dae”, mimeType=”application/octet-stream”)] private var MyObject:Class;
    private var myMaterials:Object;
    private var container:Sprite;
    private var scene:Scene3D;
    private var camera:Camera3D;
    private var rootNode:DisplayObject3D;

    public function BlenderCollada()
    {
    var Material_001:Bitmap = new Material_001() as Bitmap;

    myMaterials = {
    /*
    open your collada (.dae) file and look at where the material is defined:
    <instance_material symbol=”Your Material Name” target=”#Your Material Name>
    replace all references to “Material_001″ in this actionscript file with your material name
    */
    Material_001: new BitmapMaterial( Material_001.bitmapData )
    };

    init3D();

    addEventListener(Event.ENTER_FRAME, loop3D);
    }

    private function init3D():void {

    container = new Sprite();
    addChild( container );

    container.x = 200;
    container.y = 200;

    scene = new Scene3D( container );

    camera = new Camera3D();
    camera.x = 3000;
    camera.z = -50;
    camera.zoom = 150;
    camera.focus = 10;

    rootNode = scene.addChild( new DisplayObject3D(”rootNode”) );
    rootNode.addChildren( new Collada( XML( new MyObject() ), new MaterialsList( myMaterials ) ) );

    }

    private function loop3D( event:Event ):void {
    var screen: DisplayObject3D = scene.getChildByName(”rootNode”);
    var rotationY: Number = -(mouseX / stage.stageWidth * 360);
    var rotationX: Number = -(mouseY / stage.stageHeight * 360);
    screen.rotationY += (rotationY - screen.rotationY) / 12;
    screen.rotationX += (rotationX - screen.rotationX) / 12;
    scene.renderCamera(camera);
    }
    }
    }

    Test the application.

    I will be posting more tutorials and examples as I continue to work with Papervision3DGood Luck!

    example: http://www.tetraktysdesign.com/experiments/BlenderCollada/bin/BlenderCollada.html

    download a zip of the source files here

    posted on 2008-11-12 13:24 seal 閱讀(1017) 評論(0)  編輯  收藏 所屬分類: Flex+ActionScript
    主站蜘蛛池模板: 亚洲另类少妇17p| 亚洲一级特黄大片在线观看| 亚洲精品亚洲人成在线麻豆| 无码少妇精品一区二区免费动态 | 免费看大美女大黄大色| 亚洲日本人成中文字幕| 拍拍拍又黄又爽无挡视频免费| 97se亚洲国产综合自在线| 成人免费在线视频| 国产99久久亚洲综合精品| 亚洲黄片毛片在线观看| 免费人成激情视频在线观看冫| 亚洲av无码乱码国产精品fc2| 久久免费的精品国产V∧| 亚洲一级毛片免费观看| 日本午夜免费福利视频| 黄视频在线观看免费| 久久久影院亚洲精品| 好先生在线观看免费播放 | 亚洲大成色www永久网址| 国产小视频在线免费| a免费毛片在线播放| 噜噜噜亚洲色成人网站∨| 毛片免费视频播放| 人体大胆做受免费视频| 亚洲一区二区三区电影| 久久精品免费一区二区喷潮 | 99久久免费精品国产72精品九九| AV激情亚洲男人的天堂国语| 亚洲三区在线观看无套内射| 中文免费观看视频网站| 人妻仑刮八A级毛片免费看| 亚洲av日韩av无码黑人| 精品国产免费观看久久久| 国产精品美女免费视频观看| 亚洲高清中文字幕| 亚洲成?Ⅴ人在线观看无码| 国产91色综合久久免费分享| 在线播放国产不卡免费视频 | 国产精品无码亚洲一区二区三区| 国产亚洲综合成人91精品|