Loading colliders from .bam

Hello,

I’m using blend2bam to generate a bam file from a Blender 3 project. The only problem which I’ve encountered so far is that I’m unable to set the <Collide> Polyset keep descend tag. I’ll be more clear:

here is the portion of the output of scene.ls() which interests us:

    PandaNode bldg2_collider [Collide]
      GeomNode Cube (1 geoms: S:(MaterialAttrib TextureAttrib))

this node has a custom String property(Blender 3’s object properties panel) called “Collide” with value “Polyset keep descend”

the problem is that, when I access the node and call isCollisionNode() on it, it prints “False”.

What am I doing wrong? What is the correct way(assuming there is one) of setting the tag in Blender 3 considering that the model will be converted directly using blend2bam(i.e. without passing from the .egg format)?

For collisions usually the Rigid Body options from the Physics Properties section is used with blend2bam. For your example of the “Polyset keep descend” tag, you’d just need to enable it and use the default Convex Hull.

This will also keep the collision solids visible, in case you ever want to make them invisible (e.g. skip the “keep” of the tag) there is a special option that enables you to pass a name of a collection to the blend2bam call which is named “–invisible-collisions-collection”. It is also described in blend2bams’ help.

The custom string properties are as far as I know only used as tags on objects.

Thank you! That solved the issue :slight_smile:

Actually, there is still an issue: once I load the collider I’m unable to set it up properly(it doesn’t collide with the other objects) and I don’t understand why.

The collision traverser is the following:

CollisionTraverser, 2 colliders and 1 handlers:
  render/Scene/GROUND_COLLIDER/GROUND_COLLIDER handled by CollisionHandlerPusher
    box, (-1 -1 -1) to (1 1 1)
  render/Armature/pusherNode handled by CollisionHandlerPusher
    box, (-0.1 -0.1 0) to (0.1 0.1 0.5)

both the CollideMasks(Into and From) of both the objects are 0000 0000 0000 1111 1111 1111 1111 1111

Moreover, there is a task which prints at every call cTrav.getRecorder() and it looks like the traverser sees the right collisions…

Could we see the code that sets them up, please?

Let me note, by the way, that unless you intend for the floor to be pushed away by the other object, it might not be ideal to have it be handled by a CollisionHandlerPusher.

Static objects–that is, those that are unmoved by collisions (as floors tend to be)–can simply be left unhandled, with only “active” objects–those that are intended to actually respond to collisions–requiring a CollisionHandler, I believe.

Hi,

here is the code:

Ground collider extracted from the .bam model

self.scene = loader.loadModel('scene.bam')
gnd_coll = self.scene.find('**/GROUND_COLLIDER').getChild(0)
assert(gnd_coll.node().isCollisionNode())#OK 

Player collider

box = CollisionBox((0,0,0.25),0.1,0.1,0.25)
coll = self.player.attachNewNode(CollisionNode('pusherNode'))
coll.node().addSolid(box)
self.base.cTrav.addCollider(coll,self.base.cPusher)
self.base.cPusher.addCollider(coll, self.player, base.drive.node())

Maybe it could be useful to know that, in Blender, I set the RigidBody property with: type=passive, shape=Box

Ok, I think I solved it by setting the type to ‘Active’ in Blender…

my bad. Sorry :-/

1 Like