How to Change TextureMaterial and Heightmap?

Software: Away3D 4.x

dubletar, Member
Posted: 05 January 2014 03:43 PM   Total Posts: 73

Hi all,

I created a 3d extrude landscape, but I am trying to change the TextureMaterial and Height Map from a newly downloaded texture and heightmap, while the extrude is already generated.

I cannot figure out how to do this, can anyone help?

Please help and thank you very much.

   

Avatar
theMightyAtom, Sr. Member
Posted: 06 January 2014 07:40 AM   Total Posts: 669   [ # 1 ]

Can you post your code? It might be as simple as invalidating the previous texture.

yourTexture.invalidateContent();

This is necessary when updating a bitmapTexture.

Good Luck!

   

dubletar, Member
Posted: 09 January 2014 03:22 AM   Total Posts: 73   [ # 2 ]

Thanks for the response. The code is below. It checks if a terrain exists, if not, it creates it. That’s fine. However, I dont know how to properly update the created Elevation with the new texture and new heightmap.

I really appreciate the help.

// Create the new texture
var leTxtr:BitmapData = new BitmapData(20482048false0x00000000);
leTxtr.draw(mapImgCon);

var 
terrainMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(leTxtr));
terrainMaterial.ambientColor 0x303040;
terrainMaterial.ambient .5;
terrainMaterial.specular 0;    terrainMaterial.addMethod(globals.vars.fogMethod);
    
//create the heightmap
var leHMap:BitmapData = new BitmapData(20482048false0x00000000);
leHMap.draw(mapHgtCon);
     
// Check if there is a terrain present
if (terrain == false)
{
terrain 
= new Elevation(terrainMaterialleHMap20483820482502502550false);
terrain.name 'tile';
terrain.= -9;
addChild(terrain);
}
else
{
// If the terrain already exists, change the texture and the heightmap with the new texure and heightmap

/* This is the area with the problem. I dont know how to change the texture and/or the heightmap, and have the 3D terrain to update */
terrain.material terrainMaterial;
trace('elevation updated');
   

Avatar
theMightyAtom, Sr. Member
Posted: 09 January 2014 02:28 PM   Total Posts: 669   [ # 3 ]
terrain.material terrainMaterial;
((
terrain.material as TextureMaterial).texture as BitmapTexture).invalidateContent();
trace('elevation updated'); 

That should refresh the texture after you assigned the material (which is already assigned?)

The Elevation class doesn’t appear to support an update of it’s height map :(
You could add this functionality to it, or dispose of it and create a new mesh.

Good Luck!

   

dubletar, Member
Posted: 09 January 2014 08:28 PM   Total Posts: 73   [ # 4 ]

Do you know of any other alternative classes to Elevation that allows change to heightmaps?

   

dubletar, Member
Posted: 09 January 2014 08:38 PM   Total Posts: 73   [ # 5 ]

Actually, I found it here.

http://away3d.com/forum/viewthread/1110/#3808

   
   
‹‹ Problem with a path

X

Away3D Forum

Member Login

Username

Password

Remember_me



X