views:

38

answers:

0

I was playing around with papervision3D and want to create a reflexion to a group of planes. I load dynamically images through XML...

Using bitmapMaterial the result of reflexion doesn't appear in right order place. Does anyone know how to fix that?

ex: pic1, pic2, pic3, pic4 (normal pics above) pic2, pic4, pic1, pic3 (reflection appears) it appears in random order....sets

private function createReflection(tabItems:Array) {
 for (var index=0;index<tabItems.length;index++) {

// Load photos into bitmap data
var loadBitmap:LoadBitmap = new LoadBitmap(tabItems[index].image);
loadBitmap.addEventListener(CustomEventCenter.OBJECT_USED, handleBitmap);
 }
}



 private function handleBitmap(event:CustomEventCenter):void
{
var bitmapTexture = event._name.bitmap;

// Create reflection planes     
var bitmapMaterial:BitmapMaterial = new BitmapMaterial(bitmapTexture);      
plane2 = new Plane(bitmapMaterial, PLANE_WIDTH, PLANE_HEIGHT, PLANE_SEGMENT_WIDTH, PLANE_SEGMENT_HEIGHT);
tabPlanes2.push(plane2);

trace("Plane 2 index: "+plane2.id);

scene.addChild(plane2); 
animatePlane2(tabPlanes2);  

}

In loadBitmap class:

 private function handleLoadedBitmap(event:Event):void
{
var xPos:uint = 0;
var bitmapData:BitmapData = new BitmapData((loadBMP.width), (loadBMP.height), false, COLOR);

bitmapData.draw(loadBMP);

dispatchEvent(new CustomEventCenter(CustomEventCenter.OBJECT_USED, { bitmap:bitmapData })); 

}