Automatically zoom out using mouseWheel and PeasyCam?

Hello,

I have a P3D (3 dimensional) sketch that I've written and need help in automating or possibly dynamically changing the zoom out speed/rate. I have imported the PeasyCam library mrfeinberg.com/peasycam/ , which for the life of me I can not understand the reference.

Processing also inherently has the mouseWheel function.

My code is below, thanks for any suggestions and help in advance.

`import peasy.*; PeasyCam cam;

Line[] lines; Line[] lines2; Line[] lines3; Line[] lines4;

PVector start_pos, start_pos2, start_pos3, start_pos4; PVector end_pos, end_pos2, end_pos3, end_pos4;

void setup(){ size(displayWidth,displayHeight,P3D); cam = new PeasyCam(this, 0,0,0,100); cam.lookAt(0,0,0); //cam.setRollRotationMode(); cam.setSuppressRollRotationMode(); cam.setWheelScale(.1);

                                  //camera(0,0,0, 0,0,0,  0, 1, 0);

start_pos = new PVector(0, 0, 0); end_pos = new PVector(0, 0, 0);

start_pos2 = new PVector(0, 0, 0); end_pos2 = new PVector(0, 0, 0);

start_pos3 = new PVector(0, 0, 0); end_pos3 = new PVector(0, 0, 0);

start_pos4 = new PVector(0, 0, 0); end_pos4 = new PVector(0, 0, 0);

lines = new Line[1000]; lines2 = new Line[1000]; lines3= new Line[1000]; lines4= new Line[1000];

for(int i = 0; i < lines.length; i++){ lines[i] = new Line(start_pos, end_pos, color(random(0, 255), random(0, 255), random(0, 255)) ); start_pos = end_pos.copy(); end_pos.x = random(-100, 100); end_pos.y = random(-100, 100); end_pos.z += 100; }

for(int i = 0; i < lines2.length; i++){ lines2[i] = new Line(start_pos2, end_pos2, color(random(0, 255), random(0, 255), random(0, 255)) ); start_pos2 = end_pos2.copy(); end_pos2.x = random(-100, 100); end_pos2.y = random(-100, 100); end_pos2.z += 100; }

for(int i = 0; i < lines3.length; i++){ lines3[i] = new Line(start_pos3, end_pos3, color(random(0, 255), random(0, 255), random(0, 255)) ); start_pos3 = end_pos3.copy(); end_pos3.x = random(-100, 100); end_pos3.y = random(-100, 100); end_pos3.z += 100; }

for(int i = 0; i < lines4.length; i++){ lines4[i] = new Line(start_pos4, end_pos4, color(random(0, 255), random(0, 255), random(0, 255)) ); start_pos4 = end_pos4.copy(); end_pos4.x = random(-100, 100); end_pos4.y = random(-100, 100); end_pos4.z += random(50,250); } }
void draw(){ //rotateY(-1000); //rotateX(-1000); background(0, 127);

for(int i = 0; i < lines.length; i++){ lines[i].display(); }

for(int i = 0; i < lines2.length; i++){ lines2[i].display(); }

for(int i = 0; i < lines3.length; i++){ lines3[i].display(); }

}

class Line{ color col; PVector pos1; PVector pos2;

Line(PVector p1, PVector p2, color c){ pos1 = p1.copy(); pos2 = p2.copy(); col = c; }

void display(){ stroke(col); strokeWeight(3); line(pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z); } }`

Tagged:

Answers

Sign In or Register to comment.