⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colouredtile.java

📁 java3D game engine design of the source [three-dimensionalvirtualrealitynetworkprogram] - "virtual
💻 JAVA
字号:

// ColouredTile.java
// Andrew Davison, March 2002, dandrew@ratree.psu.ac.th

// ColouredTile creates a coloured quad array of 4 vertices.

import javax.media.j3d.*;
import javax.vecmath.*;


public class ColouredTile extends Shape3D 
{
  private static final int NUM_VERTS = 4;
  private QuadArray plane;


  public ColouredTile(Point3f p1, Point3f p2, Point3f p3, Point3f p4,
							Color3f col) 
  {
    plane = new QuadArray(NUM_VERTS, 
			GeometryArray.COORDINATES | GeometryArray.COLOR_3 );
    createGeometry(p1, p2, p3, p4, col);
    createAppearance();
  }    


  private void createGeometry(Point3f p1, Point3f p2, Point3f p3, 
								Point3f p4, Color3f col)
  { // counter-clockwise point specification
    plane.setCoordinate(0, p1);
    plane.setCoordinate(1, p2);
    plane.setCoordinate(2, p3);
    plane.setCoordinate(3, p4);

    Color3f cols[] = new Color3f[NUM_VERTS];
    for (int i=0; i < NUM_VERTS; i++)
       cols[i] = col;

    plane.setColors(0, cols);

    setGeometry(plane);
  }  // end of createGeometry()


  private void createAppearance()
  {
    Appearance app = new Appearance();

    PolygonAttributes pa = new PolygonAttributes();
    pa.setCullFace(PolygonAttributes.CULL_NONE);   
      // so can see the ColouredTile from both sides
    app.setPolygonAttributes(pa);

    setAppearance(app);
  }  // end of createAppearance()


} // end of ColouredTile class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -