topical media & game development

talk show tell print

graphic-processing-algorithm-Ch09-p209-MyObject.pde / pde



  class MyObject{
    MyFace[] f = new MyFace[6]; //below are the orientations of a cube
    int[] xc =
    {
      -1,-1,1,1, 1,1,-1,-1, 1,-1,-1,1, 1,1,1,1, -1,1,1,-1, -1,-1,-1,-1  };
    int[] yc =
    {
      -1,1,1,-1, -1,1,1,-1, -1,-1,-1,-1, 1,-1,-1,1, 1,1,1,1, -1,1,1,-1  };
    int[] zc =
    {
      1,1,1,1, -1,-1,-1,-1, -1,-1,1,1, -1,-1,1,1, -1,-1,1,1, -1,-1,1,1  };
    MyObject(float s){
      for(int i=0; i<f.length; i++){
        f[i] = new MyFace(); //make a face
        for(int j=i*4; j<i*4+4; j++) //retrieve 4-ades every
          f[i].addPoint(xc[j]*s,yc[j]*s,zc[j]*s); //collect
      }
    }
    void draw3(){
      for(int i=0; i<f.length; i++)
        f[i].plot();
    }
  }
  
  


(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.