Alternativa3D 8 的开始

译自:http://wiki.alternativaplatform.com/Getting_started_with_Alternativa3D_8

转载请注明:http://cenfee.com/?p=329

In this tutorial we will show you information about setting software for work with Alternativa3D 8.

在这个教程,我们将展示怎么在你的软件中使用 Alternativa3D 8。

需要的软件

In order to work with Alternativa3D you should get any software:

为了使用Alternativa3D,你应该有下面的软件:

  • Flex SDK (version 4.5 – link). 下载它,并放到一个方便的位置。
  • Flash – player (version 11 – link).
  • Alternativa3D 8 engine 可以从这里下载AlternativaPlatform. 下载它并放到一个方便的位置。
  • Development environment 开发环境

In this tutorial we look at the most popular development environments:

在这个教程,我们关注比较主流的开发环境:

You should choose the most convenient IDE for you (Comparison of IDE).

你应该选择对于你来说最方便的开发环境

软件设置

Flash Develop 4

  1. Download Flex SDK. Goto folder %SDK_PATH%\frameworks\libs\player\ (where %SDK_PATH% – SDK folder). If there is no folder 11.0, then create it and copy the file playerglobal.swc into it (It is necessary for all IDEs)..
    下载Flex SDK。去这个文件夹%SDK_PATH%\frameworks\libs\player\ (%SDK_PATH% – SDK的文件夹)。如果里面没有11.0的文件夹,那么久创建这个文件夹,并复制 playerglobal.swc文件到这里(这是必需的对于IDE)
  2. Launch the Flash Develop. We see the start window:
    打开Flash Develop。我们看到这样的开始界面:
    FD01.JPG
  3. For connecting the Adobe Flex SDK use menu items: “Tools→Program settings→AS3Context→Flex SDK location”. Specify the path to downloaded SDKs:
    到这里”Tools→Program settings→AS3Context→Flex SDK location”来加入Flex SDK。指定SDK的路径:
    FD05.JPG
  4. Create a new ActionScript project: menu items Project→New project:
    创建一个新的ActionScript项目:
    FD02.JPG
  5. Specify the type of project and path to it:
    指定项目类型和项目路径:
    FD03 8.JPG
  6. Open file {project_folder}\bin\index.html and add the string:
    打开{project_folder}\bin\index.html,并加入参数:

    wmode: "direct"
  7. Specify the additional parameters:
    指定附加的编译参数:
  8. Project→Properties→Compiler Options→Additional Compiler Options.FD06 8.JPG

    Add here the string:
    加入下面的字符串

    -swf-version=13 -target-player=11.0 -static-link-runtime-shared-libraries=true
  9. Project→Properties→Output→Test Movie set to Open documentand type here the string:
    bin\index.html
  10. We had created the project. Connect Alternativa3D engine. Copy to {project_folder}\lib\ the file Alternativa3D.swc. Next, go to Flash Develop. Click on Alternativa3D.swc by right mouse button and “Add to library”:
    我们已经创建这个项目。链接Alternativa3D 引擎。把文件Alternativa3D.swc复制到{project_folder}\lib\。下一步,回到Flash Develop。鼠标右键加入到库。
    FD04.JPG
  11. OK! You had configured the Flash Develop 4. To check it out you should to compile the simple example. Rename the main file of the project: Main.as to HelloBox.as. And copy here next code and compile it.
    好!你已经配置好Flash Develop 4。编译一个简单的例子看是否成功。重新命名这个项目的主文件:Main.as 改为 HelloBox.as。并复制下面的代码,并编译它。

    </li>
    </ol>
    <pre>package {
    import alternativa.engine3d.controllers.SimpleObjectController;
    import alternativa.engine3d.core.Camera3D;
    import alternativa.engine3d.core.Object3D;
    import alternativa.engine3d.core.Resource;
    import alternativa.engine3d.core.View;
    import alternativa.engine3d.materials.FillMaterial;
    import alternativa.engine3d.primitives.Box;
    
    import flash.display.Sprite;
    import flash.display.Stage3D;
    import flash.events.Event;
    
    public class HelloBox extends Sprite {
        private var stage3D:Stage3D;
        private var camera:Camera3D;
        private var rootContainer:Object3D;
        private var controller:SimpleObjectController;
        private var box:Box;
    
        public function HelloBox() {
    
            camera = new Camera3D(0.01, 10000000000);
            camera.x = -50;
            camera.y = -300;
            camera.z = 100;
            controller = new SimpleObjectController(stage, camera, 200);
            controller.lookAtXYZ(0,0,0);
            camera.view = new View(800, 600, false, 0xFFFFFF, 0, 4);
            addChild(camera.view);
    
            rootContainer = new Object3D();
            rootContainer.addChild(camera);
    
            box = new Box();
            box.setMaterialToAllSurfaces(new FillMaterial(0x0));
            rootContainer.addChild(box);
    
            stage3D = stage.stage3Ds[0];
            stage3D.addEventListener(Event.CONTEXT3D_CREATE, init);
            stage3D.requestContext3D();
    
        }
    
        private function init(event:Event):void {
            for each (var resource:Resource in rootContainer.getResources(true)) {
                resource.upload(stage3D.context3D);
            }
            addEventListener(Event.ENTER_FRAME, enterFrameHandler)
        }
    
        private function enterFrameHandler(event:Event):void {
            controller.update();
            camera.render(stage3D);
        }
    }
    }
    

    If you see the black box then all right.

    如果你看到这个黑盒子,那么一切正常。
    FD07 8.JPG

    Adobe Flash Builder 4

    1. Execute the point 1 from first chapter
      执行第一章的第一点
    2. Launch Adobe Flash Builder 4. We see the start window:
      打开Adobe Flash Builder 4。我们可以看到这个开始窗口:
    3. Create a new ActionScript project (menu items: File→New→ActionScript Project)
      创建一个新的ActionScript项目
    4. In the resulting window, specify the basic parameters of the project (name, path to the working directory, version of SDK). The name of our project: "HelloBox"
      在弹出窗口中,指定项目基本的参数。项目名字为“HelloBox”
    5. For normal operation, we need to have at least SDK version 4.5. If you haven't done so, click on the link "Configure Flex SDKs...". Please go to Installed Flex SDKs at Preferences window and add the path to the SDK.
      为了正常地运行,我们需要至少4.5版本的SDK。如果你没有这样做,点击链接“安装Flex SDKs...”。在选择窗口中选择安装 Flex SDKs,并加入SDK的路径。
    6. Specifying additional parameters of the project. Clicking on the "Add SWC" we get to the window to add a third party library. We use this to specify the path to Alternativa3D 8
      指明项目的附加参数。点击“add SWC”加入第三方的库,指明Alternativa3D 8的路径
    7. We see an empty project ActionScript 3.0
      我们看到一个空的ActionScript 3.0的项目
    8. Now we need to specify additional properties of compilation. Call the context menu of the project and select "Properties". Specify the properties of the compiler:
      现在我们需要去指定附加的编译参数。

      1. Specify the version of the player who will play the swf-movie 11.0.0
        指定player的版本
      2. Advanced Compiler Options
        加入编译参数

        -swf-version=13

        13 is the SWF version that corresponds to the player, so you need to tell the runtime what version of the APIs you want to use.
        13是SWF相对应player11.0的版本,所以你需要你告诉运行时,你想使用哪个版本的API。

    9. Specify the properties of HTML-environment (file index.template.html). To enable hardware acceleration must be set:
      指明HTML环境的属性(文件index.template.html)。为了使用硬件加速,必须设置:

      params.wmode = "direct".
    10. OK! You had configured the Adobe Flash Builder 4. To check it out you should to compile the code from first chapter. If you see the black box then all right.
      好!你已经配置好Adobe Flash Builder 4。看看你是否可以编译第一张的代码。如果你看到那个黑盒子,那么一切正常。

    [edit] Intellij IDEA(本人没用过这个工具,这部分就不翻译了,需要的话可以留言)

    1. Execute the point 1 from first chapter
    2. Launch Intellij IDEA. We see the start window. Create a new ActionScript project (menu items: File→New project)
    3. Next, select the item Create project from scratch and click Next

    At this window we can specify information about project: project name, path to project and other parameters:
    IDEA04.JPG

    1. Create source directory
    2. Specify the path to Flex SDK:
      IDEA06.JPGIDEA07.JPG

      IDEA08.JPG

      IDEA09.JPG

      Delete library {SDK_PATH}\frameworks\libs\player\10.2\playerglobal.swc. Add library {SDK_PATH}\frameworks\libs\player\11.0\playerglobal.swc

    3. Additional parameters:
      IDEA10 8.JPGIDEA11 8.JPG

      Clicking Create you will get an empty AS3 project

    4. Mark src folder as Source root. Call the context menu of src folder and select Mark Directory AsSource root
    5. Create the new AS3 class. Call the context menu of src folder and select NewActionScript Class. Specify the name of new class: HelloBox
    6. Now connect Alternativa3D 8 engine. Select the menu item FileProject Structure. After that you can see the project settings window. And here there are some points: Project, Modules, Libraries etc. We will need three of them:
      • At Project you must choose your Flex SDK
      • At Libraries you must specify the path to Alternativa3D 8 engine: add the new ActionScript/Flex library. After that click "Add SWC Files", specify the directory, where you extract Alternativa3D.swc
      • At Modules you can get the tab Flex Compiler Settings and specify Additional compiler oprions:
        -static-link-runtime-shared-libraries=true -swf-version=13
    7. To check it out you should to compile the code from first chapter. Click menu items RunRun. After that:
      IDEA12 8.JPGIDEA13 8.JPG

      Click "Run" and you will see our black box.

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>