Results 1 to 4 of 4

Thread: Using scaled general meshes for physics

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    3

    Using scaled general meshes for physics

    Hi,

    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):

    <library_geometries>
    <geometry id="Sphere-Geometry" name="Sphere-Geometry">
    <mesh>
    ... Mesh data for a triangulated sphere ...
    </mesh>
    </geometry>
    </library_geometries>
    <library_visual_scenes>
    <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">
    </instance_geometry>
    ...
    </node>
    </visual_scene>
    ...
    </library_visual_scenes>
    <library_physics_scenes>
    <physics_scene id="Scene-Physics" name="Scene-Physics">
    <instance_physics_model url="#Sphere1-PhysicsModel">
    <instance_rigid_body body="Sphere1-RigidBody" target="#Sphere1-Node"/>
    </instance_physics_model>
    ...
    </physics_scene>
    </library_physics_scenes>

    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.

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: Using scaled general meshes for physics

    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.

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    3

    Re: Using scaled general meshes for physics

    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.

  4. #4
    Member
    Join Date
    Dec 2004
    Location
    SCEA, Foster City
    Posts
    36

    Re: Using scaled general meshes for physics

    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:
    http://code.google.com/p/bullet/source/ ... r.cpp#1175
    So you can have non-uniform scaled triangle meshes etc.

    Hope this helps,
    Erwin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •