Storing input for 3d shapes

Hi everyone! I am new to processing. I am trying to draw a shape and store 5 shapes before the current one, so the fade consequently (like in this example:
(or maybe I can use some redraw function, I dunno)

But I cannot manage to combine it within my code… Can anyone help?

Here is the code:

int memory = 5; // the amount of stored shapes

void setup() {
  size(200, 200, P3D);

void draw() {
  float misha = random(200,800);
  translate(width/2, height/2);
  int amnt = 10; //amnt of lines
  PVector[][] pp = new PVector[amnt][amnt];
    for (int i = 0; i < amnt; i++) {
      float lat = map(i, 0, amnt-1, -HALF_PI, HALF_PI);
      for (int j = 0; j < amnt; j++) {
        float lon = map(j, 0, amnt-1, -PI, PI);
        int imnd = i + j * amnt;
        float r = 20 + misha; // begin radius * max radius
        float x = r * cos(lat) * cos(lon);
        float y = r * sin(lat) * sin(lon);
        float z = r * sin(lon);
        pp[i][j] = new PVector(x,y,z);
    for (int i = 0; i < amnt-1; i++) {
      stroke(500,20, misha); //blending colors
      for (int j = 0; j < amnt; j++) {
1 Like

If you want a global array that persists between draw loops, then you need to define your data globally, in the header like int memory. Otherwise pp is wiped out and completely recreated each time draw() runs.

1 Like

Thank you for your reply!

How could I do it in this case?

Move this line to the top line of the sketch and remove the amnt:

PVector[][] pp = new PVector[][];

Then size it in setup:

void setup() {
  size(200, 200, P3D);
  pp = new PVector[amnt][amnt];