Delete auto node?

Hi, i have noticed that when you import a file .egg in Panda, automatically it generate two node at root position, as follows:

 ModelRoot left_panel.egg #auto generated node
    PandaNode #auto generated node
      PandaNode leftpanel T:m(pos -0.177899 0.0516842 -0.022224)  #my node

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?

Thanks all for reply

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

Thanks very much Rdb

You can always do something like:


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.

I used:


self.lp is the model loaded variable.

Thanks to you too David for your support.

p.s.: A doubt. The PandaNode auto-generated node isn’t important for the model execution, right?

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 :smiley: , 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:

<Comment> {
	"File generated by Max2eggs Tool v1.0 (TexAnim2egg) for 3dsmax 2008 and higher."
<CoordinateSystem> { Z-Up-Right }

<Texture> Dcamerapos_test {
	<Scalar> wrapu { REPEAT }
	<Scalar> wrapv { REPEAT }
<Texture> Dcnctyperight_test {
	<Scalar> wrapu { REPEAT }
	<Scalar> wrapv { REPEAT }
<Texture> Dcnctypeleft_test {
	<Scalar> wrapu { REPEAT }
	<Scalar> wrapv { REPEAT }
<Group> leftpanel {
	<Transform> {
		<Matrix4> {
			1.0 0.0 0.0 0
			0.0 1.0 0.0 0
			0.0 0.0 1.0 0
			-0.177899 0.0516842 -0.022224 1

I use it like a dummy object, so it have no textures or geometry.

Ah, it must be the transform on the root node that’s causing it. Removing the transform in fact removes the extra node.

That’s not to say that there’s a great reason for the extra node to exist in the first place, but it at least explains what’s happening.


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.

Yes, the ModelRoot can have an arbitrary number of children, like any other node. For what it’s worth, it may also have a transform attached to it.

So I wonder why Panda generate another pandaNode after the ModelRoot if the node under it have a transform matrix…
Could someone tell me?

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:

ModelRoot left_panel.egg
  PandaNode leftpanel T:m(pos -0.177899 0.0516842 -0.022224)

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.

So, can you tell me when the version 1.9 comes out?

In any case for now, I’ll set an option that will leave the user to decide whether to delete the unnecessary node when import a model on Panda.

Thank you very much for helping me to solve this little trouble.

Not any time soon. For now, you can simply check for the existence of a child node that has no name, or something like that.