Texture Swapping

Software: Away3D 3.x

Adam, Newbie
Posted: 01 March 2012 10:33 PM   Total Posts: 1

I’m using Away3D 3.6 since it seems to better match the documentation.

Anyway I’m starting the process of evaluating Away3D for a bunch of upcoming projects. I usually start with just trying some of the basic things I know I need to accomplish.  In my case i’m loading a very simple obj model and setting it to some random material that I created.

How do I change the material that is displayed on the model.

//What i'm using now
loader.loadGeometry("Assets/001.obj", new Obj({materialmat} ));

//First thing I tried
loader.material = new ColorMaterial0xFFFFFF );
loader.updateMeshnull );

//2nd thing I tried in an event
loader.handle.material = new ColorMaterial0xFFFFFF );
loader.updateMeshnull );

//3rd thing, I tried this in the callback when the mesh is done loading
Loader3D(e.target).handle as Mesh ).material mat;
Loader3D(e.target).handle as Mesh ).updateMesh(null); 

So what is the correct way to switch the material during runtime?

Thanks in Advance,
Adam

   

Mr Margaret Scratcher, Sr. Member
Posted: 02 March 2012 02:29 AM   Total Posts: 344   [ # 1 ]

This for me works:

caseMaterials = new TextureMaterial(new BitmapTexture(caseBMD))
    
caseMaterials.ambientColor 0x505080;
    
caseMaterials.gloss 500;
    
caseMaterials.specular .6;
    
p.material caseMaterials

Where p is a mesh I created earlier with a different material…

So basically, make a material, and then do


yourMesh.material = newMaterial;

   

Mr Margaret Scratcher, Sr. Member
Posted: 02 March 2012 02:30 AM   Total Posts: 344   [ # 2 ]

Oh, that may not work - I’m using away3d 4….red face

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X