Author Topic: Consume Pivot3D  (Read 109 times)

Dimitar Kyrilenko   «   on: May 29, 2012, 11:07:46 AM »
Hey guys.
Awesome job on Flare3D, I'm having a lot of fun so far. As a nooby I have a (maybe stupid) question - I hope someone can help me with this. I"m importing DAE files (models) of buildings to my scene. Now I want to encapsulate the loaded models in a custom Building class that extends Pivot3D. What would be the best approach to 'consume' the Pivot3D object I get from scene.addChildFromFile(..) into my Building class. I thought about passing it to Buildings super(..) but Pivot3D (of course) only wants a String for its name.

Another thing is: When I load a second instance of the same DAE file it won't appear on the scene. Am I doing something wrong or is this normal behaviour?

Thanks (-:

Ivan Vodopiviz   «   Reply #1 on: May 29, 2012, 01:01:53 PM »
Hi,

I'm not sure I'm understanding what you want to do... But I'll try... addChildFromFile accepts a "parent" parameter, so when the object is loaded, it will set it as child of the object you passed as parent.

You can also do this by hand, simple doing addChild( pivot ); in your Building class, pivot being the Pivot3D reference you got from addChildFromFile.

Hope this helps!

Jason Huang   «   Reply #2 on: May 29, 2012, 01:58:03 PM »
Hi,Dimitar
I think he meant to get a "box" for f3d files or DAE files.
Well if you have a solid AS3 skills. That may helps a lot.
Something like build your own class loader. and embed all of your assets to one class. Then compile that assets class to swf file. Therefore, you actually encapsulate all files for a single swf, and use them as class.
 Here is the hint(may not be necessary): 
 loader.contentLoaderInfo.applicationDomain.getDefinition("className");

Hope this helps:)


Dimitar Kyrilenko   «   Reply #3 on: June 05, 2012, 07:00:02 AM »
Hey Ivan and Jason,

thank you for your replies. Further thinking in combination with Ivans suggestion did the trick!

Another quick question: I'm currently using the Viewer3D class as my scene. How can I reset the transformations (rotation and zoom) the user perfomed. scene.resetTransforms( ); won't work and restoring the matrix I backed up (from scene._global) like
scene.global = this.origScnePositionMatrix.clone();
didn't the trick either. Any advice would help.

Thanks again (-:

Ivan Vodopiviz   «   Reply #4 on: June 05, 2012, 10:56:56 AM »
Hi,

When you "move" the Viewer3D you're actually moving the camera, not the object itself. So you have to do the following:

scene.camera.resetTransforms();

And that should restore it like it was before modifying it with the mouse input.

Cheers,