Issue with transparency/alpha

Software: Away3D 4.x

Julien, Newbie
Posted: 04 October 2012 08:37 PM   Total Posts: 2

Hi!

I am new with away3D and am experiencing some of its functionalities at the moment, and I already got stuck at one. I followed a tutorial (that I can’t seem to find again…damn) to import a .3ds mesh I created in blender, and successfully applied a texture over it, but I cannot find out how to change its alpha value.

Should it happen at this moment?

function loadModel3D():void
{
    _objLoader 
= new Max3DS();
 
    
// redimentionner le modèle 3D, multiplie par 8 sa taille
    
_objLoader.scaling 8;
    
// analyse le fichier 3DS pour en faire un ObjectContainer3D
    
_model3D _objLoader.parseGeometry(_model3DLoader.data) as ObjectContainer3D;
 
 
// récupère le premier enfant de _model3D pour lui appliquer la texture
 
(_model3D.children[0] as Mesh).material =  new BitmapFileMaterial("texture_crystal3.png");
 
 
// lisse la texture
 
((_model3D.children[0] as Mesh).material as BitmapFileMaterial).smooth true;
 
    
// ajoute _model3D sur Scene3D puis on le place bien
    
_scene.addChild(_model3D);
    
_model3D.rotationX = -90;
    
_model3D.10;
 
    
addEventListener(Event.ENTER_FRAMErefresh);

I am also wondering whether it is normal that my shape isn’t transparent, since it was in blender…

Any idea? I guess it’s normal to be a bit confusing while trying something new smile


Thank you in advance for your help.


julien.


P.S. : I join my .fla with the post, but without the shape and the texture which I guess aren’t needed.

 

File Attachments
CrystalTest4.fla  (File Size: 6KB - Downloads: 0)
   

Julien, Newbie
Posted: 04 October 2012 08:37 PM   Total Posts: 2   [ # 1 ]

Maybe I am missing a library?

   

Drones, Newbie
Posted: 05 October 2012 04:45 PM   Total Posts: 3   [ # 2 ]

Hi, i’m having the same problem.
Can’t find a way to change the alpha of the .3ds model.

   

Avatar
alihm, Jr. Member
Posted: 05 October 2012 05:30 PM   Total Posts: 49   [ # 3 ]

You need to change materials alpha property:
your_material.alpha=0.5;

   

Drones, Newbie
Posted: 05 October 2012 05:30 PM   Total Posts: 3   [ # 4 ]

But the material is loaded with the 3ds model.

   

Avatar
80prozent, Sr. Member
Posted: 05 October 2012 05:45 PM   Total Posts: 430   [ # 5 ]

use your loadet mesh to access the material

yourLoadetMesh.material.alpha=0.5

if you have multiple submeshes do this:

for (var i:int=0;i<yourLoadetMesh.subMeshes.length;i++){
yourLoadetMesh
.subMeshes[i].material.alpha=0.5;

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Drones, Newbie
Posted: 05 October 2012 05:53 PM   Total Posts: 3   [ # 6 ]

I’m using the 4.0.9 Gold version, and in this version the Mesh.material does not have the .alpha property, only the alphaPremultiplied property, that is a boolean.

Thanks for your help!

   

Avatar
80prozent, Sr. Member
Posted: 05 October 2012 06:02 PM   Total Posts: 430   [ # 7 ]

just downloadet the 4.0.9 gold zip from the download site.

the ColorMaterial and the TextureMaterial both got alpha properties.

try this:

TextureMaterial(yourLoadetMesh.material).alpha=0.5

hope that helps

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
alihm, Jr. Member
Posted: 06 October 2012 04:06 PM   Total Posts: 49   [ # 8 ]

try this code:

var _loader:Loader3D = new Loader3D();
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoaded);
_loader.load(your_model);


function 
onModelLoaded(LoaderEvent):void
{
   _loader
.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonModelLoaded);


 for (var 
i:int 0_loader.numChildreni++)
 
{
  
var mesh:Mesh Mesh(_loader.getChildAt(i));
  
//do anything you want with your mesh
  
var material:TextureMaterial mesh.material as TextureMaterial;
  
//do anything you want with material
  
material.alpha0.5;
 
}
   

hope it helps

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X