Hi Jojo,
You need to save the Object3DLoader.handle object instead of the
Object3DLoader itself.
the handle is the loaded geometry as Object3D
for the obj format this means it can be an ObjectContainer3D, most of
the time because you grouped meshes into your editor, (G tag into the
obj file)
Mesh(es) or both. So you need to parse the handle according to your
3D
object (obj file).
for instance on onLoaderSuccess
the obj1.handle Object3D can be a Mesh or an ObjectContainer3D
If the obj file contains just a single mesh, you can access the
geometry information like this:
function addOnSuccessresult
var mesh:Mesh = obj1.handle as Mesh;
trace(mesh.vertices.length);
mesh.material = somenewMaterial;
while if the obj file is a group of meshes the above code would
generate an error, since the handle is not a Mesh but an
ObjectContainer3D
trace("there are "+obj1.handle.children.length+" objects in
this
file");
var mesh:Mesh = (obj1.handle as
ObjectContainer3D).children[0];
If you have variable structure and you want to automate, just add a
recursive parsing on loaded success,
Take a look in Weld class, Mirror class code to see how its done.
hiding an object is as simple as adding the property visible true/
false to it.
when set to false, the object is ignored by the engine for the
rendering.
Welcome to Away!
Fabrice
On Apr 24, 2009, at 6:26 AM, jojo wrote:
Hello,
I'm new to oop, flash, and away3d but trying hard reading
examples,etc ... just can't get mind around certain concepts ...
Couple questions ...
Suppose I read in an exported .obj file (textures come in fine) as
such:
import away3d.loaders.Obj;
public var obj1:Object3DLoader;
var material:BitmapFileMaterial = new BitmapFileMaterial
("bitmap1.jpg");
obj1 = Obj.load("teepot1.obj", { material:material } );
All good to that point ...
1. How do I get access to mesh vertices to be able to manipulate
obj1?
I know it's mesh.vertices but all examples I've seen just don't make
sense (not sure the basic setup). Could I get a little extra
clarification as to where to begin having obj1 in hand?
2. If I then read in another obj file (which I verified can be
read in
and texture file is ok) how do I switch back and forth displaying
one
or the other?
I've tried:
if (objtoload=2) { scene.addChild(obj2);scene.removeChild(obj1); }
via a button handler but I get the original obj and then a cube of
some sort with a texture of text saying "Loading Geometry ..." over
top of original obj ...
using Flash CS4 (demo), away3D 3.3.3, btw
Thanks- Hide quoted text -
- Show quoted text -