flattenStrong problem [SOLVED]

I’m trying to use flattenStrong to combine a bunch of stationary, identical platforms. If I reparent to the model to the root node path, they don’t get flattened. If I reparent the geom (I think), they do get flattened, but they don’t appear in the scene. I already successfully used flattenStrong for a bunch of CardMaker background tiles, so I can’t tell what’s wrong here.

root = NodePath('root')
root.reparentTo(base.render)
for i in range(10):
    p = base.loader.loadModel("models/box")
    p.setPos(i,0,0)
    g = p.getChild(0)
    (g or p).reparentTo(root)
root.flattenStrong()
print root.getChildren()

EDIT: I just needed to set the position of the child as well.

Is that the right way to flatten?
I thought it was just root.flattenStrong().

I’m having the same problem here.
Is it right to (g or p).reparentTo(root)?

I really thought it was easy to flatten, but when I load two boxes, reparentTo(‘root’) and print removed = root.flattenStrong I get 0 as answer and running analyze() still shows me 2 geoms.

What am I doing wrong?

Sorry the bump, but rdb helps me to solve and I think it’s something that could help many of the users (Amugaba inclusive).
I think get_child(0) is not the better way, and here doesn’t solved.

The solution:

A simple call of clearModelNodes:

root.clearModelNodes();
root.flattenStrong();

:stuck_out_tongue:

1 Like