Animated models and <Collide>

Hi, just a quick question.
I created an animated model in Blender, exported to Egg with Chicken, and it works fine in Panda3d. Then I was curious about having an animated polyset for collision but without showing it. I manually edited the EGG file, but adding {barrier} or {Polyset} doesn’t work, the model is STILL rendered by Panda3d. I thought I was editing it wrong, so I got back to Blender, and for my object I added the ObjectType property with “barrier” value, and exported again, but the model keeps having visible geometry…
Is it possibile to use an animated model as a collision polyset without actually having a visible geometry?

This hasn’t been possible before 1.7, but now you can pre-process the egg file with “egg-optchar -dart structured -keepall” to allow loading collision data and other data in the character model.

You can omit the -keepall if you process the model file and all animation files at the same time.

Note that “-dart structured” does interfere with the normal optimization processing that Panda would perform on an animated character, so use it only when actually needed.

Also note that the actual vertices of the collision polygons will not animate–the collision polygons will be hard-assigned to their different joints.

David

Thanks for the quick reply, drwr. I’m not sure if I got right your last sentence:

"Also note that the actual vertices of the collision polygons will not animate–the collision polygons will be hard-assigned to their different joints. "

Does this means that we can use an animated model as a STATIC collision polyset, but we can’t use the animation as a way to animate the collision surfaces?

This is not something I need right now, but I’m quite curious :stuck_out_tongue:

I believe the collision system will support rigid animation, like a robot, but not soft animation, like a snake. That is to say, each collision polygon will move as a unit, in whatever joint space it exists. Gaps will open up and close between neighboring polygons.

I’m not 100% sure of all of this, though. It’s possible that collision polygons don’t work with animation at all, even rigid animation–that wasn’t the original intention of this feature, after all, and it hasn’t been exercised heavily. (But I do know it’s possible to load collision polygons and hand-parent them to the various joints exposed via exposeJoint(), to achieve rigid animation the hard way.)

David

Thanks again :slight_smile: You’re right, probably the exposeJoint way is enough. By the way, if someone really needs an animated but invisible polyset collision solid, I think the way it just to detach the model’s NodePath from the render tree, so the model is there but won’t be rendered, animate the model and then run a separate CollisionTraverser that traverses this “invisible” tree instead of the render tree. I’m not a Panda3D guru, so I’m not sure if this works, but it seems ok to me. I’ll make a test as soon as I have time :slight_smile:

Yes, that would work (or you could simply call hide() on the model, which makes it invisible but still collidable).

However, that would use the very expensive collide-with-GeomNode test, rather than the much more optimal collide-with-CollisionNode test. Geometry that is loaded to be rendered is created as a GeomNode, which is optimized for rendering, not for collisions. It can be used for collisions anyway, but it’s about 100 times slower.

David

David, your last post confused me a bit.

I thought that when model is loaded, if it’s tagged to be collidable ColisionNode is automatically generated(loaded- i dont know real term).

Is it loaded automatically or we need to do it manually?

Again, I’m not a Panda3d guru, but here is my theory:
I think that a CollisionNode is created for each object with the tag in its EGG file, but I think you can use CollisionTraverser to test collision with every geometry in your scene. Nodes without the tag can still generate collisions but they’re not optimized for this purpose, since they’re created as GeomNodes. So it is important to keep a clean usage of the collision bitmask, to avoid unintended collision testing that would slow down execution.
Panda3d manual says:
<<Adding an object to a CollisionTraverser makes it a “from” object. On the other hand, every object that you put in the scene graph, whether it is added to a CollisionTraverser or not, is automatically an “into” object.>> ( panda3d.org/manual/index.php/C … Traversers )

Now, my supposition can be right or completely wrong… Let’s wait for David to make things clear
:smiley:

That’s the right idea.

As to GrizzLyCRO’s confusion, it’s generally true that a tag in an egg file will create CollisionNodes instead of GeomNodes, but CollisionNodes can’t be animated the same way GeomNodes can (they can only be animated as rigid bodies, they don’t deform during animation like GeomNodes do).

So if you want your soft-skinned model to have very precise collisions, you have no choice but to use the very expensive GeomNode collisions. (It’s probably better to accept rigid collisions instead, though.)

David