How to go from plane to 3D

Hello @Karrajo,

For starters you need to work with the P3D renderer.

Some tutorials and references to get you started:
https://processing.org/tutorials/rendering
https://processing.org/reference/size_.html
https://processing.org/tutorials/p3d

Interesting topic:

I suggest you start simple and build on that…

Reference:
https://mathcurve.com/courbes3d.gb/lissajous3d/lissajous3d.shtml

Some modifications to your code for P3D to give you some ideas:

float t=1;
void setup() {
  size(800, 800, P3D);
}

void draw() {
  background(0);
  noStroke();
  fill(255);
  lights();

  int counter = (frameCount-1)%720; // 0 to 719 and repeats
  float angle = counter*(TAU/720);
  // println(frameCount, counter, angle, degrees(angle)); // Testing

  translate(width/2, height/2);
  rotateX(angle);

  for (int i = 0; i < 100; i++) {
    float x = width/4 * sin(t*i*PI*2);
    float y = height/4 * sin(t*i*PI*3);
    float z = 200*sin(t*i*PI*4);
    //rect(x, y, 2, 2);
    stroke(0, 255, 0);
    strokeWeight(5);
    
    point(x+20, y+20, z+20); // offset by 20 so the sphere did not cover it
  
    push();
    translate(x, y, z);
    noStroke();
    sphere(10);
    pop();

  }
  t += 0.00001;
}

I really had to throttle back on the example I provided since this is your journey.

Have fun!

:)

1 Like