// Conceptual Models / 2x2x2: Solid Ideas // by Herbert Spencer // October 2006 import saito.objloader.*; // General Variables float OD = 0.2; //Ortho distance... very tricky int axisLength = 100; // distance from origin int delayer = 7; // rotational delayer float currentX, currentY, currentZ = 0; // current roation in the axis float nextX, nextY, nextZ; // next rotation in the axis boolean rotating = false; // interpolated animation boolean orthoText = true; // if the text is present or not float textAlpha = 100.0; PImage legend; // Fonts PFont gillsans; PFont pixelfont; //3D objects OBJModel workModel; OBJModel travelModel; OBJModel leisureModel; OBJModel homeModel; // toggle visibility boolean showWork = true; boolean showTravel = false; boolean showLeisure = false; boolean showHome = false; void setup(){ size(900,600, P3D); //OPENGL works better but renders poorly the transparency ortho(-width*OD, width*OD, -height*OD, height*OD, -1000, 1000); legend = loadImage("legend.jpg"); // Font pixelfont = loadFont("Standard.vlw"); gillsans = loadFont("GillSansMT-Bold-24.vlw"); // 3D Objects workModel = new OBJModel(this); workModel.load("workBlob.obj"); travelModel = new OBJModel(this); travelModel.load("travelBlob.obj"); leisureModel = new OBJModel(this); leisureModel.load("leisureBlob.obj"); homeModel = new OBJModel(this); homeModel.load("homeBlob.obj"); } void draw(){ background(255); pushMatrix(); translate(30+width/2,height/2); pushMatrix(); scale(0.4,0.4); image(legend,-width*0.57, -height*0.49); popMatrix(); textFont(pixelfont, 16*OD); textAlign(LEFT); fill(100); text("Keyboard Navigation\n\n\nVIEWS:\n[1] social - explicitness\n[2] explicitness - energy\n[3] social - energy\n\n[W] WORK\n[T] TRANSPORT\n[L] LEISURE \n[H] HOME", -204, 60, 0); textFont(gillsans, 24*OD); textAlign(CENTER); if (orthoText == false) { pushMatrix(); fill(0,textAlpha); { text("SOCIAL", 90, -50,0); text("PERSONAL", -90, 55,0); text("HIGH ENERGY", 95, 55,0); text("LOW ENERGY", -95, -50,0); text("EXPLICIT", 0, -75,0); text("IMPLICIT", -0, 80,0); } popMatrix(); } { // rotate with keys (1,2,3) and mouseDrag rotateX(currentX); rotateY(currentY); rotateZ(currentZ); if (rotating == true){ // interpolate the rptation smoothly currentX += (nextX - currentX)/delayer; currentY += (nextY - currentY)/delayer; currentZ += (nextZ - currentZ)/delayer; // make the text fade in every time there is a keyboard rotation textAlpha = 100 - 200*dist(currentX, currentY, currentZ, nextX, nextY, nextZ); if(dist(currentX, currentY, currentZ, nextX, nextY, nextZ) < 0.001){ rotating = false; } } pushMatrix(); { drawModels(); //draws the blobls fill(0,textAlpha); scale(OD*5,OD*5); stroke(255,0,0,100); line(-axisLength, 0, 0, axisLength, 0, 0); //RED X if (orthoText == true) { text("SOCIAL", 115, 1.6,0); // text("PERSONAL", -120, 1.6,0); // text("EXPLICIT", 0, -104,0); // text("IMPLICIT", -0, 108,0); // } stroke(0,255,0,100); line(0, -axisLength, 0, 0, axisLength, 0); //GREEN Y if (orthoText == true) { pushMatrix(); { rotateY(-PI/2); text("HIGH ENERGY", 125, 1.6,0); // text("LOW ENERGY", -125, 1.6,0); // text("EXPLICIT", 0, -104,0); text("IMPLICIT", -0, 108,0); } popMatrix(); } stroke(0,0,255,100); line(0, 0, -axisLength, 0, 0, axisLength); //BLUE Z if (orthoText == true) { pushMatrix(); { rotateX(PI/2); text("SOCIAL", 115, 1.6,0); // text("PERSONAL", -120, 1.6,0); // text("LOW ENERGY", 0, -104,0); text("HIGH ENERY", -0, 108,0); } popMatrix(); } } popMatrix(); } popMatrix(); } void drawModels() { noStroke(); //stroke(0,20); if(showWork == true){ workModel.draw(); } if(showTravel == true){ travelModel.draw(); } if(showLeisure == true){ leisureModel.draw(); } if(showHome == true){ homeModel.draw(); } } // key specifications void keyPressed(){ if(key =='1'){ nextX = 0; nextY = 0; nextZ = 0; rotating = true; orthoText = true; } if(key =='2'){ nextX = 0; nextY = PI/2; nextZ = 0; rotating = true; orthoText = true; } if(key =='3'){ nextX = -PI/2; nextY = 0; nextZ = 0; rotating = true; orthoText = true; } if(key =='4'){ nextX = -PI/4; nextY = PI/4; nextZ = 0; rotating = true; orthoText = false; } if(key =='i' || key =='I'){ orthoText = false; } if(key =='o' || key =='O'){ orthoText = true; } if(key =='w' || key =='W'){ showWork = !showWork; } if(key =='t' || key =='T'){ showTravel = !showTravel; } if(key =='l' || key =='L'){ showLeisure =!showLeisure; } if(key =='h' || key =='H'){ showHome = !showHome; } } void mouseDragged() { currentY += (mouseX - pmouseX) * -0.01; currentX += (mouseY - pmouseY) * 0.01; textAlpha = 0; } void mousePressed(){ //println(mouseX+" "+mouseY); if(mouseX<93 && mouseX>9 && mouseY<55 &&mouseY>5){ showHome = !showHome; } if(mouseX<173 && mouseX>101 && mouseY<55 &&mouseY>5){ showWork = !showWork; } if(mouseX<269 && mouseX>191 && mouseY<55 &&mouseY>5){ showTravel = !showTravel; } if(mouseX<375 && mouseX>285 && mouseY<55 &&mouseY>5){ showLeisure =!showLeisure; } }