//the Situation in 2020 //by Jia Tao //2009.11 // A Rotater class class Rotater { float x,y,z; // x,y,z location float theta; // angle of rotation float speed; // speed of rotation float w; // size of box Rotater(float tempX, float tempY, float tempZ, float tempSpeed, float tempW) { x = tempX; y = tempY; z = tempZ; // Angle is always initialized to 0 theta = 0; speed = tempSpeed; w = tempW; } // Increment angle void spin() { theta += speed; } // Display boxes void display() { stroke(0); fill(0,100); // pushMatrix() and popMatrix() are called inside the class' display() method. // This way, every Rotater object is rendered with its own independent translation and rotation! pushMatrix(); translate(x,y,z); rotateX(theta); rotateY(theta); box(w); popMatrix(); } // Display text void displayText() { String solar = "Solar"; // an array of strings shown besides each box. String[] words = { "Cars", "Pool Heating", "Hot Water Heating", "Electricity","Energy House","Lighting" }; int index = int(random(words.length)); // same as int(random(4)) // pushMatrix() and popMatrix() are called inside the class' display() method. pushMatrix(); translate(x+20,y,z); //red text fill(255, 0, 0); text(solar, 0,0,0); //black texts; fill(0); text(words[index], 43,0,0); popMatrix(); } }