Physics and Animation

    Oct 28 2011 | 8:35 pm
    Hello - I had a question about physics and animation. I was hoping to propel objects around using the object, while also giving it physics. I was somewhat successful with my hacky approach below, but there are some problems:
    1) the physics bounds and the octahedron are not well aligned, which seems to be a timing problem with the animation. I would think that the fix would be if the physics.body could be driven by the as well (perhaps as a node?), but that doesn't work.
    2) which brings me to the other issue... when the objects collide in my example what I might expect is that the path of the octahedron would be altered, causing it to go off in a new direction, however it seems to stay it's course. I wasn't sure how to get the animation to change in relation to the collisions.
    In both cases this seems to me that there should be a kind of feedback relationship between the physics and the animation. I wasn't sure how to achieve this-
    Thanks and kind regards,

    • Oct 28 2011 | 10:24 pm
      hi MardDavid, thanks for your patch and your comments!
      1 - there actually is no @shape octa. check the phys.body ref page for available shapes. there are two options. first is to simply surround the gl.plato shape with a one of the phys.body simple shapes, such as sphere. this is basically what your patch is doing, because it defaults to @shape sphere. however this may require some offsetting of the render shape from the physics shape, which requires inserting two anim.node objects between the phys.body, and the gl.plato. this is the more efficient option. the second option is to use matrixoutput of the gl.plato to send a single matrix to a phys.body. this will cause the phys.body @shape to be set to convexhull, which will more accurately reflect the shape of the gl.plato.
      here's an an example of these two methods:
      2 - syncing user animations with rigid-bodies is not a trivial task, and there is no built-in mechanism for doing this. what you are doing is fine, but inefficient with regards to the physics simulation. the proper way to apply user-animations to a rigid body is to set @kinematic 1 on the phys.body. when you want to switch back to the simulation, you simply set @kinematic 0. here is an example of this using your animation controls:
    • Oct 29 2011 | 5:59 am
      Thanks Robert- that's at least much closer to what I had in mind.
      all the best- markdavid