Transparency problem

Software: Away3D 4.x

dona, Jr. Member
Posted: 12 September 2012 12:19 PM   Total Posts: 46

Hi,

I’ve created a tree by combining 2 planes in crisscross order using maya. For material i’ve used both color and alpha map.And combined using copyChannel method.

here is the code:

var colorMap:BitmapData = TexturePool.getBitmapData(“tree_color_map”);
var alphaMap:BitmapData = TexturePool.getBitmapData(“tree_alpha_map”);
var combinedBitmap:BitmapData = new BitmapData(colorMap.width, colorMap.height, true);
combinedBitmap.copyPixels(colorMap, new Rectangle(0, 0, colorMap.width, colorMap.height), new Point());
combinedBitmap.copyChannel(alphaMap, new Rectangle(0, 0, alphaMap.width, alphaMap.height), new Point(), 1, BitmapDataChannel.ALPHA);
var bitmapTexture:BitmapTexture = new BitmapTexture(combinedBitmap);
mesh.material = new TextureMaterial(bitmapTexture);
TextureMaterial(mesh.material).alphaBlending = true;

But it shows transparency problem, I can see the plane through other plane. I’ve attached the screenshot, the transparent area is marked in red.

Anybody knows how to fix this issue?

Thanks

 

 

   

dona, Jr. Member
Posted: 12 September 2012 12:25 PM   Total Posts: 46   [ # 1 ]

I’m using away3D version:  4.0.9

   

dona, Jr. Member
Posted: 14 September 2012 08:17 AM   Total Posts: 46   [ # 2 ]

Anybody knows, how to apply png as mesh material?

I tried following method. But it makes unwanted transparency.

textureMaterial.alphaBlending = true; 

mesh.material= textureMaterial;

Thanks

 


   

Arno, Newbie
Posted: 14 September 2012 08:48 AM   Total Posts: 25   [ # 3 ]

There is not one perfect solution. These are some options

1) You can try to use textureMaterial.alphaThreshold = 0.5; (tweak the number to remove the white edges)

2) Set the pivot of one plane on far behind the other plane. This only works if you see the planes from one side. If you can rotate around the object it isn’t working

3) never tested this myself but give the plane more surfaces. If you did it right you now have 2 planes with each 2 surfaces. Just split them a few times.


Note: it is needless to do these things in maya. Just use away3d to do this it is lighter and more flexible. Just do this:

//merge for merging all meshes and re use geometry
var merge:Merge = new Merge(true);

//create empty mesh that will contain the whole plant
var plantMesh:mesh = new Mesh(new Geometry());

//create one side plane 4,4 is the number of defenision
var bushSideMesh:Mesh =  new Mesh(new PlaneGeometry(2000, 2000, 4,4,true,true), textureMaterial);

//merge one side inside the plantMesh
merge.apply(plantMesh, bushSideMesh);

//rotate the bushSide
bushSideMesh.rotationY = 90;

//Apply rotation inside the mesh this is faster
MeshHelper.applyRotations(bushSideMesh);

//tells merge to delete the mesh after merge
merge.disposeSources = true;

//merge other side of the plant. Now you have a cross
merge.apply(plantMesh, bushSideMesh);

view3d.scene.addChild(plantMesh);

 

   

dona, Jr. Member
Posted: 14 September 2012 09:57 AM   Total Posts: 46   [ # 4 ]

alphaThreshold works, Thanks a lot!

I thought to use maya for setting the level.

 

 

   

Arno, Newbie
Posted: 14 September 2012 10:12 AM   Total Posts: 25   [ # 5 ]

Level for what? Transparancy?

   

dona, Jr. Member
Posted: 14 September 2012 10:21 AM   Total Posts: 46   [ # 6 ]

No i was thinking to set the game level using maya.

   

Arno, Newbie
Posted: 14 September 2012 11:23 AM   Total Posts: 25   [ # 7 ]

For positioning maya is good but simple primitives can be made in away3d. You can save a lot of data with this. You can position your model in maya with a cube as representation of you bush and just copy the coordinates to the mesh

plantMesh.transform.position = new Vector3D(2000, 0 500);

   

dona, Jr. Member
Posted: 14 September 2012 11:51 AM   Total Posts: 46   [ # 8 ]

that’s a good idea…after your suggestion, i got Ogre scene exporter, i think with some minor modifications, we can use it for level editing.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X