We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone,
I am new to processing and I am trying to extrude a 2D shape into 3D. The figure that I want to draw is made up of curves, beziers, and ellipses.
Is there any method, technique or library that I can use to extrude my custom 2D shape into 3D. I want to be able to give my 2D shape some depth and turn it into 3D.
The figure that I am trying to extrude into 3D is similar to this one.
void setup() {
size(600, 450, P3D);
background(255);
}
void draw() {
stroke(0);
strokeWeight(1.5);
noFill();
int x = 300;
int y = 220;
bezier(x + 50, y - 50, x + 30, y - 30, x + 30, y + 30, x + 50, y + 50);
bezier(x + 40, y - 40, x + 20, y - 20, x + 20, y + 20, x + 40, y + 40);
bezier(x - 50, y - 50, x - 30, y - 30, x - 30, y + 30, x - 50, y + 50);
bezier(x - 40, y - 40, x - 20, y - 20, x - 20, y + 20, x - 40, y + 40);
bezier(x - 50, y - 50, x - 30, y - 30, x + 30, y - 30, x + 50, y - 50);
bezier(x - 40, y - 40, x - 20, y - 20, x + 20, y - 20, x + 40, y - 40);
bezier(x - 50, y + 50, x - 30, y + 30, x + 30, y + 30, x + 50, y + 50);
bezier(x - 40, y + 40, x - 20, y + 20, x + 20, y + 20, x + 40, y + 40);
}
Answers
If you want to do your own extrusion, in general, you want:
So for a list of points:
You also want to draw everything again and add a z:
...and then connect the two:
To move from @Chrisir's concrete example to a more general extrude solution:
You can draw your 2D layer as a PShape. This could be anything made out of a vertex list.
Actually, because copying PShapes can be complex / impossible, create a constructor to build your PShape, and have it take a z argument.
i tried to work further on this but it's very confusing
I tried using bezierVertex() together with beginShape() but then the points must be in a certain order and apparently they were not
It was a mess
at least I have done one side wall filled in red
here is the mess (my mistake, not yours!)
But I think, bezierVertex() is so complicate to work with, one should write a class to be a wrapper for it basically. There is now so much repetition in my code