Using scaled general meshes for physics


I’d like to instantiate a mesh several times, under different nodes. These nodes can include transforms and rotations as well as scales.

At the same time, I want to instantiate rigid bodies which have this (non-convex) mesh as collision shape (in order to test non-convex collision detection). Instantiating the geometry which defines the mesh works fine, and giving the rigid body takes over the node’s translation and rotation, but not the scale. Searching on the forum did not give me a direct result, except for this: viewtopic.php?f=3&t=1242&p=4390&hilit=scale#p4390, which could imply that rigid bodies under a node cannot take this node’s scale. In this case, I would not understand the design decision behind this, though.
Otherwise, I would be thankful for a hint on how to use the same mesh in several (possibly scaled) instances, both for graphics and physics.

Some example code which does not seem to work (at least not in bullet physics):

<geometry id=“Sphere-Geometry” name=“Sphere-Geometry”>
… Mesh data for a triangulated sphere …
<visual_scene id=“Scene” name=“Scene”>
<node id=“Sphere1-Node” name=“Sphere1-Node”>
<scale>2.0 2.0 2.0</scale>
<instance_geometry url="#Sphere-Geometry">


<physics_scene id=“Scene-Physics” name=“Scene-Physics”>
<instance_physics_model url="#Sphere1-PhysicsModel">
<instance_rigid_body body=“Sphere1-RigidBody” target="#Sphere1-Node"/>


The sphere-mesh is graphically shown twice as big, but has only its original collision size. Any hint on what I could be missing is appreciated.

The <instance_rigid_body> element targets the node (coordinate system) for visualization purposes. The node’s coordinate system doesn’t affect the physics scene.

Rigid body collision shape is defined by the <shape> element, not by the targeted node. The rigid body must have at least one shape. The shape can be defined by exactly one analytic or mesh geometry. The shape can include translations and rotations, but not scale as that’s (typically) not supported in physics engines. This part of COLLADA schema design had input from PhysX and Bullet developers among many others.

In short you must have a <shape> with the correct scale ready to load for the physics engine to use.

I hope that helps.

Thank you for your explanation, Marcus.

I understand why my attempts were not successfull.

However, I still think the possibility of scaling a mesh when used as rigid body would be useful.

General scaling for shapes does not make sense, since scaling a sphere in 3 dimensions with different scaling factors would make it something else than a sphere.

But a unilateral scaling for shapes would be well-defined. Maybe even a general scale- operator could be allowed (in 3 dimensions), which would have to be unilateral for a sphere, free in 2 dimensions for a capsule/cylinder, and free in 3 dimensions for a box or a mesh.

Using primitive shapes, the gain would not be large (except for being able to reference the shapes when creating other rigid bodies), but for meshes it would be practical indeed.

The main problem is that scaling cannot be part of a rigid transform. But you can extract/apply scaling of the node and apply it directly to the local scaling of the collision shape instead.

In the BulletColladaConverter, the node’s scaling is applied as local scaling to the collision shape: … r.cpp#1175
So you can have non-uniform scaled triangle meshes etc.

Hope this helps,