tracking moving points in openGL?
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.
take a look at the help files and let me know if it isn’t clear.
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"
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.
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…
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 942.3oc2X1sbhBCEG+Z8oHCW65PBeHcuxmh8lc1wIBoZ5fIrIgpsc569FRPq 5TQjFoL63HYRHbxe9kONmCuMdj2R9NhzC7SvuAiF813QiLMU0vn55i71f2kl iklt4wHa4Kexah8VJxNko4mnpoqxmtRPyjqwEDvbYJNm.7mBAyS44bA.B70+ zUwkJ9FrhlB72amG4LECugXr0uHhLLCu+drxM7RUNQYD.ptUaSpWJHV0WofE ZqJn67l.77.+4HSKouZ5FDM0+CqRY6MJrtwBrJcMksZgfjpr1Ek3qeFPHzTD DUYA.BN0+v.PyLpVSke.m4U016iGWcYxWCoJvRPtCAzRLa08.MAyrEgMRlXG RFY4RohpJUDvVtHOqfKA5+TEkybHvtcXgtNrBMEPasKRqHmtNZEQcfScZMUP SHx4qqBsKnP0nB17VtPGhpBAofvx9BKlfWjTtlNvZ5.ajNANjNulOUlSSIff g5lrZ1Tu6B527lLjCYSk+OphHb7dq6w9JXTqnCzwz4rnCLEE4XltRFcC.o+M 25+VShhRE.t2L4TFIkWxTGO6ObiXXOlq4qsHH9BX128XdCQtdfDX0CWFSAAV LUSqfFWMl3XJgYzMSY7LReeRl1CijvT3JuKGCCTh0k2rpB+5KGL1MFQF5g1r CO3+EldizoFKWgNcx4fhuZUNo4HCJvBMSztJVPX3k4lWF+K89SqNz6VWEXia J3rqe1K4CNNcEh.KI2gTVr10YGPe77ebios3x749qdVWvAQNLnRCebVvSFdX ONNNtIpD63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