change 3ds mesh material after loading 3ds file, on runtime

Software: Away3D 3.x

nomenomen, Newbie
Posted: 17 July 2012 11:10 AM   Total Posts: 3

Hi all,
I can’t get this material thing working. Searched google wide and deep with no results. Basically I am loading a 3ds file, single mesh ie one object (yes, with uvs) like this:

var my_mesh:Mesh;
//creating a parser with initial material
var max3ds_parser:Max3DS = new Max3DS();
max3ds_parser.material = new WireColorMaterial(0xFF0000);

var 
loader:Loader3D = new Loader3D();
loader.addEventListener(Loader3DEvent.ON_SUCCESSonSuccess);
loader.loadGeometry("myMesh.3ds"max3ds_parser);

function 
onSuccess(e:Loader3DEvent):void{
my_mesh 
Mesh(e.loader.handle);
view.scene.addChild(my_mesh)

Up until now everything is fine, the mesh appears in the view with red wirecolormaterial applied, but now I want to apply new material on the same my_mesh after a mouse click, so:

stage.addEventListener(MouseEvent.CLICKonClick);
function 
onClick(e:MouseEvent):void{
//FAIL cames here:
my_mesh.material = new WireframeMaterial(0x000000);
trace("clicked!");

Mighty Failure, can’t get this to work. Seems so simple but I can’t figure out how to change the material during run-time.
Thank you for any help.

   

nomenomen, Newbie
Posted: 17 July 2012 11:59 AM   Total Posts: 3   [ # 1 ]

also when I trace(my_mesh.material) it says that the material was changed but in the view my_mesh still has the old material applied, what am I doing wrong? Can you somehow update the scene so that my_mesh picks up new material?

   

nomenomen, Newbie
Posted: 17 July 2012 02:05 PM   Total Posts: 3   [ # 2 ]

now here is a good one for ya:

((my_mesh as ObjectContainer3D).children[0] as Mesh).material = new ShadingColorMaterial(0x000FF0); 

the code above is working, but this is NOT:

my_mesh.material = new ShadingColorMaterial(0x000FF0

go figure…
is there any other workaround to change material?

   

parele, Jr. Member
Posted: 30 November 2012 10:37 AM   Total Posts: 43   [ # 3 ]

you know what, iv been searching for this same thing for 20 hours or so literally, tried everything still cant get my_model.material = new texture to work…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X