import processing.opengl.*; //bindet die opengl-bibliothek ein import saito.objloader.*; //bindet OBJ model-bibliothek ein OBJModel model1; OBJModel model2; OBJModel model3; float basicScale = 1.0; float value = basicScale; float radX = 0; float radY = 0; float radZ = 0; // these booleans will be used to turn on and off bits of the OBJModel boolean bTexture = true; boolean bStroke = false; boolean bMaterial = true; void setup() { size(400, 400, OPENGL); model1 = new OBJModel(this); model1.load("chair.obj"); model1.setDrawMode(POLYGON); model2 = new OBJModel(this); model2.load("chair.obj"); model2.setDrawMode(POLYGON); model3 = new OBJModel(this); model3.load("chair.obj"); model3.setDrawMode(POLYGON); PFont fontA = loadFont("CourierNew36.vlw"); textFont(fontA, 20); noStroke(); frameRate(10); } int posX = 0; int posY = 0; int posZ = 0; int x = -100; int y = -200; int z = 400; void draw() { //background(180); background(0); lights(); directionalLight(255, 255, 255, -1, 0, 0); directionalLight(255, 255, 255, 0, -1, 0); directionalLight(255, 255, 255, 0, 1, 0); translate(width/2, height/1.5); //camera(-100, -200, 400, 0.0, 0.0, 0.0, 0, 1, 0); camera(x, y, z, 0.0, 0.0, 0.0, 0, 1, posZ); //coordinates(); pushMatrix(); rotateX(radX); //rotiert das objekt rotateY(radY); //rotiert das objekt rotateZ(radZ); //rotiert das objekt scale(value); model1.draw(); translate(100,0); rotateY(1); model2.draw(); translate(100,0); rotateY(2); model3.draw(); popMatrix(); //display(); if(z > -300){ z = z -10; } else{ if(x < 180){ x = x +10; } else if(y < 500){ y = y+10; } else if(y < 4000){ y = y+50; } else{ x = -100; y = -200; z = 400; } } } void mouseDragged() { if (mouseButton == LEFT) { radX = (float)mouseY/(width/2)*PI; radY = (float)mouseX/(height/2)*PI; //radZ = (float)mouseX/(width/2)*PI; } } void coordinates() { stroke(50); fill(0); line(0,0,0,250,0,0); text("+x",250,0,0); line(0,0,0,0,250,0); text("+y",0,250,0); line(0,0,0,0,0,250); text("+z",0,0,250); noStroke(); noFill(); } void keyPressed() { if (key == CODED) { if (keyCode == UP) { x += 10; } else if (keyCode == DOWN) { x -= 10; } else if (keyCode == LEFT) { y += 10; } else if (keyCode == RIGHT) { y -= 10; } } redraw(); } void display() { fill(0); text("eyeX = "+posX,10,20); text("eyeY = "+posY,10,40); text("eyeZ = "+posZ,10,60); text("x = "+x,10,80); text("y = "+y,10,100); text("z = "+z,10,120); noFill(); }