import saito.objloader.*; import processing.opengl.*; OBJModel model; boolean stroked=false; // set position scale and rotation //rotations// float rotX= 0.080000035; float rotY= 1.5807964; float rotZ= 0.02; //positions// float posX= 10.299912; float posY= 28.299896; float posZ= 0.0; //scalings// float scalerW= 26.30007; float scalerD= 79.50012; float scalerH= 82.89996; //camera lens// float fov= 1.0; void setup() { size(1024, 768, OPENGL); frameRate(14); noStroke(); hint(ENABLE_ACCURATE_TEXTURES); // float cameraZ = (height/2.0) / tan(fov/2.0); perspective(fov, float(width)/float(height), cameraZ/10.0, cameraZ*10.0); // model = new OBJModel(this, "crystaphyll_heightMapped.obj"); model.drawMode(TRIANGLES); model.enableTexture(); setupTexture(); } void draw() { background(0); model.setTexture(renderTexture()); pushMatrix(); translate(width/2+posX, height/2+posY, posZ); setupLights(); renderLights(); rotateZ(rotZ); rotateX(rotX); rotateY(rotY); scale(scalerW, scalerD, scalerH); model.draw(); popMatrix(); printTransfomrations(); println("frame rate: "+frameRate); } void keyPressed() { if(key == 's') { if(stroked) { stroked = false; noStroke(); } else{ stroked = true; stroke(0,0,255); strokeWeight(2); } } } void mouseDragged() { if(keyPressed) { if(key == 'd') { scalerD += (mouseX - pmouseX)*.1; } if(key == 'w') { scalerW += (mouseX - pmouseX)*.1; } if(key == 'h') { scalerH += (mouseY - pmouseY)*.1; } // if(key == 'X') { rotX += (mouseY - pmouseY) * 0.01; } if(key == 'Y') { rotY -= (mouseX - pmouseX) * 0.01; } if(key == 'Z') { rotZ += (mouseY - pmouseY) * 0.01; } // if(key == 'x') { posX += (mouseX - pmouseX) * 0.1; } if(key == 'y') { posY -= (mouseY - pmouseY) * 0.1; } if(key == 'z') { posZ += (mouseY - pmouseY) * 0.1; } // if(key == 'l') { fov += (mouseX - pmouseX) * 0.01; } } } void printTransfomrations() { println("//rotations//"); println(" float rotX= "+rotX+"; "); println(" float rotY= "+rotY+"; "); println(" float rotZ= "+rotZ+"; "); println("//positions//"); println(" float posX= "+posX+"; "); println(" float posY= "+posY+"; "); println(" float posZ= "+posZ+"; "); println("//scalings//"); println(" float scalerW= "+scalerW+"; "); println(" float scalerD= "+scalerD+"; "); println(" float scalerH= "+scalerH+"; "); println("//camera lens//"); println(" float fov= "+fov+"; "); println("\r\r"); }