i have used loader.loadModel() method for it.
So my question is:
Can i delete two auto-generated nodes without compromising my model at execution?
Or are needed for some hidden routine?
The ModelRoot is there to store a bit more information about the loaded model such as the filename. It also serves a different purpose, which is to prevent multiple individually-loaded models from being flattened together at a call to flattenStrong().
You can call clearModelNodes(), if you wish, to remove the ModelRoot. You can call flattenMedium() to remove other unnecessary nodes, or flattenStrong() to try and reduce the number of nodes even more by merging geometry together as possible.
You are very helpfull Rdb.
I tried all the command that you told to me, but what i need at this time is to remove only one node and connect the entire tree below him to his parent node.
It can be done with one function?
I am not able to find it
Though I’m not sure why it’s important to you to remove this node; it doesn’t cost much to have it, and keeping it around allows the model loader’s reference counter to keep track of the models you are still using.
Thanks David.
I understood the importance of ModelRoot node in a object, in fact, I do not want to remove it but, the first auto-generated PandaNode child.
Hmm, I think you might be mistaken about the node beneath the ModelRoot node. That’s not automatically generated, and must have come from the mode file itself for some reason. Still, simply calling model.flattenMedium() should remove any apparently unneeded nodes like this, automatically.
leftpanel is the first group that i see in the .egg file.
I tried to use flattenMedium() but it flat transform matrix too and, i need it in many cases.
You can confirm me that and .egg file imported to Panda3d don’t auto-produce a “dummy” Pandanode, after the ModelRoot node (from Maya, blender, or other)?
Because i use and exporter for 3dsmax made by me and could be a bug (I’ve already tested it several times and work well but, a bug is always behind the corner , since it is still in alpha stage )
But if leftpanel has any siblings, then the egg loader will need to create a parent node of all of those siblings to group them all, and that must be the node you are seeing. (The ModelRoot node is added later.)
If leftpanel were the only group at the top level of the egg file, then it would be the child of the ModelRoot.
You can also do the equivalent of a flattenMedium() to remove nodes, without also removing transforms, by using a lower-level SceneGraphReducer:
gr = SceneGraphReducer()
gr.flatten(model.node(), 0)
I checked it several times and the root group in .egg file is leftpanel but when import… puff! appears another pandaNode over it.
Can be a missing property?
my .egg file is like the follow:
Can ModelRoot have many childs? (at the same sublevel)
If yes, i delete the auto-generated node at root when import in panda, instead of change my export code and insert another group without transformation matrix.
I have notice that the auto-pandanode also appers when i use x2egg exporter shipped with panda.
So I have the feeling that the “problem” appears with all exporter, because it use transform matrix on nodes.
I’ve just modified the EggLoader not to ever create that unnecessary intermediate node at all. This will be in 1.9.0, as I can’t risk breaking 1.8.2 in case some people rely on a particular node structure. With my change, the structure now looks like:
That extra node that was being created corresponded to the EggData object, which doesn’t hold much useful data on its own except for child nodes, which is why I’m confident that this is a safe change. It makes sense to me that the EggData object would correspond to the ModelRoot object instead.
The question that puzzled me is why Panda only removed that empty PandaNode when the node under it didn’t have a transform applied to it; I’m guessing that this is caused by an imperfection in the flattening code, but I suppose that is moot now anyway.