topical media & game development

talk show tell print

graphic-processing-algorithm-Ch08-p188-p188.pde / pde



  MyPoint[] points;
  void setup(){
    points = new MyPoint[8];
    points[0] = new MyPoint(-20., -20., -20.);
    points[1] = new MyPoint( 20., -20., -20.);
    points[2] = new MyPoint( 20., 20., -20.);
    points[3] = new MyPoint(-20., 20., -20.);
    points[4] = new MyPoint(-20., -20., 20.);
    points[5] = new MyPoint( 20., -20., 20.);
    points[6] = new MyPoint( 20., 20., 20.);
    points[7] = new MyPoint(-20., 20., 20.);
  }
  
  void draw(){
    background(255);
    strokeWeight(4);
    for(int i=0; i<8; i++)
      point( 50+ points[i].x, 50+ points[i].y);
  }
  
  void mouseDragged(){
    int xoff = mouseX - pmouseX;
    int yoff = mouseY - pmouseY;
    for(int i=0; i<points.length; i++){
      points[i].rotatey(radians(xoff));
      points[i].rotatex(radians(yoff));
    }
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.