2012-11-29 40 views
0

我似乎無法找到解決的辦法,反正基本上我嘗試了新的動態紋理添加到使用的Away3D引擎閃光燈AS#3變材料紋理

var myImage:BitmapData = new BitmapData(256, 256, true,0xFFFFFFFF); 

    // i cant seem to reference this to my 3D model in the example: Myevent(enter frame): 

    myModel.material = new TextureMaterial(new BitmapTexture(myImage)) 

我曾沿着嘗試不同的東西3D模型上面的方法,我已經檢查了away3d文檔,並找不到類似的我目前的情況:

即時通訊使用最新的Away3d庫,和Flash播放器11 ...我所有的模型的工作原理和負載與嵌入式materialtTextures,IM只是試圖將它們更改爲我已動態創建的位圖或紋理

+0

你流汗什麼錯誤? – Gone3d

+0

damm我以爲你有一個答案卡住了這一天,其驅使我瘋了....即時通訊沒有錯誤,只是我的材料沒有改變,四嘗試渲染();和更新方法.....沒有工作,我不知道 – joshua

回答

2

到這裏看看:

https://github.com/away3d/away3d-tutorials-fp11/blob/master/tutorials/materials/basic_shading/src/Basic_Shading.as

他們使用的Away3D的演員實用工具類創建BitmapTexture對象,他們還添加不同的紋理貼圖的一羣 - 希望這可以幫助

**編輯 - - 本教程並工作**

新增

public bmt:BtiMapTexture; 

.... 
private function initMaterials():void { 
    this.bmt = new BitmapTexture(new BitmapData(256,256, true, 0x222277FF)); 
    sphereMaterial = new TextureMaterial(Cast.bitmapTexture(this.bmt)); 
    sphereMaterial.specularMap = Cast.bitmapTexture(this.bmt); 
    sphereMaterial.lightPicker = lightPicker; 
} 

我有一個不錯的藍色球體

+0

不,這沒有任何幫助,這個例子只是加載圖像(JPEG)添加到網格或對象,我沒有任何JPEG只是試圖使我的模型材質更改爲我已動態創建的位圖.... – joshua

+0

var myImage:BitmapData = new BitmapData(256,256,true,0xFFFFFFFF);這是我想要的模型 – joshua

+0

您是否需要它作爲紋理,或者您可以使用ColorMaterial進行此操作嗎? – Gone3d

0

我的解決辦法是:

var mesh:Mesh = 'the mesh for changing' 
for each (var item:SubMesh in mesh.subMeshes) { 
item.material = null; 
} 
mesh.material = new ColorMaterial(0xFF00FF);