Live textures

Software: Away3D 4.x

GameDesign, Newbie
Posted: 21 August 2013 02:29 PM   Total Posts: 4

Hi All

Does anyone have any ideas on the best way to create live updating textures.
I need the texture for the model to be updated every frame if possible. My texture is 1024x1024 and after a few seconds it goes over its resource limit.

I am not quite sure why it is doing this as it is only reloading the same image every frame.

private function enterFrameHandler(evt:Event):void
{
this.bitmapTexture = new BitmapTexture(layoutBitmap.bitmapData);
this.textureMaterial = new TextureMaterial(bitmapTexture);
coffin.material = this.textureMaterial;
}

Any help would be greatly appreciated
Thanks

   

Lexcuk, Newbie
Posted: 21 August 2013 02:42 PM   Total Posts: 17   [ # 1 ]

Try this

var bitmapData:BitmapData bitmapTexture.bitmapData;
         
bitmapData.lock();
         
bitmapData.fillRect(bitmapData.rect0);
         
//bitmapData.draw(_video, _matrix, null, null, bitmapData.rect, _smoothing);
         
bitmapData.draw(simpleVideoPlayer.container);
         
bitmapData.unlock();
         
bitmapTexture.invalidateContent();
         
         
         
view.render(); 
   

GameDesign, Newbie
Posted: 21 August 2013 03:43 PM   Total Posts: 4   [ # 2 ]

I had just solved the problem, but thanks anyway for your reply smile

   

asimilon, Newbie
Posted: 10 October 2013 06:38 PM   Total Posts: 2   [ # 3 ]

Care to share?

   

Avatar
theMightyAtom, Sr. Member
Posted: 10 October 2013 09:34 PM   Total Posts: 669   [ # 4 ]

I would assume they updated the material without creating a whole new material every frame. That was why they would be running out of memory.
See lexcuk’s solution above.

I would create a variable which keeps a reference to the material bitmapData, ready for updating.

something like….

private var updatingBmd:BitmapData;
  private var 
myBitmapTexture:BitmapTexture;
  private var 
myMaterial:TextureMaterial;
  private var 
contentThatUpdates:Sprite;

  private function 
init():void{
   updatingBmd 
= new BitmapData(1024,1024);
   
myBitmapTexture = new BitmapTexture(updatingBmd);
   
myMaterial = new TextureMaterial(mybitmapTexture);

  
}

  
private function redraw(evt:Event):void{
   updatingBmd
.draw(contentThatUpdates);
   
myBitmapTexture.invalidateContent();
  

Good Luck!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X