Forums > Jitter

tracking moving points in openGL?

December 23, 2013 | 12:26 pm

If I create cube (or any other shape) by specifying openGL point coordinates, what’s the best way to keep track of the current point positions as I rotate and move the cube? I suspect some sort of transformation matrix is used, but it’s not clear how I would implement it.

I thought something like [getattr] connected to [jit.gl.sketch] with rotation values feeding into [jit.traffic] .. or something in that direction. But it’s not clear how thousands of 3D coordinates would be mapped to a 2D matrix or how rotation data is used to enumerate current all of the current positions.

Hope that makes sense.


December 23, 2013 | 1:50 pm

you can use jit.anim.node to track and transform points, possibly in conjunction with javascript for a complex system.
take a look at the help files and let me know if it isn’t clear.


December 24, 2013 | 1:28 pm

Rob, thanks very much for reply… though after several hours of confusion and frustration, a bit of clarification would be a great help… Perhaps an example would give you a better idea of what I want to do.

If I plot the 64 points of a 6-bit RGB cube, with all of the coordinate values matching the color values (normalized to [0,1]… ex. point 0. 0.333 0.667, glcolor 0. 0.333 0.667 1., etc.) and view it in a pwindow, what information remains regarding those points?

I know that openGL doesn’t retain state information (hence having to be redrawn continuously), so how do I then obtain a list of the coordinate values in that context based on current position, rotation, rotationxyz settings? (let’s assume position 0. 0. 0., rotation 0. 0. 0. 0., rotationxyz 0. 0. 0., scale 1. 1. 1., anchor -.5 -.5 -.5)

Similarly, if I want to dynamically change the point colors so they remain consistent with the current coordinate values, do I need to keep a record of those changes on my end (as I create new code to redraw the cube) or is there a way to grab current colors for each point?

jit.anim.node seems more geared towards taking an input and transforming it into something different (a new orientation or shape) rather than simply converting values based on the positional data received. Does jit.anim.node receive the list of original points that I programmed along with current orientation settings? If so, I don’t want it to do anything more than enumerate values.. you know, like in Dragnet.. "Just the data, ma’am"


December 26, 2013 | 5:15 pm

If anyone can help me out (and aren’t caught up in holiday festivities) it would be greatly appreciated.

The abbreviated version: I plotted the points of a cube using jit.gl.sketch… I need to grab the current coordinates of the cube in real time as I rotate and move it.

That’s it.

I sent a gettransform message to jit.anim.node.. parsed the output into a list of 9 elements (0,1,2,4,5,8,9,10) and sent the list (rotation matrix) to the right inlet of jit.traffic to perform matrix transformations with the original coordinates sent the left inlet. When I redraw the cube using the traffic output as coordinate values, the cube position doesn’t match the rotated source… (row/column transposition of the rotation matrix doesn’t help either)

I will post a patch if it will help, but it’s currently part of a much larger project so I would need to spend some time to abbreviate it. I’m really just looking for some direction here…

thanks!


December 27, 2013 | 10:10 am

posting a patch demonstrating your technique will get you more help.
without seeing the patch, i’m assuming you can’t use matrixoutput 2 of a jit.gl.gridshape @shape cube.

what you can do is create a jit.anim.node hierarchy, where the parent node represents the "cube" and the child nodes represent the points of the cube. when you rotate the parent node, the child node’s worldpos attribute will update appropriately. you can even use a single child anim.node and iterate the points, updating and calling getworlpos each frame.

here’s a basic patch demonstrating:

<code>

– Pasted Max Patch, click to expand. –

</code>


Viewing 5 posts - 1 through 5 (of 5 total)