2011-09-01 63 views
1

我已經加載了一個使用3DS分析器的模型,該分析器已經鏈接到一個材質並加載正常。我想讓這個模型成爲半透明的一部分,但不是全部。我想只設置alpha = .5,但是當我瞄準不是選項的material時。Away3D(4.x掃帚) - 如何設置加載3DS文件的材質的alpha值?

下面是代碼,並使用:

 var slingPar:Max3DSParser = new Max3DSParser(); 
     var slingLoader:Loader3D = new Loader3D(); 
     sling = new ObjectContainer3D(); 
     slingLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, function(e:LoaderEvent):void 
     { 
      var mesh:Mesh = Mesh(sling.getChildAt(0)); 
      mesh.material.lights = [light1, light2, light3]; 
      mesh.rotationY = 180; 

     }); 
     slingLoader.load(new URLRequest("assets/game/slingCup.3DS"),slingPar); 
     sling = slingLoader; 

我試圖

mesh.material.alpha = .5 

但沒有運氣。有任何想法嗎?

回答

1

我想通了。我定位了加載網格的BitmapMaterial並從那裏進行了修改。

slingLoader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, function(e:LoaderEvent):void 
     { 
      var mesh:Mesh = Mesh(sling.getChildAt(0)); 
      var map:BitmapMaterial = mesh.material as BitmapMaterial; 
      map.ambient = .5; 
      map.specular = .5; 
      map.alpha = .8; 
      map.lights = [light1, light2, light3]; 
      map.repeat = true; 
      map.smooth = true; 
      map.bothSides = false; 

     }); 
0

試試:

var mesh:Mesh = [the mesh for changing] 
for each (var item:SubMesh in mesh.subMeshes) { 
item.material = null; 
} 
mesh.material = new ColorMaterial(0xFF00FF, ALPHA); 
相關問題