This should work.
At least according to what you say and write.
What also is possible is that the directory in which the files are is
locked or not having sufficient privileges.
I also can see you took over the examples
headObj = (e.loader.handle as ObjectContainer3D).children[0];
headObj.x = headObj.y = headObj.z = 0;
since you add the loader to the scene, both lines are unnecessary.
Its in the example there, just to show how to access or change
properties of the loaded object(s)
the autoload property is not a Obj class property. If the parser finds
an mtl tag, it will load the mtl, parse it and set the materials.
Try to look in the file if you see between the vt and f tag
usemtl Texture3
If the problem persist and you are sure all urls are ok, send your
file offline over to me, I'll look at it.
Fabrice
On May 25, 2009, at 4:02 AM, EagleHawk wrote:
Thanks for the quick reply Fabrice. I did actually know that and the
following files are all in the same folder - neutral.obj, neutral.mtl,
neutral_skin_hi.jpg, etc.
In my neutral.obj file I have the following line,
mtllib neutral.mtl
And in neutral.mtl I have,
newmtl Texture3
Ns 20
d 1
illum 2
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd neutral_skin_hi.jpg
It seems to me that the files and the locations are all correct and I
can open the OBJ in other viewers such as GLC Player with no problem
too. So the problem must be in my code I think but I can't see
anything wrong compared to the examples I've seen. I've pasted the
relevant sections below.
private function loadMyObjFile (url: String): void
{
var loader: Object3DLoader = Obj.load (url, {autoLoadTextures: true,
bothsides: false});
loader.addOnSuccess (onLoaderSuccess);
view.scene.addChild (loader);
}
private function onLoaderSuccess (e: LoaderEvent): void
{
headObj = (e.loader.handle as ObjectContainer3D).children[0];
headObj.x = headObj.y = headObj.z = 0;
camera.target = headObj;
addEventListener (Event.ENTER_FRAME, onEnterFrame);
}
The only other possibility I can think of is that I'm working with
Away3D 2.3.3 and FP9. Do I need to upgrade to Away 3.3.3 and FP10?
Thanks,
Richard.
PS The software that exported the model is called FaceGen.
On May 25, 1:47 am, Fabrice3D <[email protected]> wrote:
Hi Richard and welcome to Away,
You do not see the material because you do not have the mtl file
placed next to the sources.
If your mtl would be missing but tagged into the obj file, you would
see default white bitmapmaterials and you would probably see an error
triggered by the mtl parser.
the first line in the obj file says: use mtl + url, according to
wavefront specs, the mtl must be next to the obj file
since the mtl adres is resolved from the obj url. the mtl contains
the
url of the sources bitmaps.
in short from your exporter you should get this:
myobject.obj --> holds geometry data and mtl adress
myobject.mtl --> holds materials information + sources urls per
materials
source.jpg --> sources most of the time located next to mtl or in map
"images" located in same map as the mtl
Since you get no errors and see random fill materials, your exporter
probably have exported only the geometry information.
What is the exporter you are using?
Fabrice
On May 24, 2009, at 6:22 PM, EagleHawk wrote:
Hi,
I'm loading an OBJ file that has accompanying materials and textures
file. So far, the mesh loads fine but I can't get the textures to
display. All I get each time is the mesh showing the random colours.
From everything I've found in the forum here and elsewhere, I'm
led to
believe that as long as the materials file and the OBJ file are in
the
same folder and have the same name then Away3D should auto load the
textures.
One of the things I tried from an example I found was to include an
autoLoadTextures property in the init object for the loader.
During a
debug process the only message I get is that autoLoadTextures is an
unused argument.
So my question is how exactly does one load the textures associated
with the OBJ file?
Thanks,
Richard.