<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
    主站蜘蛛池模板: 国产婷婷成人久久Av免费高清| 亚洲精品无码一区二区| 中文字幕的电影免费网站| 一区二区三区亚洲视频| 黄网站色成年片大免费高清| 四虎永久精品免费观看| 在线精品自拍亚洲第一区| 免费国产真实迷j在线观看| 美女的胸又黄又www网站免费| 国产在线观看免费完整版中文版| 亚洲AV网一区二区三区| 亚洲人成电影在线播放| 国产成人无码区免费网站| 久久久久亚洲AV无码观看| 一二三四在线播放免费观看中文版视频 | 91成人在线免费观看| 亚洲福利视频网址| 成人性生交大片免费看无遮挡| 亚洲国产成人综合精品| 亚洲人成影院在线观看| 精品视频在线免费观看| 亚洲三级在线视频| 国产无遮挡色视频免费视频| 一级人做人爰a全过程免费视频 | 99久久这里只精品国产免费| 亚洲AV无码成人网站在线观看 | 亚洲韩国—中文字幕| 免费无码A片一区二三区 | 亚洲一区二区三区乱码A| 久久久久国产精品免费网站| 亚洲国产精品综合久久20| 又黄又爽的视频免费看| 久久国产免费一区| 亚洲色成人网站WWW永久四虎| 亚洲免费日韩无码系列| 57pao一国产成永久免费| 国产午夜亚洲精品不卡免下载| 情人伊人久久综合亚洲| 最新中文字幕免费视频| 99精品视频免费| 一本色道久久88—综合亚洲精品 |