Getting started with Alternativa3D 8

From AlternativaPlatform Wiki

Jump to: navigation, search


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

Contents

[edit] Required software

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

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

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

[edit] Software setup

[edit] Flash Develop 4

  1. Flex SDK 4.6 is integrated into FlashDevelop 4 and you can go to next point.
  2. Launch the Flash Develop 4. We see the start window:
    FD01.JPG

  3. Create a new ActionScript project: menu items Project→New project:
    FD02.JPG

  4. Specify the type of project and path to it:
    FD03 8.JPG

  5. Specify the additional parameters:
    1. Project→Properties→Compiler Options→Additional Compiler Options.
      FD06 8.JPG

      Add here the string:
      -swf-version=13 -target-player=11.1 -static-link-runtime-shared-libraries=true

    2. Project→Properties→Output→Test Project set to Open document and type here the string:
      bin\index.html
  6. 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":
    FD04.JPG

  7. 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.
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

[edit] Adobe Flash Builder 4

  1. Execute the point 1 from first chapter
  2. Launch Adobe Flash Builder 4. We see the start window:
  3. Create a new ActionScript project (menu items: File→New→ActionScript Project)
  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"
  5. For normal operation, we need to have at least SDK version 4.6. 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.
  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
  7. We see an empty project 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.1.0
    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.
  9. Specify the properties of HTML-environment (file index.template.html). To enable hardware acceleration must be set:
    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.

[edit] Intellij IDEA

  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.
  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.JPG

    IDEA07.JPG

    IDEA08.JPG

    IDEA09 8.JPG

  3. Additional parameters:
    IDEA10 8.JPG

    Clicking Finish 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.
    • 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
  7. Goto File→Settings→Compiler→Flex Compiler and set Compile with→Flex Compiler Shell (fcsh)
  8. To check it out you should to compile the code from first chapter. Click menu items RunRun. After that:
    IDEA12 8.JPG


    IDEA13 8.JPG

    Click "Run" and you will see our black box.
Personal tools
Namespaces
Variants
Actions
Navigation
Category
Toolbox
In other languages