some path problems

pseudostereo's icon

In this patch, both paths are receiving the same position data from jit.bfg. The green jit.gl.path gets its data directly, and the red path gets it through the @drawpath attribute of the jit.anim.path.

Why aren't the two paths the same?

Why is the red path two dimensional? (all points are at the same depth)

Why doesn't the yellow sphere stay on the red path evenly from beginning to end?

Also: the docs for jit.path and jit.anim.path (but not jit.gl.path) list a 'closed' attribute. That would be nice, but that attribute doesn't seem to exist.

Max Patch
Copy patch and select New From Clipboard in Max.

TFL's icon

jit.anim.path and jit.gl.path don't take the same input.

jit.anim.path needs at least a 4 planes matrix where the first plane is the time stamp of each point and next 3 planes are XYZ, while jit.gl.path just needs XYZ.

So when sending your 3 planes XYZ matrix to jit.anim.path, your X position is interpreted as time stamps, Y becomes X, Z becomes Y, and you have nothing for Z.

That's why with jit.anim.path you were getting a 2D path with uneven trajectory speed.

What I did is to make jit.bfg to output a 4 planes matrix (even though we will only use 3), reducing the dimension to a 2D matrix (so it makes more sense in my head), and properly generating 1st plane for jit.anim.path with time stamps. For that I just used [cell], so that first point is at time 0, 2nd point at 1s, 3rd point at 2s, etc.

Max Patch
Copy patch and select New From Clipboard in Max.

EDIT: and all jit.path, jit.anim.path and jit.gl.path does have a @closed attribute

pseudostereo's icon

Thanks a lot TFL, all makes sense now.

Hadn't noticed that the 'closed' attribute is read only - apparently you close it via a 'closepath' message, which adds an endpoint in the same position as the first point.

One last question: once you close the path with 'closepath': how do you open it back up again? I guess you just delete the extra point? Seems to me it would make more sense to have 'closepath 1' & 'closepath 0'.

TFL's icon

In order to make closepath to work in your patch, you need to stop banging the [jit.bfg] every frame, as it resets the path every frame, removing the point created with closepath. You just need to send the path matrix once, and when you update it, and then send closepath.

And to unclose the path, indeed you can delete the last point. Here we know that we have 64 points (from index 0 to 63) and that the closing point (65th) will be the point at index 64, so you can use "delete 64", but otherwise you can use the pointcount (get only) attribute to know which point index to delete.

Max Patch
Copy patch and select New From Clipboard in Max.