Hi,
it has nothing to do with peasycam, more with processing.
You can set the x-coordinates of your art being exactly around zero (e.g. going from -100 to +100).
When you then use rotate() and translate your art into the middle of the screen, the thing rotates around itself.
This scares me every time I do it.
Greetings, Chrisir
- float CameraX;
- float CameraY;
- float angle;
- void setup()
- {
- size( 800, 800, P3D );
- CameraX = width / 2.0;
- CameraY = 50;
- // noCursor();
- } // setup
- void draw()
- {
- background(0);
- // camera
- camera(
- CameraX, CameraY, 700,
- width/2.0, height/2.0, 0,
- 0, 1, 0);
- // Floor
- drawFloor();
- // ==================================================
- // paint box
- stroke(111, 110, 110);
- fill(111, 110, 110);
- pushMatrix();
- translate(width/2, 0, 0);
- rotateY(angle);
- MyBox (-100, 350, -0,
- 100, 350, -0,
- 15, color (2, 0, 255));
- popMatrix();
- //
- angle+=.01;
- } // draw
- void keyPressed() {
- if (key == CODED) {
- //
- if (keyCode == UP) {
- CameraY-=10;
- // println("UP");
- }
- else if (keyCode == DOWN) {
- CameraY+=10;
- }
- else if (keyCode == RIGHT) {
- CameraX+=10;
- }
- else if (keyCode == LEFT) {
- CameraX-=10;
- }
- else {
- // nothing
- }
- }
- else {
- // not key == CODED
- //
- }
- }
- void MyBox(float x1, float y1, float z1,
- float x2, float y2, float z2,
- float weight, color strokeColour)
- // was called drawLine; programmed by James Carruthers
- // see http://processing.org/discourse/yabb2/YaBB.pl?num=1262458611/0#9
- {
- PVector p1 = new PVector(x1, y1, z1);
- PVector p2 = new PVector(x2, y2, z2);
- PVector v1 = new PVector(x2-x1, y2-y1, z2-z1);
- float rho = sqrt(pow(v1.x, 2)+pow(v1.y, 2)+pow(v1.z, 2));
- float phi = acos(v1.z/rho);
- float the = atan2(v1.y, v1.x);
- v1.mult(0.5);
- pushMatrix();
- translate(x1, y1, z1);
- translate(v1.x, v1.y, v1.z);
- rotateZ(the);
- rotateY(phi);
- noStroke();
- fill(strokeColour);
- box(weight, weight, p1.dist(p2)*1.2);
- popMatrix();
- }
- void drawFloor() {
- stroke(255);
- // draw floor:
- float floorY=600;
- // to right (background)
- line ( 20, floorY, -200,
- width-20, floorY, -200);
- // to right (in the front)
- line ( 20, floorY, -0,
- width-20, floorY, -0);
- // left side
- line ( 20, floorY, -200,
- 20, floorY, -0);
- // right side
- line ( width-20, floorY, -200,
- width-20, floorY, -0);
- }
- //