Enhanced For Loop to General For Loop
in
Programming Questions
•
2 years ago
Hi... playing with one of the Sensebloom Processing examples (
here), for receiving OSC values from osceleton...
There's a
Skeleton Class, with a bunch of arrays for each xyz position of a skeleton joint, then an array named
allCoords that holds each of those within it...
In the
draw() function, it's called like this:
- for (Skeleton s: skels.values()) {
- stroke(s.colors[0], s.colors[1], s.colors[2]);
- for (float[] j: s.allCoords) {
- pushMatrix();
- translate(j[0]*width, j[1]*height, -j[2]*100);
- sphere(20);
- popMatrix();
- }
So, getting down to my question, I'm trying to draw vertexes (vertices ?) between the points, but I'm having a little trouble unpacking the way the For Loop is written. I've found
this page on the Oracle site that explains it is an 'Enhanced For Loop' for dealing with arrays...
I want to rewrite it into a 'General' for loop, but am getting a bunch of errors:
for (int j = 0; j < s.allCoords; j++) {
returns "The operator < is undefined for the argument type(s) int, float[][]"
for (int j = 0; j < s.allCoords[]; j++) {
and
for (float j = 0; j < s.allCoords[]; j++) {
returns "Syntax error on token"[", Expression expected after this token"
... so, I'm stuck. Any ideas welcome. Or... if anyone has already modified this example to draw a proper skeleton instead of spheres at the joints, that code would be welcome too (thought I do want to understand this...)
thanks,
~ J
1