Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import damkjer.ocd.*;
- Camera camera;
- float rotation = 0;
- float phi,theta;
- float phiStart = 0.5, thetaStart = 2;
- float xstart,ystart;
- final float height_setka = 40;
- final float height_table = 5;
- final float long_table = 500;
- final float width_table = 300;
- float XposCircle = - 200;
- float YposCircle = -50;//-7.5;
- float ZposCircle = 0;
- float radius = 5;
- float xspeed = 3, yspeed = 0, zspeed = 0;
- float gravity = 0.02;
- final float thin_setka = 2;
- float orbitRadius = 0;
- float ypos = 130;
- float xpos= cos(rotation)*orbitRadius;
- float zpos= sin(rotation)*orbitRadius;
- float scale = 1;
- int mashtab;
- float yFloor;
- float x_set = 0, y_set = 0, z_set = 0;
- void setup() {
- size(1000, 700, P3D);
- camera = new Camera(this, -80,0,-55);
- camera.feed();
- updateView();
- }
- void draw() {
- lights();
- camera.feed();
- background(130);
- stroke(255);
- fill(53, 88, 53);
- yFloor = height_table/2 + 100;
- //camera(xpos, ypos, zpos, width/2.0, height/2.0, 0, 0, 1, 0);
- //0 0 0
- translate(width/2.0, height/2.0, 0);
- box(long_table, height_table, width_table);
- drawSetka();
- drawLegs();
- drawFloor();
- drawWalls();
- fill(255);
- noStroke();
- //pushMatrix();
- translate(XposCircle, YposCircle, ZposCircle);
- sphere(radius);
- XposCircle += xspeed;
- YposCircle += yspeed;
- ZposCircle += zspeed;
- xspeed *= 0.998;
- yspeed *= 0.998;
- zspeed *= 0.998;
- yspeed += gravity;
- if (XposCircle + radius > thin_setka/2 && YposCircle+radius>- height_table/2 - height_setka) {
- XposCircle = thin_setka/2 - radius;
- xspeed = xspeed * -0.5;
- }
- //<>// //<>//
- //println(YposCircle + radius, height_table/2);
- //<>//
- if (YposCircle + radius > -height_table/2 && XposCircle-radius<0 + long_table/2 && XposCircle + radius > 0 - long_table/2 && ZposCircle + radius > - width_table/2 && ZposCircle - radius < width_table/2) { //<>//
- yspeed = -yspeed * 0.9;
- YposCircle = -height_table/2 - radius;
- }
- //popMatrix();
- }
- void drawSetka() {
- pushMatrix();
- translate(0, - height_table/2 - height_setka/2, 0);
- fill(0, 0, 0, 100);
- box(thin_setka, height_setka, width_table);
- popMatrix();
- }
- void drawLegs() {
- fill(0);
- stroke(72);
- pushMatrix();
- translate(long_table/2 - 2, height_table/2 + 50, -width_table/2 + 2);
- box(4, 100, 4);
- popMatrix();
- pushMatrix();
- translate(-long_table/2 + 2, height_table/2 + 50, -width_table/2 + 2);
- box(4, 100, 4);
- popMatrix();
- pushMatrix();
- translate(long_table/2 - 2, height_table/2 + 50, width_table/2 - 2);
- box(4, 100, 4);
- popMatrix();
- pushMatrix();
- translate(-long_table/2 + 2, height_table/2 + 50, width_table/2 - 2);
- box(4, 100, 4);
- popMatrix();
- }
- void drawFloor() {
- pushMatrix();
- fill(251,17,17);
- stroke(150,0,0);
- translate(-1000,100 + height_table/2,-1000);
- box(4000,1,4000);
- popMatrix();
- }
- void drawWalls() {
- pushMatrix();
- fill(250,190,0);
- stroke(250,190,0);
- translate( - 1000,yFloor - 1000,-1000);
- box(1,4000,4000);
- popMatrix();
- pushMatrix();
- fill(250,190,0);
- stroke(250,190,0);
- translate( - 1000,yFloor - 1000,1000);
- box(4000,4000,1);
- popMatrix();
- pushMatrix();
- fill(250,190,0);
- stroke(250,190,0);
- translate(0,yFloor - 1000,-1000);
- box(4000,4000,1);
- popMatrix();
- pushMatrix();
- fill(250,190,0);
- stroke(250,190,0);
- translate(1000,yFloor - 1000,0);
- box(1,4000,4000);
- popMatrix();
- }
- void mouseDragged() {
- updateView();
- camera.feed();
- cursor(HAND);
- }
- void mouseReleased() {
- cursor(ARROW);
- }
- void mousePressed() {
- xstart = mouseX;
- ystart = mouseY;
- phiStart = phi;
- thetaStart = theta;
- camera.feed();
- }
- void mouseWheel(MouseEvent event) {
- scale = event.getCount();
- mashtab += scale;
- //updateView();
- }
- void updateView() {
- phi = phiStart + map(mouseX - xstart,0,width,-PI/2,PI/2);
- theta = thetaStart + map(mouseY - ystart,0,height,0,PI);
- if (theta < 0.1)
- theta = 0.1;
- else if (theta > PI)
- theta = PI;
- println(phi, theta);
- float r = 100;
- float x = r * sin(theta) * cos(phi);
- float y = r * sin(theta) * sin(phi);
- float z = r * cos(theta);
- println(x, " ",y ," ",z);
- camera.jump(x, z, y);
- camera.feed();
- }
Add Comment
Please, Sign In to add comment