Is there a easy way to creat the CollisionShape?

Hello! I have been trying the bulletAppState for a moment now, but am hitting a wall:

When I direcly add the sceneNode whit the addControl and add to physical space, I get the shapes I want, but when I do a collision, then I only colide whit the node, losing all the information I put in the userData of some spatials I added to the scene.

Also, when I try to directly add the items that contains those userdata information as RigidBodyControl, it just won’t correctly scale the CollisionShape for some reason, so i only get tiny boxes that i can never touch :confused:

Any tips available? This is slowly getting me insane :confused:

Okay so found it : Seem like the RigidBodyControl did not scale whit the object, so i had to manualy scale it whit the worldscaling of the spatial. Is it normal?

Yeah.

I know I will regret asking but… why?

Counter-question: Why would it scale with the spatial?

Well, because the spatial was already that size. Why would the RigidBodyControl base itself on any information at all then?

I mean the spatial was initialized as this size on my scene because I set it that way in the editor. It seems counter initiative to then have to simply scale the collision box the right way by getting into the whole mess like this

spa.getControl(RigidBodyControl.class).getCollisionShape().setScale(spa.getWorldScale());

Then again, its easy enouf when you know where the problem come from, but i really belive this kind of info should be add in the wiki.

According to that logic it doesn’t make sense to add the RigidBody to a PhysicsSpace then. See, you have two separate things here: One is the scenegraph with rendered objects, one is the physics system with RigidBodies, collision shapes etc. They are completely separate - each works without the other. The only thing that happens is that the positional information from the physics object is transferred to the scenegraph object. The physics object could (and will in most cases) have a different shape than the scenegraph object. You’ll have hull shapes for complex geometries, boxes instead of simple small objects etc. etc.

So the RigidBodyControl DOES NOT base itself on any information from the scenegraph, it bases itself on the information you give to it. The CollisionShapeFactory is the only thing that uses scenegraph information to help you have an initial physics object.

Furthermore, in bullet the scale of an object is - as you found out - based on its collision shape, NOT on the RigidBody. As you can use one collision shape for multiple objects to save memory it would be a HUGE mess to have a physics control check the scale of its spatial each frame and apply that to the collision shape of the managed physics object. This could cause all kinds of objects in the physics space to suddenly change their size. And again - it would be the ONLY thing that a spatial suddenly transfers to the physics object. Unless a physics control is set to kinematic mode not even the position of the spatial affects the physics object location.

2 Likes

Ok now i get it :smiley: Thanks x)

Somewhat related :

Is there a way to import a model from blender with collisionshapes and joints ?
Or I must create this in code like KinematicRagdollControl does it?

Yes, it is possible thanks to @RiccardoBlb. You can import collision shapes from blender.
see :

For Ogre importer :

For Xbuf importer :

Great thank you brother

1 Like