Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS#3改变材质纹理_Actionscript 3_Flash_Flash Cs5_Away3d - Fatal编程技术网

Actionscript 3 AS#3改变材质纹理

Actionscript 3 AS#3改变材质纹理,actionscript-3,flash,flash-cs5,away3d,Actionscript 3,Flash,Flash Cs5,Away3d,我似乎找不到一个解决方案,反正我基本上是在尝试使用Away3d引擎和flash为3D模型添加一个新的动态纹理 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 Texture

我似乎找不到一个解决方案,反正我基本上是在尝试使用Away3d引擎和flash为3D模型添加一个新的动态纹理

   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))
我尝试了以上方法的不同方法,我检查了away3d文档,但找不到适合我当前情况的类似方法:

我使用最新的Away3d库和flash player 11…我所有的模型都可以工作并加载原始的嵌入材质纹理,我只是想将它们更改为我动态创建的位图或纹理看看这里:

他们使用Away3D的Cast实用程序类创建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;
}
我得到了一个漂亮的蓝色球体

我的解决方案是:

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

你犯了什么错误?妈的,我以为你有一个答案被困在这上面一天了,快把我逼疯了。。。。我没有得到任何错误,只是我的材料没有改变,我尝试了render();和更新方法…没有任何效果我没有主意啊,这根本没有帮助,这个例子只是加载图像(JPEG)以添加到网格或对象中,我没有任何JPEG,我只是尝试将我的模型材质更改为我动态创建的位图…var myImage:BitmapData=新的BitmapData(256,256,true,0xFFFFFFFF); 这是我的图像,我想在我的模型上你需要它是一个纹理还是你可以用彩色材质来代替它?它必须是一个纹理材质,我尝试使用上面的,再次没有错误,但也没有发生任何事情。。。不同之处在于,我有一个带有纹理的嵌入式模型,然后我尝试在运行时替换它。我让它用我上面发布的内容处理教程代码-看看有什么不同,看看它是否修复了它-你可能必须使用Cast.bitmapTexture()