(DEV branch) What to use instead of BitmapFileMaterial?

Software: Away3D 4.x

M4TH76, Newbie
Posted: 14 November 2011 06:00 PM   Total Posts: 3

Hi All
I Just merged DEV branch and the BitmapFileMaterial() is removed! What should I use instead of that Class?

Thanks

   

Alex Bogartz, Sr. Member
Posted: 14 November 2011 08:10 PM   Total Posts: 216   [ # 1 ]

They made a reference some time back about creating a new class called TextureMaterial.  Is that in there?

   

M4TH76, Newbie
Posted: 14 November 2011 08:13 PM   Total Posts: 3   [ # 2 ]

Thanks

Here a little hack I made :]

BitmapFileMaterial.as in root dir of my classpath/.fla

package  {
 import flash
.display.BitmapData;
 
import away3d.materials.TextureMaterial;
 
import flash.display.Loader;
 
import flash.net.URLRequest;
 
import flash.events.Event;
 
import away3d.textures.BitmapTexture;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
 public class 
BitmapFileMaterial extends TextureMaterial {
  
public var bitmapTexture:BitmapTexture
  
  
public function BitmapFileMaterial(url:String{
   
// constructor code
   
bitmapTexture =  new BitmapTexture(new BitmapData(256256true0x00000000))   
   
super(bitmapTexture)   
   
   var 
loader:Loader = new Loader()
   
loader.contentLoaderInfo.addEventListener(Event.COMPLETEonBitmapLoaded)
   
loader.load(new URLRequest(url))
  
}
  
  
private function onBitmapLoaded(event:Event){
   bitmapTexture
.bitmapData event.currentTarget.content.bitmapData
  }
  
  
public function set lights(value){
   this
.lightPicker = new StaticLightPicker(value)
  
}

 }
 
   

Avatar
David Lenaerts, Administrator
Posted: 15 November 2011 11:57 AM   Total Posts: 80   [ # 3 ]

While that technically works, it’s the “wrong” way to go about it wink What’s happening in your code is actually the reason the old BitmapFileMaterial is now gone: poor resource management. Instead, you could look into creating a BitmapFileTexture that extends Texture2DBase or BitmapTexture base. That way, one Texture object can be shared across several materials, which is not something a BitmapFileMaterial would allow. Instead, it creates new BitmapData and BitmapTexture instances all the time.

We’re planning to implement these things so you’ll have them ready to go (same goes for VideoTexture, MovieTexture), but if you feel like having a stab at it, feel free and let us know wink

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X