# Storing input for 3d shapes

**URL:** <https://discourse.processing.org/t/storing-input-for-3d-shapes/21024>\
**Category:** Coding Questions\
**Created:** [May 18, 2020, 5:38pm UTC](https://discourse.processing.org/t/storing-input-for-3d-shapes/21024 "2020-05-18T17:38:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbro](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrbro/32/8485_2.png) [@mrbro](https://discourse.processing.org/u/mrbro)\
**Post date:** [May 18, 2020, 5:38pm UTC](https://discourse.processing.org/t/storing-input-for-3d-shapes/21024/1 "2020-05-18T17:38:34Z")

</div>

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: [https://processing.org/examples/storinginput.html](https://processing.org/examples/storinginput.html)).  
(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:

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

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

void draw() {
  background(204);
  
  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++) {
      beginShape(TRIANGLE_STRIP);
      stroke(500,20, misha); //blending colors
      noFill();
      for (int j = 0; j < amnt; j++) {
        vertex(pp[i][j].x,pp[i][j].y,pp[i][j].z);
        vertex(pp[i+1][j].x,pp[i+1][j].y,pp[i+1][j].z);
      }
      endShape();
    }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 20, 2020, 7:37pm UTC](https://discourse.processing.org/t/storing-input-for-3d-shapes/21024/2 "2020-05-20T19:37:27Z")

</div>

> [@mrbro](#):
>
> and store 5 shapes

> [@mrbro](#):
>
> `PVector[][] pp = new PVector[amnt][amnt];`

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.

---

<div class="post-metadata">

**Author:** ![mrbro](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrbro/32/8485_2.png) [@mrbro](https://discourse.processing.org/u/mrbro)\
**Post date:** [May 21, 2020, 3:45pm UTC](https://discourse.processing.org/t/storing-input-for-3d-shapes/21024/3 "2020-05-21T15:45:55Z")

</div>

Thank you for your reply!

How could I do it in this case?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 21, 2020, 8:24pm UTC](https://discourse.processing.org/t/storing-input-for-3d-shapes/21024/4 "2020-05-21T20:24:42Z")

</div>

> [@mrbro](#):
>
> `PVector[][] pp = new PVector[amnt][amnt];`

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

```auto
PVector[][] pp = new PVector[][];

```

Then size it in setup:

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

```
