Thanks for the snippet Rob. Unfortunately, some weird things are
happening that I cant explain. The material library comes back null
and when I trace out myObject I get "$: x:0 y:0 z:0" I have
successfully added the object to the stage and it shows up fine, but
whenever I try to trace any properties everything comes back null.
This is the function:
private function onObjLoaded( e:Loader3DEvent ):void
{
_obj = e.loader.handle;
_obj.scaleX = -1;
var matData:MaterialData = matLib.getMaterial(
"Material1" );
trace( matData );
var bitmapMat:BitmapMaterial = matData.material as
BitmapMaterial;
trace( bitmapMat );
matData.material = new
WhiteShadingBitmapMaterial( bitmapMat.bitmap );
_scene.addChild( _obj );
addEventListener( Event.ENTER_FRAME, onRender );
}
On Feb 2, 1:29Â pm, Rob Bateman <[email protected]> wrote:
> Hey charglerode
>
> once the object and texture has loaded, just do this:
>
> var myObject:Object3D = myLoader.handle
>
> var myMaterialLibrary:MaterialLibrary = myObject.materialLibrary
>
> var myMaterialData:MaterialData =
> myMaterialLibrary.getMaterial("myMaterial");
>
> var myBitmapMaterial:BitmapMaterial = myMaterialData.material as
> BitmapMaterial;
>
> myMaterialData.material = new
> WhiteShadingBitmapMaterial(myBitmapMaterial.bitmap);
>
> make sure the argument in the getMaterial() method is the name of the
> material you want to change in your obj file.
>
> cheers!
>
> Rob
>
>
>
>
>
> On Tue, Jan 26, 2010 at 8:48 AM, Fabrice3D <[email protected]> wrote:
> > access the materialdata and change the material
> > or parse the faces, nullify the materials and apply a new material
>
> > Fabrice
>
> > On Jan 26, 2010, at 8:48 AM, charglerode wrote:
>
> > > You got it Peter. Sorry for the confusion. The OBJ loader
> > > automatically loads the image from the MTL file, but always applies it
> > > as an away3d BitmapMaterial. I would like the loader to apply it as an
> > > away3d  WhiteShadingBitmapMaterial instead or any other away3d bitmap
> > > material I may want.
>
> > > On Jan 25, 6:24 am, Peter Kapelyan <[email protected]> wrote:
> > >> I think the subject of thread is his problem, he is loading an OBJ, an
> > >> instead of loading the bitmap to a BitmapMaterial, he'd like it to be a
> > >> WhiteShadingBitmapMaterial instead on his OBJ, and was wondering if
> > there is
> > >> some easy way to do it.
>
> > >> -Pete
>
> > >> On Mon, Jan 25, 2010 at 4:00 AM, Fabrice3D <[email protected]> wrote:
> > >>> I'm not sure I follow you here...
> > >>> If the obj doesn't load the image you want, edit in your 3d app or
> > alter
> > >>> the mtl file where the file url is stored.
>
> > >>> Fabrice
>
> > >>> On Jan 25, 2010, at 8:15 AM, charglerode wrote:
>
> > >>>> This means that I still have to load the texture separately. Since the
> > >>>> OBJ loader already loads the texture I would prefer it keep loading
> > >>>> the texture, but just let me specify which type of bitmap material to
> > >>>> use when applying it. Is this possible? If I have to load the texture
> > >>>> myself, then that means I have to keep a reference to a JPG file for
> > >>>> each OBJ file, which kind of defeats the purpose of using an OBJ file
> > >>>> especially since I am trying to avoid constant republishing.
>
> > >>>> On Jan 24, 10:47 am, Fabrice3D <[email protected]> wrote:
> > >>>>> once loaded, just parse the handle, and when a mesh type is found
> > >>> apply...
> > >>>>> Look for example in geom package at Mirror.as line 246 code, you need
> > >>> write something recursif like this...
>
> > >>>>> Fabrice
>
> > >>>>> On Jan 24, 2010, at 6:23 AM, charglerode wrote:
>
> > >>>>>> This doesn't work because when I load in the OBJ file, I grab the
> > >>>>>> handle as an ObjectContainer3D which does not have a material
> > >>>>>> property. Searching around here only turned up a method which
> > requires
> > >>>>>> I loop through and set the material of each individual face of mesh.
> > >>>>>> This also requires that I load in the JPG separately instead of
> > >>>>>> letting the OBJ loader handle it. I'd like the OBJ loader to handle
> > >>>>>> loading of the mesh and the texture on its own, but I would like to
> > >>>>>> specify which type pf bitmap material to use. Is it possible to cast
> > >>>>>> the loaded OBJ handle as an instance of Mesh, seeing as Mesh has a
> > >>>>>> material property?
>
> > >>>>>> On Jan 22, 6:36 am, Peter Kapelyan <[email protected]> wrote:
> > >>>>>>> Hi did you you try a simple:
>
> > >>>>>>> myObject.material=someOthermaterial;
>
> > >>>>>>> in case you dont want to reload the bitmap you can probably do
> > >>> something
> > >>>>>>> like:
>
> > >>>>>>> var myBitmap(orData,I forget)=myObject.material.bitmap;
>
> > >>>>>>> Hope I didn't miss the point of your question
>
> > >>>>>>> -Pete
>
> > >>>>>>> On Fri, Jan 15, 2010 at 2:25 AM, charglerode <
> > [email protected]>
> > >>> wrote:
> > >>>>>>>> Is it possible to load an OBJ, but have the loader apply the JPG
> > >>>>>>>> texture as a WhiteShadingBitmapMaterial ( or any other ) instead
> > of
> > >>>>>>>> just a plain BitmapMaterial?
>
> > >>>>>>>> The reason I'm asking it because I would like to apply lights to
> > the
> > >>>>>>>> scene, but plain BitmapMaterials don't seem to react to lights. I
> > >>>>>>>> don't want to have the overhead of loading texture separately and
> > >>>>>>>> applying them face by face. Seems like a lot of unnecessary work.
>
> > >>>>>>> --
> > >>>>>>> ___________________
>
> > >>>>>>> Actionscript 3.0 Flash 3D Graphics Engine
>
> > >>>>>>> HTTP://AWAY3D.COM
>
> > >> --
> > >> ___________________
>
> > >> Actionscript 3.0 Flash 3D Graphics Engine
>
> > >> HTTP://AWAY3D.COM
>
> --
> Rob Bateman
> Flash Development & Consultancy
>
> [email protected]