Hi Roland,
Thanks for the response.
I see what you are getting at, however, does this work for a
BitmapFileMaterial?
Let me try again to explain what I'm doing.
I have 1 .obj file (i.e. teapot_1.obj) ...
I have several different bipmap files (i.e. teapot_1.jpg,
teapot_2.jpg) that I can swap around when I load initially (removed
texture & mtl info in .obj file) as such:
= Obj.load("assetts/teapot_1.obj",{material:texture3});
or
= Obj.load("assetts/teapot_1.obj",{material:texture2});
or
= Obj.load("assetts/teapot_1.obj",{material:texture1});
They all load fine because I coordinated the UV mapping for all to the
object.
Is there a way to break apart the Obj.load such that I load the obj
first:
= Obj.load("assetts/teapot_1.obj")
and then load textureX (i.e. teapot_1.jpg) with seperate "command"?
I thought I saw a basic example where it was done in 2 steps but I
can't find the example now ...
On Apr 27, 12:57 am, routine <[email protected]> wrote:
> Hi Joseph,
>
> you get an errror because Object3D does not have any material property.
> To swap materials on importedobjects you have to parse through all its
> faces
> and set the material of the faces to the one you like to have.
>
> Here is a litte snippet for you:
>
> for ( var i : Number = 0; i < object.children.length; i++ ) {
> for ( var j : Number = 0; j < object.children[i].faces.length; j++ ) {
> object.children[i].faces[j].material = new
> ShadingColorMaterial( c );
> }
>
> }
>
> In this case "object" will be your Object3D instance.
>
> Hope this works. If not, try ObjectContainer3D instead of Object3D.
>
> Roland
>
> Am 27.04.2009 um 09:49 schrieb Joseph:
>
>
>
>
>
> > Hello,
> > Been looking at source code for (Basic09_BitmapMaterialExplorer.as).
> > Want to swap textures back and forth on an .obj ... not quite working,
> > though ...
>
> > Flex framework brought into project library ... CS4, away3d 3.3.3 ...
>
> > Import relavent away3d classes:
> > import away3d.core.utils.Cast;
> > import away3d.materials.BitmapMaterial;
>
> > I embed a couple of textures:
> > [Embed(source="assetts/teapot_1.jpg")]
> > public var texture1:Class;
> > [Embed(source="assetts/teapot_2.jpg")]
> > public var texture2:Class;
>
> > Declare material variables:
> > private var material1:BitmapMaterial;
> > private var material2:BitmapMaterial;
>
> > Load in .obj:
> > var obj1:Object3DLoader = Obj.load("assetts/teapot_1.obj",
> > {material:texture1});
>
> > On success grab handle:
> > obj1object3d = e.loader.handle;
>
> > Create new materials:
> > material1 = new BitmapMaterial( Cast.bitmap( new this[texture1]() as
> > Bitmap ));
> > material2 = new BitmapMaterial( Cast.bitmap( new this[texture2]() as
> > Bitmap ));
>
> > On button press simply toggle materials with these calls:
> > obj1object3d.material = material1;
> > or
> > obj1object3d.material = material2;
>
> > But get error for the toggle material calls ...
> > 1119: Access of possibly undefined property material through a
> > reference with static type away3d.core.base:Object3D.
>
> > Obviously for a primitive sphere.material works but for Object3D I
> > have to get it another way ... how would I do that?
>
> > BTW, all these things I'm learning I'm compiling into a "Common Noob
> > Mistakes" to help others as low level as I ...- Hide quoted text -
>
> - Show quoted text -