| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 
 |  
package org.alwin;
import java.net.URL;
 
import javax.media.j3d.*;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
 
import com.sun.j3d.utils.geometry.Cylinder;
import com.sun.j3d.utils.image.TextureLoader;
 
public class Plancher extends Shape3D {
  private BranchGroup bg = new BranchGroup();
 
  public BranchGroup getBg() {
    return bg;
  }
 
  public Plancher() {
    QuadArray plane = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3 );
 
    float x = 10.0f;
    float y = 0.0f;
    float z = 10.0f;
    Point3f[] pointList = new Point3f[4];
    pointList[0] = new Point3f(-x, y, z);
    pointList[1] = new Point3f( x, y, z);
    pointList[2] = new Point3f( x, y,-z);
    pointList[3] = new Point3f(-x, y,-z);
    plane.setCoordinates(0,pointList);
 
    Color3f[] cols = new Color3f[4];
    Color3f col = new Color3f(0.5f,0.2f,0.2f);
    for( int i = 0; i < cols.length; i++)
      cols[i] = col;
    plane.setColors(0,cols);
 
    setGeometry(plane);
 
    createAppearance();
    bg.addChild(this);
  }
  private void createAppearance()
  {
    Appearance app = new Appearance();
    Material mat = new Material(white, red, white, white, 25f);
    app.setMaterial(mat);
    mat.setLightingEnable(true);
 
 
    PolygonAttributes pa = new PolygonAttributes();
    pa.setCullFace(PolygonAttributes.CULL_NONE);
    pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
      // On force à une visibilité double face
    app.setPolygonAttributes(pa);
 
    setAppearance(app);
  }
 
} | 
Partager