tracking position of opengl object when anchor is set

    Mar 03 2014 | 1:31 pm
    hello jitter pros,
    having a question how to track the position of opengl object when anchor is set. with the getposition message, i only get the staic center of the object.
    here is a simple patch, which demonstrate the issue.
    looking forward for any help !

    • Mar 03 2014 | 5:20 pm
      you are going to have to use anim.node for this. you can query the worldpos attribute to get the world-space position of a 3d object.
      also, never use a [metro 1] to drive your renderer, instead use [qmetro]
    • Mar 04 2014 | 2:00 pm
      thanks rob for the explanation and the patch !
      but there seems to be a little offset between the word- and object coordinates.
      here is a demo patch:
    • Mar 04 2014 | 6:52 pm
      it's a little tricky, but you simply need to send a bang to the jit.anim.node after setting the rotate. this causes it to update immediately, rather than waiting for the the render context to update it. so when you get the world-position, it's already updated based on the new rotation of the anim.node.
      alternatively, you could use to drive the animation.
    • Mar 04 2014 | 7:06 pm
      hey rob,
      thanks so much for your help !
      one more thing, which is not clear to me is: if i rotate the whole scene, the two circles does not align anymore in 3d space.
      putted a to the render.
      here is the code:
    • Mar 05 2014 | 12:05 am
      did i mention this stuff gets tricky?
      so this actually makes sense if you thing about it. the gl.handle is affecting the gl.render node, which is the root node of all the nodes and objects in the context. to make your patch work, then you must use the worldtolocal message of jit.anim.node, which takes a world-position (from the spinning object), and creates the local position value based on the objects current world-position that will bring the object to that world-position.
      a simpler alternative is to never adjust the gl.render transforms. this is my advice for any kind of patch that has to do work with transforms. instead, create a new jit.anim.node and attach the handle to that, and then parent that to all the other anim.nodes you want the handle to control.
    • Mar 13 2014 | 1:39 pm
      hey rob,
      i just want to thank for your help. now i got everythin working.
      perhaps it woud be nice, if all open gl objects could tell us their "real" position by sending something like a "getWorldPos" message.
      then, we could save many objects ;-)
      have a nice day, pc