//the Situation in 2009 //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 box void display() { stroke(255); fill(255,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 Pool = "Pool Heating"; String Cars = "Cars"; String Water = "Hot Water Heating"; String Electricity = "Electricity"; String EnergyHouse = "Energy House"; String Lighting = "Lighting"; // 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(6)) // pushMatrix() and popMatrix() are called inside the class' display() method. pushMatrix(); translate(x,y+30,z); //black texts; fill(255); //text(Water, 43,0,0); text(words[index], 43,0,0); popMatrix(); pushMatrix(); translate(x,y+60,z); //black texts; fill(255); //text(Pool, 43,0,0); text(words[index], 43,0,0); popMatrix(); pushMatrix(); translate(x-50,y+100,z); //black texts; fill(255); //text(Electricity, 43,0,0); text(words[index], 43,0,0); popMatrix(); pushMatrix(); translate(x+30,y-20,z); //black texts; fill(255); // text(Lighting, 43,0,0); text(words[index], 43,0,0); popMatrix(); pushMatrix(); translate(x-20,y-60,z); //black texts; fill(255); //text(EnergyHouse, 43,0,0); text(words[index], 43,0,0); popMatrix(); pushMatrix(); translate(x-70,y-80,z); //black texts; fill(255); // text(Cars, 43,0,0); text(words[index], 43,0,0); popMatrix(); } }