Problem with Vectors: toxiclibs addSelf() vs translate()
in
Contributed Library Questions
•
1 year ago
Hi Forum!
I'm trying to help someone with a sketch, using a Vec3D from toxiclibs...
There are a number of flocking agents in an ArrayList, which are wandering about, and continually checking the distance between themselves and other members of the ArrayList population...
When this conditional is met (ie there is an agent too close), we want to translate up (or down) in the Z-Depth, moving up a layer and continuing to wander about, and draw their trail...
The problem is attempting to use either scaleSelf() or addSelf() methods from toxiclibs Vec3D class... in short, it's changing the direction of the vectors, not pushing/popping them on a matrix stack...
I thought to use a translate() call on the Z-depth only, and this works in the manner that it visually translates the agents current position, but we are drawing (and writing to file) the full xyz coordinates of the vector, and it obviously doesn't affect that, even if I try to put the same translate on the Vec3D itself...
There's lots of code, but this is the main section...
- //calls the accumulate function and returns in accum
- Vec3D accum = accumulate(population, rangeOfVis);
- //scales that value in the z direction only?
- accum.scaleSelf(0,0,1); // (this is the primary culprit)
- //accum.addSelf(0,0,1); // (tried this as well...)
- //adds that value to the pos of agent... seems to affect the vector's direction, rather than position
- pos.addSelf(accum);
If anyone has any ideas about where we're going wrong, etc., please feel free to point us in the right direction!
Cheers,
~ J
1