I think it's actually the Collada objects that dispatch the
ParserEvents. I tried it like:
c0.addEventListener(ParserEvent.PARSE_SUCCESS, pe);
c1.addEventListener(ParserEvent.PARSE_SUCCESS, pe);
c2.addEventListener(ParserEvent.PARSE_SUCCESS, pe);
private function pe(e:ParserEvent):Void
{
ps++;
if (ps == 3) {
parseComplete();
}
}
private function parseComplete():Void
{
mp = new Morpher(m1);
addEventListener(Event.ENTER_FRAME, ef);
}
But alas, the m0, m1, m2 all have nothing in the vertices. If I try
tracing these out every frame same thing. The strange thing is that
the data MUST be there as it renders fine.
Any ideas?
On Feb 22, 11:14 am, Cauê Waneck <[email protected]> wrote:
> Hey Tarwin!
>
> Have you got the Morpher working with Lite? The problem with the empty
> arrays is that since the parser works asynchronously, you'll only get the
> results when the ParserEvent.PARSE_SUCCESS is dispatched for each parsed
> geometry. So you've got to m0.addEventListener(ParserEvent.PARSE_SUCCESS,
> onSuccess), for every parser object.
>
> It's kind of hard to get the Morpher working with complex geometries, since
> it all comes down to the way the geometry was exported - to map each source
> vertex to the destination vertex. So let us know if you've been able to do
> it!
>
> cheers
> Cauê
>
> 2010/2/21 tarwin <[email protected]>
>
>
>
> > Hi,
>
> > I've moved the Morpher (core.base.Morpher) to Away3D Lite (actually
> > I'm using the haXe version, but same difference), and got it working
> > perfectly with geometry created programmatically ie "new Sphere(...);"
> > but am having trouble getting it to work with Collada objects.
>
> > I'm guessing this is something to do with Collada objects (those given
> > by .parseGeometry) are different in some way. The problem I'm facing
> > is that anything I send to the Morpher from parseGeometry just has an
> > empty vertices Vector<Float>.
>
> > My code looks as follows:
>
> > ---------------------------------------------------------------------------
> > --------------
>
> > override private function init():Void
> > {
> > super.init();
>
> > var daeData1 = Resource.getString("dae1");
> > var daeData2 = Resource.getString("dae2");
>
> > var c0 = new Collada();
> > var c1 = new Collada();
> > var c2 = new Collada();
>
> > m0 = cast c0.parseGeometry(daeData1);
> > m1 = cast c1.parseGeometry(daeData1);
> > m2 = cast c2.parseGeometry(daeData2);
>
> > mv0 = c0.geometryLibrary.getGeometryArray()[0].vertices;
> > mv1 = c1.geometryLibrary.getGeometryArray()[0].vertices;
> > mv2 = c2.geometryLibrary.getGeometryArray()[0].vertices;
>
> > scene.addChild(m1);
>
> > mp = new Morpher(mv1);
>
> > addEventListener(Event.ENTER_FRAME, ef);
> > }
>
> > private function ef(event:Event):Void
> > {
> > super.onEnterFrame(event);
>
> > m0.rotationY = -180 + 360 * (mouseX / stage.stageWidth);
> > m1.rotationY = -180 + 360 * (mouseX / stage.stageWidth);
> > m2.rotationY = -180 + 360 * (mouseX / stage.stageWidth);
>
> > mp.start();
> > mp.mix(m2, Math.sin(Lib.getTimer()/1000)*100000);
> > mp.finish(m0);
>
> > view.render();
> > }
>
> > ---------------------------------------------------------------------------
> > --------------
>
> > The test I've done with spheres seems to be giving the correct
> > results, although I'm worried I'm missing something. You'll see I've
> > also created references to the objects inside the geometryLibraries
> > which I think would work but then you have to pass the Vectors
> > themselves to the Morpher and thus completely changing how it works.
>
> > So I guess the question comes down to "How do I get access to the
> > geometry as a Mesh from parseGeometry / a Collada"?