I need to know what the exact format and syntax for importing a basic
3d model into Flash through Away3D is. I have done a lot of searching
and seen various methods that for me seem to produce varying errors or
no visible object. This is just a test to make sure I understand the
concept before actually getting deeply into the programming, so for
that reason I have not used a material for the model. I assume that
Away3D will still produce a visible result, just as a cube or sphere
can be seen without assigning a specific material. Let me say first
that i fully understand the class imports and that is not an issue. I
have used AS on and off, so I understand that for the most part, plus
have other programming experience, so that is not the major issue. I
am using Flash CS5 I believe and AS3 and Flash 10 formats. I have an
intial stage and use an external class for all the Away3D AS
scripting. I am playing with it and basically putting together a
template to build furture Away3D/Flash from. I am going to post the
entire external package here, and I know it has some issues, it copied
and pasted some portions from the Earth/Stars tutorial to save time
and I have used 2 movie clips for zooming in and out on a basic cube.
I used 3DMax to make a very basic torus and exported it to the root
folder for the app and named it tube.3ds, I also produced a smaller
version of the same called tube2.3ds. You will see a lot of commented
out lines as I have tried many methods to import the model. I even
tried as a Wavefront OBJ. I really find this as the last stumbling
block to going somewhere with this software so please help. Here's my
current AS...
package
{
import flash.display.Sprite;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.primitives.*;
import away3d.materials.*;
import away3d.core.utils.Cast;
import away3d.cameras.*;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GlowFilter;
import flash.events.MouseEvent;
import flash.events.Event;
import away3d.core.render.Renderer;
import flash.events.KeyboardEvent;
import flash.events.*;
import away3d.loaders.Max3DS;
import away3d.loaders.Obj;
//import fl.motion.MotionEvent;
public class hhh extends Sprite
{
public function hhh()
{
var move:Boolean = false;
var lastPanAngle:Number;
var lastTiltAngle:Number;
var lastMouseX:Number;
var lastMouseY:Number;
var skies:Sphere;
var scene:Scene3D = new Scene3D();
// Create and set up the camera
var camera:HoverCamera3D = new
HoverCamera3D({zoom:2,focus:
200,distance:400});
camera.panAngle = -180;
camera.tiltAngle = 15;
camera.hover(true);
camera.yfactor = 1;
var view:View3D = new
View3D({scene:scene,camera:camera});
addChild(view);
view.x = 250;
view.y = 200;
var desk:Cube = new Cube({material:"blue#white"});
desk.height = 15;
desk.width = 150;
desk.depth = 25;
desk.x = 100;
view.scene.addChild(desk);
//var tube=new Max3DS();
var tube:Max3DS=new Max3DS.load("tube.3ds");
//var tube2:Obj=new Obj("tube2.obj");
//view.scene.addChild(tube);
tube.scale(100);
view.render();
function MouseDown(event:MouseEvent):void
{
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
move = true;
}
function MouseUp(event:MouseEvent):void
{
move = false;
}
function MouseOverHandlerplus(event:MouseEvent):void
{
// Start your custom code
// This example code displays the words "Moused
over" in the
Output panel.
camera.zoom = camera.zoom + 1;
// End your custom code
}
function MouseOverHandlerminus(event:MouseEvent):void
{
// Start your custom code
// This example code displays the words "Moused
over" in the
Output panel.
camera.zoom = camera.zoom - 1;
// End your custom code
}
function zoomreset(event:KeyboardEvent):void
{
camera.zoom = 1;
}
function onEnterFrame(e:Event):void
{// rerender viewport
var cameraSpeed:Number = 0.3;// Approximately
same speed as mouse
movement.
if (move)
{
camera.panAngle =
cameraSpeed*(stage.mouseX - lastMouseX) +
lastPanAngle;
camera.tiltAngle =
cameraSpeed*(stage.mouseY - lastMouseY) +
lastTiltAngle;
}
camera.hover();
view.render();
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN,
MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
plus.addEventListener(MouseEvent.CLICK,
MouseOverHandlerplus);
zoomout2.addEventListener(MouseEvent.CLICK,
MouseOverHandlerminus);
stage.addEventListener(MouseEvent.DOUBLE_CLICK,
zoomreset);
stage.addEventListener(KeyboardEvent.KEY_UP, zoomreset);
}
}
}
I can't seem to add a second agument to the new MAX3D without getting
an error, so I stopped even trying that. If I just go with blah:new
Max3D(); then I can't find a way to attach this to a model file.
var tube:Max3DS=new Max3DS.load("tube.3ds");
gives me a method cannot be used as a constructor error. At this
point I cannot remember all the ways I have tried to do this.