Advertisement
Luninariel

289 - Cube

Apr 8th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. //
  2. //  Cube.java
  3. //  Easel
  4. //
  5. //  Created by Philip Rhodes on 7/26/05.
  6. //  Copyright 2005 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. /** The Cube class represents a cube. */
  10. public class Cube extends Shape {
  11.  
  12.    /** Construct a cube that is initially sitting on the xy
  13.     *  plane with one vertex at 0,0,0 and the other at 1,1,1 in object space.
  14.     *  Its dimensions are then scaled by the size parameter given to the
  15.     *  constructor.
  16.     */
  17.    public Cube(float size){
  18.    
  19.       super(8, 12);
  20.       setScales(size, size, size);
  21.      
  22.       int vi = 0;
  23.       //int ti = 0;
  24.       for(int x=0;x<=1;x++)
  25.       {
  26.           for(int y=0;y<=1;y++)
  27.           {
  28.               //float temp[] = new float[3];
  29.               for(int z=0;z<=1;z++)
  30.               {
  31.                   //temp[0] = (float)x;
  32.                   //temp[1] = (float)y;
  33.                   //temp[2] = (float)z;
  34.                   this.setVertex(vi++,(float)x,(float)y,(float)z);
  35.               }
  36.           }
  37.       }
  38.       /*
  39.       for(j=0;j<vertices.length;j++)
  40.       {
  41.           if(j%3==0 || j)
  42.           {
  43.               //this would be the first vertex
  44.           }
  45.          
  46.       }
  47.       */
  48.       setTriangle(0,0,4,6);
  49.       setTriangle(1,0,2,6);
  50.       setTriangle(2,0,1,3);
  51.       setTriangle(3,0,2,3);
  52.       setTriangle(4,0,4,5);
  53.       setTriangle(5,0,1,5);
  54.  
  55.       setTriangle(6,7,6,4);
  56.       setTriangle(7,7,5,4);
  57.       setTriangle(8,7,6,2);
  58.       setTriangle(9,7,3,2);
  59.       setTriangle(10,7,5,1);
  60.       setTriangle(11,7,3,1);
  61.    }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement