0

下面我特意制作了一个测试脚本:你可以在www.parele.com/plane.html上看到它 所有源代码都在下面,我想要做的是改变我的网格......请注意:我想改变材料我的模型网格,到另一种颜色,任何颜色都不会创建一个新平面,因为这个样本是一个例子来测试这个不是我的实际爱好项目,我很乐意提供任何需要的文件或信息..我一直在这整整 20 多个小时被困在这里,它杀死了我

import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.containers.ObjectContainer3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
import away3d.containers.ObjectContainer3D;
import away3d.loaders.Loader3D;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import away3d.*;
import away3d.materials.ColorMaterial;
import away3d.materials.TextureMaterial;
import away3d.textures.BitmapTexture;
import sunag.animation.AnimationTarget;
import sunag.events.SEAEvent;
import sunag.sea3d.SEA3D;
import away3d.materials.methods.*;
import away3d.primitives.*;
import away3d.textures.*;
import away3d.utils.*;
import away3d.events.*;
[SWF(width = "955",height = "600",frameRate = "50")]
var view:View3D;
var scene:Scene3D;
var sea3d:SEA3D;
var _container:ObjectContainer3D = new ObjectContainer3D();
[Embed(source = "Models/plane.sea",mimeType = "application/octet-stream")]
var homepage:Class;
stage.stageFocusRect = false;
stage.showDefaultContextMenu = false;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
scene = new Scene3D();
view = new View3D(scene);
view.backgroundColor = stage.color;
view.antiAlias = 4;
var dat:BitmapData = new BitmapData(256, 256, false, WHATEVERCOLOUR);
var mMaterial = new TextureMaterial(new BitmapTexture(dat));
scene.addChild(_container);
addChild(view);
sea3d = new SEA3D();
view.blendMode = BlendMode.NORMAL;
sea3d.addEventListener(SEAEvent.COMPLETE, onComplete);
sea3d.loadBytes(new homepage());

function onEnterFrame(e:Event):void
{

 var body1:Mesh = sea3d.getMesh("body");
 body1.material = mMaterial;
 view.render();
 }
 function onComplete(e:SEAEvent):void
 {
 view.camera = sea3d.getCamera("Camera001");
  stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
  scene.addChild(sea3d.container);
 }
4

1 回答 1

1

我相信这就是你要找的东西:SubMeshes

从模型中提取的网格通常至少由 SubMesh 组成,但可以包含多个。更改该“根”网格对象上的材质不会传播到其子网格。您需要遍历其子网格并更改其材质。

hth。

于 2012-12-19T01:55:45.623 回答