Hi,
I tried to use the bulkloader but I'm not having any luck with that
either. I'm in the same place as before. I can start the cube and make
it move, but no fancy loading of images from a URL. Below is the code
I am using. I have another question though, can I take
bitmapfilematerial to convert it to a bitmapmaterial that can be used
on a model, and then make another loader event to fire off when the
bitmapmaterial event is finished?
package {
import br.com.stimuli.loading.BulkLoader;
import br.com.stimuli.loading.BulkProgressEvent;
import flash.display.Sprite;
import flash.events.*;
import flash.display.*;
import away3d.cameras.*;
import away3d.core.math.Number3D;
import away3d.core.render.Renderer;
import away3d.core.utils.Cast;
import away3d.lights.DirectionalLight3D;
import away3d.containers.View3D;
import away3d.primitives.Cube;
import away3d.materials.BitmapMaterial;
import away3d.materials.Material;
import away3d.materials.BitmapFileMaterial;
import away3d.materials.Dot3BitmapMaterial;
//import away3d.core.utils.Cast;
public class ExBitmapFileMaterial extends Sprite {
public var loader:BulkLoader;
public var viewport:View3D;
public var cube:Cube;
//ublic static var TorsoImage:Class;
public var diffuseMaterial:BitmapMaterial;
public var normalMaterial:BitmapMaterial;
public var dot3Materials:Dot3BitmapMaterial;
public var light:DirectionalLight3D;
public function ExBitmapFileMaterial() {
viewport=new View3D({x:512,y:512});
addChild(viewport);
this.text2.text="Loading...";
loader=new BulkLoader("main-site");
this.text2.text="Loading bulkloader";
loader.add("http://www.binxalot.com/Texturama/lichen-and-
stone.jpg", {type:"image", id:"pic2"});
this.text2.text="Loading Bitmap 1";
loader.add("http://www.binxalot.com/Texturama/lichen-and-
stone_bump.jpg", {type:"image", id:"pic2"});
this.text2.text="Loading BitMap 2";
// loader.addEventListener(BulkLoader.COMPLETE,
onAllItemsLoaded);
loader.addEventListener(BulkLoader.COMPLETE,
onAllItemsLoaded);
//this.addEventListener(BulkLoader.COMPLETE,
onAllItemsLoaded);
this.text2.text="Added Listener...";
loader.start();
this.text2.text="Started Loader...";
cube=new
Cube({x:-150,y:+150,z:0,width:150,height:150,depth:
150,material:"blue"});
this.text2.text="Created Cube...";
viewport.scene.addChild(cube);
this.text2.text="Added Cube to Scene";
this.addEventListener(Event.ENTER_FRAME, renderThis);
}
private function renderThis(e:Event):void {
this.text1.text="Playing";
cube.rotationX+=1;
this.text1.text="Playing.!..";
cube.rotationY-=1;
this.text1.text="Playing..!-";
cube.rotationZ+=1;
this.text1.text="Playing!...";
viewport.camera.z=-400;
this.text1.text="Playing...!";
viewport.render();
}
public function onAllItemsLoaded(e:Event):void {
this.text2.text="Starting All Items Loaded...";
diffuseMaterial= loader.getBitmapData("pic1") as
BitmapMaterial;
cube.material = diffuseMaterial;
this.text2.text="Loaded Diffuse Material";
normalMaterial= loader.getBitmapData("pic2") as
BitmapMaterial;
cube.material = normalMaterial;
this.text2.text="Loaded Bump Material";
dot3Materials = new
Dot3BitmapMaterial(Cast.bitmap(diffuseMaterial),Cast.bitmap(normalMaterial));
this.text2.text="Created Dot3Material";
cube.material = dot3Materials;
light=new
DirectionalLight3D({color:0xFFFFFF,ambient:0.25,diffuse:
0.75,specular:0.85});
light.direction=new Number3D(400,-40,400);
this.text2.text="Created Light";
viewport.scene.addLight(light);
this.text2.text="Light Added to Scene..";
this.text2.text="Now Render it all...";
}
}
}
On Jul 26, 3:44 am, 白昆 <[email protected]> wrote:
> Bulk-Loader really works.
> Just attention that because there is a delay of downloading textures form
> internet, you need to repaint the textures to your objects after they have
> been loaded. Otherwise, nothing would be changed, although the textures are
> loaded correctly.
>
> BitmapFileMaterial works too and it's easy to use, but it doesn't support
> shade materials. If you want apply a directional 3d light on the object,
> you'd better use Bulk-Loader or something else.
>
> Good luck.