Texture is not updated

Software: Away3D 4.x

Mafiy, Newbie
Posted: 16 August 2012 02:08 PM   Total Posts: 15

Hi,
I have three textures (they will be named as subtextures)
For example:
First texture - grass;
Second texture - details for grass;
Third textures - trees, shrubs.

I need to merge these textures to single (common texture) and apply to surface. But after merging I can change subtextures one time only.

If I want to do modification one more time the changes are not displayed on common texture. How can I fix issue?

Draw on texture:

private function Draw(x:uinty:uint):void
{
var point:Point = new Point(xy);
var 
textureMap:BitmapTexture m_MapView.materialPlane;
 
m_Layers.groundLayer.copyPixels(m_Brush.brushDatam_Brush.rectBrushpoint);
m_Layers.combineLayers(); //merge textures
textureMap.bitmapData m_Layers.mainLayer;

m_Layers:

public function Layers(width:uintheight:uint
{
m_MainLayer 
= new BitmapData(widthheightfalse0x000000);
m_bdGroundLayer = new BitmapData(widthheightfalse0x000000);
m_bdDetailsGroundLayer = new BitmapData(widthheighttrue0x000000);
m_bdStaticLayer = new BitmapData(widthheighttrue0x000000);
}
  
public function combineLayers():void
{
m_MainLayer
.copyPixels(m_bdGroundLayerm_bdGroundLayer.rect, new Point());
m_MainLayer.copyPixels(m_bdDetailsGroundLayerm_bdDetailsGroundLayer.rect, new Point(),m_bdDetailsGroundLayer, new Point(), true);
m_MainLayer.copyPixels(m_bdStaticLayerm_bdStaticLayer.rect, new Point(),m_bdStaticLayer, new Point(), true);
}

public function get mainLayer():BitmapData
{
combineLayers
();
return 
m_MainLayer;
}
  
public function get groundLayer():BitmapData 
{
return m_bdGroundLayer;
}
  
public function set groundLayer(value:BitmapData):void 
{
m_bdGroundLayer 
value;
   

Richard Olsson, Administrator
Posted: 27 August 2012 09:30 AM   Total Posts: 1192   [ # 1 ]

This sounds like a bug in your own code and in no way related to Away3D, am I right?

After you have copied your pixels to m_MainLayer, any changes to other bitmaps will have no effect. You have to re-merge the “layers” into the main bitmap again. Does that answer your question? Otherwise, please try to explain what you have already tried, and why that didn’t work.

   

Mafiy, Newbie
Posted: 30 August 2012 07:22 AM   Total Posts: 15   [ # 2 ]

I fixed this problem by other way. most optimized
Now I have one texture and three-dimensional array which contains bitmapdata for each cells of maps.

m_MapView.addObject(m_MapData.get2DCell(xy).layerxy);

public function 
addObject(objectsName:Array, x:uinty:uint):void
{
var uvPoint:Point = new Point(Grid.sizeGrid.size);
var 
textureMap:BitmapTexture m_MapMaterial.texture as BitmapTexture;
m_MapBitmapData textureMap.bitmapData.clone();
m_MapBitmapData.lock();
for (var 
i:uint 03i++)
{
 
if (objectsName[i].name != "")
 
{
  m_MapBitmapData
.copyPixels(m_ResManager.getObject(objectsName[i].name).frameTexture.getFrame(1), m_ResManager.getObject(objectsName[i].name).frameTexture.getFrame(1).rectuvPoint);
 
}
 
else
 
{
  m_MapBitmapData
.copyPixels(emptyBitmapemptyBitmap.rectuvPoint);
 
}
}
m_MapBitmapData
.unlock();
textureMap.bitmapData m_MapBitmapData;
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X