Thanks for the response, Fabrice :)
obj1.visible=false; ... Ah very good and should have been obvious to
me ... I feel a bit silly ...
tried it but didn't work but I think that is because button isn't
working ... I'll get it working
All single meshes for now ... so I tried:
private var obj13d:Object3D;
obj1 = Obj.load("assett/teapot_1.obj", { material:material } );
obj1.addOnSuccess(onLoaderSuccess);
private function onLoaderSuccess(e:LoaderEvent):void
{
var mesh:Mesh = obj1.handle as Mesh;
trace(mesh.vertices.length);
}
but got compile "output":
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at Basic_Cube/onLoaderSuccess()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at away3d.loaders::Object3DLoader/notifySuccess()
at away3d.loaders::Object3DLoader/onParserComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at away3d.loaders::AbstractParser/notifySuccess()
at away3d.loaders::AbstractParser/parseNext()
at away3d.loaders::Object3DLoader/startParsingGeometry()
at away3d.loaders::Object3DLoader/onGeometryComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Do I have obj13d as the mesh or is that output saying something else?
Sorry for all the low level questions ... btw I'm excited to be
"trying" to learn away3d because I've read so many things about it.
Good job!
On Apr 24, 12:35 am, Fabrice <[email protected]> wrote:
> 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 -