How to use BSP Tree Builder in Away3d 3.6.0

Software: Away3D 3.x

Avatar
Bob Klein, Newbie
Posted: 02 November 2011 06:20 PM   Total Posts: 17

I am porting a large application from Alternativa to Away3D because the lack of documentation over there has become problematic.  So far everything has gone well and my code is running okay in Away3d except for the fact that my models show serious z-sorting problems with faces fighting for a view.

I know that my code needs to generate BSP trees and I am trying to figure out how to use the BSPBuilder interface.  My application generates non-trivial 3d models on the fly based upon user inputs so there is no way that I can use the prefab3d utility.  For anyone that is interested my application manages 2d floorplans and creates 3d models of a building interactively.  So far so good.

I have a set of Mesh objects.  I go into the geometry of each Mesh and get the faces vector.  I then put every Face into an array and pass that into the IBSPBuilder build() method.  When I get the complete event I take the tree property of the IBSPBuilder and attempt to do an addChild of the tree to my scene.  So far this doesn’t work.  I get nothing in my scene.

Does anyone have a sample of some code that uses the BSPBuilder interface that can provide some assistance?

thanks very much in advance,
...bob klein…

   

Avatar
Bob Klein, Newbie
Posted: 09 November 2011 10:46 PM   Total Posts: 17   [ # 1 ]

For anyone that cares I was able to get this working.  I had to break all of my geometry data into triangles (fortunately I had already created the code to do triangulation of all polygons) and then I created a Face object for each triangle.  All of the faces went into one big array and then I passed that into the IBSPBuiilder build method and it actually worked.

My z-sorting problems went away and the structures were rendered properly.

However, the performance was horrible. 

1. Actually creating the BSPTree was extremely long.  Some floorplan levels took over a minute to generate.  Using the Alternativa (version 7.8) createTree() method usually took about 10-15 seconds to do the equivalent job.

2.  The rendering time of the resulting BSPTree in away3d was on the order of 8-10 fps while the same scenes in Alternativa 7.8 were running around 22fps. 

Eeeek!  I’ve concluded that I cannot use away3d 3.6 for my application.  I have a completely functional version in Alternativa 7.8 but they don’t support any kind of lighting effects (for non-textured materials) there so I was hoping to accomplish that in away3d.  Now I’m back to trying to figure out what to do next.

I understand that using Away3d version 4 should work very well to improve my rendering speed.  However, when I look at the documentation I see nothing about z-sorting issues.  There is no functionality for a BSP tree.  In away3d version 4 what can I expect with regards to solving the z-sorting issues that are critical to my type of application?  Can anyone out there describe what can be done to deal with z-sorting problems in version 4 (perhaps I missed something in my scan of the api)?  Or is there some reason that z-sorting issues go away in version 4?  Just wondering…

thanks in advance,
...bob klein…

p.s. on top of this I just saw the depressing news today about Adobe backing off on support for the Flash plug-in in the not too distant future.  I don’t think these kinds of apps are going to live in an HTML5 environment.  Bwwwaaahhhh!

   

Avatar
Bob Klein, Newbie
Posted: 10 November 2011 05:01 PM   Total Posts: 17   [ # 2 ]

After I posted my reply to my original posting I realized the answer to my questions above.  Duh….

The way to deal with the z-sorting issues is to simply make the triangles smaller and smaller (presumably using the Away3d 4.x Facehelper.splitfaces() and trifaces() methods) until z-sorting problems go away.  This solution was unreasonable in earlier implementations of Away3d because the increased triangle count would make the result very slow to render.  But if the triangle count handling capabilities of the 4.x implementation are as advertised this should not be a problem when using Away3d 4.x.

So - I guess it is time for me to re-port my implementation to the 4.x version of the api and see what happens.  Hopefully then I can get back to my original goal which was to implement lighting features into my dynamically generated models (which is missing from the original Alternativa implementation).

I realize that I am basically talking to myself here but I can see that at least a few people are reading this thread.  So maybe if I keep posting I’ll help out some other dope like me in the future.

back to my keyboard….

...bob…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X