how can I add collision node without editing the egg?

Hi, as we know that we must set the node’s collision bitmask so that it will be checked for collision against other node with the same bit.

Without editing the egg, it will work IF that node has no descendant.
If it HAS descendants, WITHOUT putting the line:

node {polygon keep descend}

in the egg file after the node’s ‘’ line, then the descendants are not checked for collision.

Are there anyway to set the collision for it’s all descendants too without editing the egg?

It’s just unpleasant when the model get revised often.

Firstly, even without editing the egg file, you can set the collision mask on a node and all of its descendents, by using the interface on NodePath, for instance:


(as opposed to nodePath.node().setIntoCollideMask(newMask), which only affects that one node).

However, that being said, when you set the collision mask on visible geometry like that, you are asking Panda to perform the intersection test with the actual visible geometry. This will work, but it is much less efficient than performing the intersection test against special collision geometry created for this purpose. Other than creating a bunch of CollisionPolygons by hand at runtime, the only practical way to get a whole scene full of collision geometry is to load it from an egg file.

If you are using Maya to do your modeling, you can use the eggObjectFlags.mel script to add one or more “egg options” to a given node. A handful of egg options are already defined for you; you can edit the script file to define more, whichever ones you make up. When you add an egg option to a node, for instance “barrier”, it causes the line:

<ObjectType> { barrier }

to be inserted into your egg file at the given node. This, in turn, is defined in 20_panda.prc, with the line:

egg-object-type-barrier         <Collide> { Polyset descend }

This means that when you load or egg2bam the egg file, it will replace { barrier } with { Polyset descend }, thus marking the specified geometry as an invisible collision solid.

You can define your own object types, like “foo”, by adding a line defining egg-object-type-foo to your own Config.prc file (making it be whatever egg syntax you want), and also adding “foo” to the list of object types supported by eggObjectTypes.mel.

Now, if you are not using Maya, you will have to use some different mechanism to insert the syntax into the file. To be honest, I don’t know if the 3DSMax converter supports anything like this or not. I do know that any of the converter pathways that involve going through an .x file don’t support this (because the .x file format itself doesn’t support anything like this).


Yeah, my BAD, I just noticed.


Where can one find the eggObjectFlags.mel script? I’m afraid I’m having no luck in the forums today.


It’s here in the source repository:


Edit: I don’t know why phpBB refused to make that link clickable. Maybe it doesn’t like the asterisks in the middle, but that’s what ViewCVS does. You’ll have to cut-and-paste it into your browser.