home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 May / SGI IRIX 6.5 Applications 2004 May.iso / dist / java3d.idb / usr / demos / java / j3d / programs / examples / PickTest / CubeIQA.java.z / CubeIQA.java
Encoding:
Java Source  |  2003-08-08  |  3.8 KB  |  132 lines

  1. /*
  2.  *    @(#)CubeIQA.java 1.8 02/04/01 15:03:40
  3.  *
  4.  * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  *
  10.  * - Redistributions of source code must retain the above copyright
  11.  *   notice, this list of conditions and the following disclaimer.
  12.  *
  13.  * - Redistribution in binary form must reproduce the above copyright
  14.  *   notice, this list of conditions and the following disclaimer in
  15.  *   the documentation and/or other materials provided with the
  16.  *   distribution.
  17.  *
  18.  * Neither the name of Sun Microsystems, Inc. or the names of
  19.  * contributors may be used to endorse or promote products derived
  20.  * from this software without specific prior written permission.
  21.  *
  22.  * This software is provided "AS IS," without a warranty of any
  23.  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
  24.  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
  25.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
  26.  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
  27.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  28.  * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
  29.  * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
  30.  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  31.  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
  32.  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
  33.  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  34.  *
  35.  * You acknowledge that Software is not designed,licensed or intended
  36.  * for use in the design, construction, operation or maintenance of
  37.  * any nuclear facility.
  38.  */
  39.  
  40. import javax.media.j3d.*;
  41. import javax.vecmath.*;
  42.  
  43. class CubeIQA extends IndexedQuadArray {
  44.     CubeIQA() {
  45.     super(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 24);
  46.  
  47.  
  48.     Point3f verts[] = new Point3f[8];
  49.     Color3f colors[] = new Color3f[8];
  50.     
  51.     verts[0] = new Point3f(1.0f, 1.0f,  1.0f);
  52.     verts[1] = new Point3f(-1.0f, 1.0f, 1.0f);
  53.     verts[2] = new Point3f(-1.0f,-1.0f, 1.0f);
  54.     verts[3] = new Point3f( 1.0f,-1.0f, 1.0f);
  55.     verts[4] = new Point3f( 1.0f, 1.0f,-1.0f);
  56.     verts[5] = new Point3f( -1.0f, 1.0f,-1.0f);
  57.     verts[6] = new Point3f( -1.0f,-1.0f,-1.0f);
  58.     verts[7] = new Point3f( 1.0f,-1.0f,-1.0f);
  59.     
  60.     colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
  61.     colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
  62.     colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
  63.     colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
  64.     colors[4] = new Color3f(1.0f, 0.0f, 1.0f);
  65.     colors[5] = new Color3f(0.0f, 1.0f, 1.0f);
  66.     colors[6] = new Color3f(0.0f, 1.0f, 1.0f);
  67.     colors[7] = new Color3f(0.0f, 1.0f, 1.0f);
  68.     
  69.     int pntsIndex[] = new int[24];
  70.     int clrsIndex[] = new int[24];
  71.     
  72.     pntsIndex[0] = 0;
  73.     clrsIndex[0] = 0;
  74.     pntsIndex[1] = 3;
  75.     clrsIndex[1] = 0;
  76.     pntsIndex[2] = 7;
  77.     clrsIndex[2] = 0;
  78.     pntsIndex[3] = 4;
  79.     clrsIndex[3] = 0;
  80.  
  81.     pntsIndex[4] = 1;
  82.     clrsIndex[4] = 1;
  83.     pntsIndex[5] = 5;
  84.     clrsIndex[5] = 1;
  85.     pntsIndex[6] = 6;
  86.     clrsIndex[6] = 1;
  87.     pntsIndex[7] = 2;
  88.     clrsIndex[7] = 1;
  89.  
  90.     pntsIndex[8]  = 0;
  91.     clrsIndex[8]  = 2;
  92.     pntsIndex[9]  = 4;
  93.     clrsIndex[9]  = 2;
  94.     pntsIndex[10] = 5;
  95.     clrsIndex[10] = 2;
  96.     pntsIndex[11] = 1;
  97.     clrsIndex[11] = 2;
  98.  
  99.     pntsIndex[12] = 3;
  100.     clrsIndex[12] = 3;
  101.     pntsIndex[13] = 2;
  102.     clrsIndex[13] = 3;
  103.     pntsIndex[14] = 6;
  104.     clrsIndex[14] = 3;
  105.     pntsIndex[15] = 7;
  106.     clrsIndex[15] = 3;
  107.  
  108.     pntsIndex[16] = 0;
  109.     clrsIndex[16] = 4;
  110.     pntsIndex[17] = 1;
  111.     clrsIndex[17] = 4;
  112.     pntsIndex[18] = 2;
  113.     clrsIndex[18] = 4;
  114.     pntsIndex[19] = 3;
  115.     clrsIndex[19] = 4;
  116.  
  117.     pntsIndex[20] = 7;
  118.     clrsIndex[20] = 5;
  119.     pntsIndex[21] = 6;
  120.     clrsIndex[21] = 5;
  121.     pntsIndex[22] = 5;
  122.     clrsIndex[22] = 5;
  123.     pntsIndex[23] = 4;
  124.     clrsIndex[23] = 5;
  125.  
  126.     setCoordinates(0, verts);
  127.     setCoordinateIndices(0, pntsIndex);
  128.     setColors(0, colors);
  129.     setColorIndices(0, clrsIndex);
  130.     }
  131. }
  132.