Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float angle = 0.0;
- void setup() {
- size(600, 600, P3D);
- }
- void draw() {
- background(255);
- translate(width/2, height/2);
- rotateX(angle);
- rotateY(angle);
- drawHemisphere(new PVector(HALF_PI, 0, 0), 100, 60, 60);
- angle += 0.01;
- }
- void drawHemisphere(PVector rot, float radius, float slicesA, float slicesB) {
- float a, b, x, y, z, da, db;
- da = TWO_PI / slicesA;
- db = HALF_PI / slicesB;
- rotateX(rot.x);
- rotateY(rot.y);
- rotateZ(rot.z);
- noStroke();
- fill(0, 255, 0, 127);
- beginShape(QUAD_STRIP);
- for (b=0; b < HALF_PI; b += db) {
- for (a=0; a < TWO_PI+da; a += da) {
- x = cos(a) * cos(b) * radius;
- y = sin(a) * cos(b) * radius;
- z = sin(b) * radius;
- vertex(x, y, z);
- x = cos(a) * cos(b+db) * radius;
- y = sin(a) * cos(b+db) * radius;
- z = sin(b+db) * radius;
- vertex(x, y, z);
- }
- }
- endShape();
- rotateZ(-rot.z);
- rotateY(-rot.y);
- rotateX(-rot.x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement