Example usage for javax.media.j3d TriangleArray setCapability

List of usage examples for javax.media.j3d TriangleArray setCapability

Introduction

In this page you can find the example usage for javax.media.j3d TriangleArray setCapability.

Prototype

public final void setCapability(int bit) 

Source Link

Document

Sets the specified capability bit.

Usage

From source file:TickTockPicking.java

public Tetrahedron() {
    int i;//from w  ww.j  a  v  a2s.c  o m

    TriangleArray tetra = new TriangleArray(12,
            TriangleArray.COORDINATES | TriangleArray.NORMALS | TriangleArray.TEXTURE_COORDINATE_2);

    tetra.setCoordinates(0, verts);
    for (i = 0; i < 12; i++) {
        tetra.setTextureCoordinate(0, i, texCoord[i % 3]);
    }

    int face;
    Vector3f normal = new Vector3f();
    Vector3f v1 = new Vector3f();
    Vector3f v2 = new Vector3f();
    Point3f[] pts = new Point3f[3];
    for (i = 0; i < 3; i++)
        pts[i] = new Point3f();

    for (face = 0; face < 4; face++) {
        tetra.getCoordinates(face * 3, pts);
        v1.sub(pts[1], pts[0]);
        v2.sub(pts[2], pts[0]);
        normal.cross(v1, v2);
        normal.normalize();
        for (i = 0; i < 3; i++) {
            tetra.setNormal((face * 3 + i), normal);
        }
    }

    tetra.setCapability(Geometry.ALLOW_INTERSECT);

    this.setGeometry(tetra);
    this.setAppearance(new Appearance());
}