Flattening issues

So I have a nice dae file, which I can load, but I need tangents and binormals, so I use dae2egg, then egg-trans, then I load the egg, strip tons of pointless render attributes that end up every where, and throw every conceivable flattening attack on it I could think of.

I have this method among several other things to try and flatten stuff:


def flatten(map):
    sceneGraphReducer.decompose(map.node())
    sceneGraphReducer.flatten(map.node(),SceneGraphReducer.CSRecurse)
    sceneGraphReducer.removeUnusedVertices(map.node())
    sceneGraphReducer.applyAttribs(map.node())
    sceneGraphReducer.makeCompatibleFormat(map.node())
    sceneGraphReducer.collectVertexData(map.node())
    sceneGraphReducer.unify(map.node(),False)
    
    map.flattenStrong()

Pview is happy to tell me:

Thats 534 geoms! Most of the massive node count is for collisions stuff, so ignore that, there is no geometry in that part of the graph.

Well, that sucks, so to debug, I used bam2egg, and the egg looked fine, and pview says:

So my collision stuff is all missing (otherwise the node count would still be huge), but making it into an egg file fixed the geom count.

So I wanted to see how broken it was, so I dumped it back to a bam with egg2bam so my game would take it. And I get this:

Well, thats clearly not supposed to happen.

We are dealing with a 40 mb bam file, and a 107 mb egg file, so I haven’t just dumped them up for inspection, but I can provide them if desired. I can’t provide all my code, because there is a heck of a lot of it involved.

So: whats with the egg2bam failed assertion? Why does bam2egg flatten my model when no matter what I do in code to my scene graph fails to? and how can I get a flattened model without dumping out a 100+MB tmp egg file? (I already 2 different tmp egg files so I can get tangents and binormals, so writing out a third to disk is not too bad, but its lame that I have to read and write my model through 3 tmp files just to generate my flattened bam file, and even that process crashes if I use egg2bam).

Edit: Also, bam2egg is losing my UVs, so while I’ve finally got my pipeline working by using bam2egg to get the flatten to work, I don’t have UVs (tangents or binormals) anymore. I think my UV column has a non standard name in the bam, file, bit it worked in Pview and in my game.

bam2egg is nowhere close to a robust conversion, so it doesn’t surprise me that it loses lots of useful attributes.

The more important question is why your flattening attempts weren’t more successful, I think. Perhaps you have lots of different render state on your different Geoms that are preventing them from being combined together? Then when the render state is lost by the bam2egg -> egg2bam conversion, it is more successful.

David