I am currently working on project which requires a 2D image to be turned in to a 3D landscape. This is done by using SkinExtrued and Elevation features of Away3D. Anyway I have just finished working on it, and surprise surprise it doesn't work. I have checked and re-checked everything, but as I am very new to Away3D and 3D in general, I have got nowhere. Here is my code:
- Code: Select all
package {
import away3d.containers.Scene3D;
import away3d.primitives.Sphere;
import flash.display.MovieClip;
import flash.display.BitmapData;
import away3d.materials.BitmapMaterial;
import away3d.materials.IMaterial;
import away3d.extrusions.Elevation;
import away3d.extrusions.SkinExtrude;
import away3d.cameras.HoverCamera3D;
import away3d.containers.View3D;
import flash.utils.getDefinitionByName;
public class WorldDoc extends MovieClip {
public var cam:HoverCamera3D = new HoverCamera3D( { zoom:50, focus:200 } );
public var scene:Scene3D = new Scene3D
public var view:View3D = new View3D( { x:0, y:0, camera:cam, scene:scene } );
public var extrude:SkinExtrude;
public function WorldDoc():void {
cam.steps = 16;
// Add the view to the stage.
this.addChild(view);
build();
cam.hover();
view.render();
}
//Here a little function that generates the bmd from the library, above player 9.0.115 you can directly access the library
//with this one you are fully 9.0 compatible, just add a linkage name to your image in the lib, and pass that id to this function.
private function imageFromLib(source_ID:String):BitmapData
{
var classRef:Class = getDefinitionByName(source_ID) as Class;
return new classRef(classRef.width, classRef.height);
}
private function build():void
{
// instance bitmapdata for elevation info
var source_elevation:BitmapData = imageFromLib("World_Elev");
// your material using the color bitmapdata
var mat:IMaterial = new BitmapMaterial(imageFromLib("World") , {smooth:true});
// instance of the elevation class, you can now call the generate method, multiple times if needed.
var elevate:Elevation = new Elevation();
// we pass to the SkinExtrude class the generated points from the elevation class
extrude = new SkinExtrude(elevate.generate(source_elevation, "r", 5, 5, 50, 50, 4), {material:mat, recenter:true, closepath:false, coverall:true, subdivision:1, bothsides:false, flip:true});
extrude.rotationX = 90;
// show time!
view.scene.addChild(extrude);
}
}
}
I have two bitmaps with the linkage ID's of 'World' and 'World_Elev'. The funny thing is that Flash throws no errors at me so...?
Many thanks in advance
Harry.