Forget my last post.
looking at your code i had a stupid idea and thought i give it a try.
i am not sure if it is useful to do it this way. but looks good.
What i did was taking your vertexes , used beziercurve to get different steps and connected them by a triangle strip.
What do you think ?
Oh and like you see i added some moving/morphing.
Btw, got your email and will answer it tomorrow.
Code:int numSegments = 18;
float Ra = 150.0; // aperture / radius
float Ha = 100.0; // height
float angleSpace = TWO_PI / numSegments;
float offsetX, offsetY;
float rot = 0.0;
float[][] points = new float[numSegments][2];
void setup() {
size(640, 480, P3D);
offsetX = width * 0.5;
offsetY = height * 0.65;
}
void draw() {
background(0);
//noFill();
Ha = 100+((1+sin(frameCount/20.0))/2.0)*200;
Ra = 60+((1+cos(frameCount/20.0))/2.0)*140;
println(Ha);
for (int i = 0; i < numSegments; i++) {
float x = cos(i * angleSpace) * Ra;
float y = sin(i * angleSpace) * Ra;
points[i][0] = x;
points[i][1] = y;
}
directionalLight(51, 102, 126, -100, 100, 0);
directionalLight(51, 102, 126, 100, -200, 0);
pushMatrix();
// align the umbrella in the center
translate(offsetX, offsetY);
// perform rotation just to appreciate the geometry
rotateY(rot);
// rotate the umbrella 90 degrees, so it stands normally
rotateX(HALF_PI + 0.1);
// draw the umbrella
for (int i = 0; i < numSegments - 1; i++) {
umbrellaSegment(points[i][0], points[i][1], points[i + 1][0], points[i + 1][1], Ha, true);
}
// draw last segment of the umbrella
umbrellaSegment(points[numSegments - 1][0], points[numSegments - 1][1], points[0][0], points[0][1], Ha, true);
popMatrix();
rot += 0.015;
}
void umbrellaSegment(float x1, float y1, float x2, float y2, float h, boolean debugrender) {
if (debugrender == true) {
stroke(0, 127, 255);
noFill();
}
else {
noStroke();
fill(0, 127, 255, 255);
}
for (int i = 0; i <= 6; i++) {
float t = i / 6.0;
float x =bezierPoint(x1, x1, x1, 0, t);
float y =bezierPoint(y1, y1, y1, 0, t);
float z =bezierPoint(0, h * 0.5, h*0.4, h, t);
bezier(x1, y1, 0 ,x1, y1, h * 0.5, x1, y1, h*0.4 ,0, 0, h );
pushMatrix();
translate(x,y,z);
box(3);
popMatrix();
}
fill(255 );
stroke(0, 127, 255,100);
beginShape(TRIANGLE_STRIP);
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps) ;
float x =bezierPoint(x1, x1, x1, 0, t);
float y =bezierPoint(y1, y1, y1, 0, t);
float z =bezierPoint(0, h * 0.5, h*0.4, h, t);
float bx =bezierPoint(x2, x2, x2, 0, t);
float by =bezierPoint(y2, y2, y2, 0, t);
float bz =bezierPoint(0, h * 0.5, h*0.4, h, t);
vertex(x,y,z);
vertex(bx,by,bz);
}
endShape(CLOSE);
}