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:uint, y:uint):void
{
var point:Point = new Point(x, y);
var 
textureMap:BitmapTexture = m_MapView.materialPlane;
 
m_Layers.groundLayer.copyPixels(m_Brush.brushData, m_Brush.rectBrush, point);
m_Layers.combineLayers(); //merge textures
textureMap.bitmapData = m_Layers.mainLayer;
} 

m_Layers:

public function Layers(width:uint, height:uint) 
{
m_MainLayer 
= new BitmapData(width, height, false, 0x000000);
m_bdGroundLayer = new BitmapData(width, height, false, 0x000000);
m_bdDetailsGroundLayer = new BitmapData(width, height, true, 0x000000);
m_bdStaticLayer = new BitmapData(width, height, true, 0x000000);
}
  
public function combineLayers():void
{
m_MainLayer
.copyPixels(m_bdGroundLayer, m_bdGroundLayer.rect, new Point());
m_MainLayer.copyPixels(m_bdDetailsGroundLayer, m_bdDetailsGroundLayer.rect, new Point(),m_bdDetailsGroundLayer, new Point(), true);
m_MainLayer.copyPixels(m_bdStaticLayer, m_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(x, y).layer, x, y);

public function 
addObject(objectsName:Array, x:uint, y:uint):void
{
var uvPoint:Point = new Point(x * Grid.size, y * Grid.size);
var 
textureMap:BitmapTexture = m_MapMaterial.texture as BitmapTexture;
m_MapBitmapData = textureMap.bitmapData.clone();
m_MapBitmapData.lock();
for (var 
i:uint = 0; i < 3; i++)
{
 
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).rect, uvPoint);
 
}
 
else
 
{
  m_MapBitmapData
.copyPixels(emptyBitmap, emptyBitmap.rect, uvPoint);
 
}
}
m_MapBitmapData
.unlock();
textureMap.bitmapData = m_MapBitmapData;
} 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X