/******************************************************************* ** Programado por: Jean D. L. Amarante ** ** Estudante de Design Digital pela PUC-PR ** ** Contatos: jean.amarantes@gmail.com ** ** http://pt-br.facebook.com/people/Jean-Amarante/ ** ******************************************************************* ******************************************************************* */ import saito.objtools.*; import saito.objloader.*; import ddf.minim.*; import ddf.minim.signals.*; Minim minim; AudioOutput out; SineWave sine; float rotx = PI/4; float roty = PI/4; float cor; PImage fundo1, fundo2, lua, ufo, nuvem, bot1, bot2, corpo; OBJModel cabeca; void setup() { size(800, 600, P3D); cabeca = new OBJModel(this, "cabeca.obj"); fundo1 = loadImage("fundo1.png"); fundo2 = loadImage("fundo2.png"); lua = loadImage("lua.png"); ufo = loadImage("ufo.png"); nuvem = loadImage("nuvem.png"); bot1 = loadImage("bot1.png"); bot2 = loadImage("bot2.png"); corpo = loadImage("corpo.png"); imageMode(CENTER); minim = new Minim(this); out = minim.getLineOut(Minim.STEREO); sine = new SineWave(440, 0.5, out.sampleRate()); sine.portamento(200); out.addSignal(sine); } void draw() { background(0); sound(); lights(); cor = map(mouseX, 0, width, 0, 255); rotateY(map(mouseX, 0, width, -0.02, 0.02)); fundo(); nuvens(); pushMatrix(); translate(100, 0, 2); nuvens(); translate(50, 20, 2); scale(0.5); nuvens(); translate(150, -90, 2); nuvens(); popMatrix(); pushMatrix(); translate(width/2+82, height/2+75, 250); scale(0.7); homem(); corpo(); popMatrix(); pushMatrix(); translate(width/2+90, height/2-35, 250); scale(30); cab(); popMatrix(); pushMatrix(); translate(width/2-mouseX/5, height/2-mouseY/5, 100); rotateY(frameCount*0.05); rotateX(frameCount*0.05); fill(255); noStroke(); cube(); stroke(0); popMatrix(); pushMatrix(); translate(mouseX, mouseY, 20); scale(0.3); image(ufo, 0, 0); popMatrix(); translate(50, 75, 21); scale(0.8); botoes(); } void fundo() { pushMatrix(); translate(width/2, height/2, -100); tint(cor, rotx*150, 255); image (fundo2, 0, 0); translate(0, 0, 10); image (lua, -150, -rotx*100); translate(0, 0, 20); image (fundo1, random(0, 3), 0); popMatrix(); } void nuvens() { pushMatrix(); translate(40+mouseX*0.05, 70); image (nuvem, 0, 0); image (nuvem, 400, 30); image (nuvem, 250, 60); popMatrix(); } void corpo() { image(corpo, 0, 0); } void homem() { rotateY(-0.5); rotateY(map(mouseX, 0, width, -0.09, 0.09)); } void cab() { rotateY(-0.5); rotateY(roty); cabeca.drawMode(POLYGON); cabeca.draw(); } void mouseDragged() { float rate = 0.01; rotx += (pmouseY-mouseY) * rate; roty += (mouseX-pmouseX) * rate; } void cube() { box (10+rotx*3); translate(50, 0); rotateX(frameCount*0.05); rotateY(frameCount*0.05); box (10+rotx*3); translate(-50, 0); rotateX(frameCount*0.05); rotateY(frameCount*0.05); box (10+rotx*3); } void sound() { if (mouseX >=10&&mouseX< width-10&&mouseY >=10&&mouseX< height-10) { for (int i = 0; i < out.bufferSize() - 1; i++) { float x1 = map(i, 0, out.bufferSize(), 0, width); float x2 = map(i+1, 0, out.bufferSize(), 0, width); line(x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50); line(x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50); } } } void botoes() { image(bot1, 0, 600); if (mousePressed) { if (mouseX<73 && mouseY>531) { image(bot2, 0, 600); } } } void mouseReleased() { if (mouseX<73 && mouseY>531) { link("http://pt.wikipedia.org/wiki/Salvador_Dal%C3%AD"); } } void mouseMoved() { float freq = map(mouseY, 0, height, 900, 0); sine.setFreq(freq); float pan = map(mouseX, 0, width, -1, 1); sine.setPan(pan); } void stop() { out.close(); minim.stop(); super.stop(); }