Example usage for javax.media.j3d GeometryArray COORDINATES

List of usage examples for javax.media.j3d GeometryArray COORDINATES

Introduction

In this page you can find the example usage for javax.media.j3d GeometryArray COORDINATES.

Prototype

int COORDINATES

To view the source code for javax.media.j3d GeometryArray COORDINATES.

Click Source Link

Document

Specifies that this GeometryArray contains an array of coordinates.

Usage

From source file:AppearanceExplorer.java

Shape3D createTriangleFanArray() {

    int[] stripLengths = new int[1];
    stripLengths[0] = 5;/*w  ww .j  a va2  s .c  o  m*/
    Point3f pnt[] = new Point3f[5];
    pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f);
    pnt[1] = new Point3f(1.0f, -1.0f, 0.0f);
    pnt[2] = new Point3f(1.0f, 0.0f, 0.0f);
    pnt[3] = new Point3f(0.0f, 1.0f, 0.0f);
    pnt[4] = new Point3f(-1.0f, 1.0f, 0.0f);

    TriangleFanArray tfa = new TriangleFanArray(5, GeometryArray.COORDINATES, stripLengths);
    tfa.setCoordinates(0, pnt);

    return new Shape3D(tfa, appearance);
}

From source file:PickTest.java

TetrahedronLA() {
    super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    Point3f pnts[] = new Point3f[12];
    Color3f clrs[] = new Color3f[12];

    pnts[0] = verts[0];//w w  w .  ja v a2  s .c  o m
    clrs[0] = colors[0];
    pnts[1] = verts[1];
    clrs[1] = colors[1];

    pnts[2] = verts[1];
    clrs[2] = colors[1];
    pnts[3] = verts[2];
    clrs[3] = colors[2];

    pnts[4] = verts[2];
    clrs[4] = colors[2];
    pnts[5] = verts[0];
    clrs[5] = colors[0];

    pnts[6] = verts[1];
    clrs[6] = colors[1];
    pnts[7] = verts[3];
    clrs[7] = colors[3];

    pnts[8] = verts[2];
    clrs[8] = colors[2];
    pnts[9] = verts[3];
    clrs[9] = colors[3];

    pnts[10] = verts[0];
    clrs[10] = colors[0];
    pnts[11] = verts[3];
    clrs[11] = colors[3];

    setCoordinates(0, pnts);
    setColors(0, clrs);
}

From source file:AppearanceExplorer.java

Shape3D createTexTris() {

    Point3f pnt[] = new Point3f[9];
    pnt[0] = new Point3f(-0.8f, -0.8f, 0.0f);
    pnt[1] = new Point3f(-0.5f, -0.7f, 0.0f);
    pnt[2] = new Point3f(-0.7f, 0.7f, 0.0f);

    pnt[3] = new Point3f(-0.4f, 0.7f, 0.0f);
    pnt[4] = new Point3f(0.0f, -0.7f, 0.0f);
    pnt[5] = new Point3f(0.4f, 0.7f, 0.0f);

    pnt[6] = new Point3f(0.5f, 0.7f, 0.0f);
    pnt[7] = new Point3f(0.5f, -0.7f, 0.0f);
    pnt[8] = new Point3f(0.9f, 0.0f, 0.0f);

    TexCoord2f texCoord[] = new TexCoord2f[9];
    texCoord[0] = new TexCoord2f(0.05f, 0.90f);
    texCoord[1] = new TexCoord2f(0.25f, 0.10f);
    texCoord[2] = new TexCoord2f(1.00f, 0.60f);

    texCoord[3] = texCoord[0];/* www  .  jav  a2s .  com*/
    texCoord[4] = texCoord[1];
    texCoord[5] = texCoord[2];

    texCoord[6] = texCoord[0];
    texCoord[7] = texCoord[1];
    texCoord[8] = texCoord[2];

    TriangleArray ta = new TriangleArray(9, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
    ta.setCoordinates(0, pnt);
    ta.setTextureCoordinates(0, 0, texCoord);

    return new Shape3D(ta, appearance);
}

From source file:PickTest.java

TetrahedronITA() {
    super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    int pntsIndex[] = new int[12];
    int clrsIndex[] = new int[12];

    pntsIndex[0] = 2;/*from   w  w  w . ja  va 2s .c o  m*/
    clrsIndex[0] = 0;
    pntsIndex[1] = 1;
    clrsIndex[1] = 0;
    pntsIndex[2] = 0;
    clrsIndex[2] = 0;

    pntsIndex[3] = 3;
    clrsIndex[3] = 1;
    pntsIndex[4] = 2;
    clrsIndex[4] = 1;
    pntsIndex[5] = 0;
    clrsIndex[5] = 1;

    pntsIndex[6] = 1;
    clrsIndex[6] = 2;
    pntsIndex[7] = 2;
    clrsIndex[7] = 2;
    pntsIndex[8] = 3;
    clrsIndex[8] = 2;

    pntsIndex[9] = 1;
    clrsIndex[9] = 3;
    pntsIndex[10] = 3;
    clrsIndex[10] = 3;
    pntsIndex[11] = 0;
    clrsIndex[11] = 3;

    setCoordinates(0, verts);
    setCoordinateIndices(0, pntsIndex);
    setColors(0, colors);
    setColorIndices(0, clrsIndex);
}

From source file:AppearanceExplorer.java

Shape3D createTexSquare() {

    // color cube
    Point3f pnt[] = new Point3f[4];
    pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f);
    pnt[1] = new Point3f(1.0f, -1.0f, 0.0f);
    pnt[2] = new Point3f(1.0f, 1.0f, 0.0f);
    pnt[3] = new Point3f(-1.0f, 1.0f, 0.0f);
    TexCoord2f texCoord[] = new TexCoord2f[4];
    texCoord[0] = new TexCoord2f(0.0f, 0.0f);
    texCoord[1] = new TexCoord2f(1.0f, 0.0f);
    texCoord[2] = new TexCoord2f(1.0f, 1.0f);
    texCoord[3] = new TexCoord2f(0.0f, 1.0f);

    QuadArray qa = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
    qa.setCoordinates(0, pnt);/*w  w  w.ja  v  a2 s .  com*/
    qa.setTextureCoordinates(0, 0, texCoord);

    return new Shape3D(qa, appearance);
}

From source file:AppearanceExplorer.java

Shape3D createLargeTexSquare() {

    // color cube
    Point3f pnt[] = new Point3f[4];
    pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f);
    pnt[1] = new Point3f(1.0f, -1.0f, 0.0f);
    pnt[2] = new Point3f(1.0f, 1.0f, 0.0f);
    pnt[3] = new Point3f(-1.0f, 1.0f, 0.0f);
    TexCoord2f texCoord[] = new TexCoord2f[4];
    texCoord[0] = new TexCoord2f(-1.0f, -1.0f);
    texCoord[1] = new TexCoord2f(2.0f, -1.0f);
    texCoord[2] = new TexCoord2f(2.0f, 2.0f);
    texCoord[3] = new TexCoord2f(-1.0f, 2.0f);

    QuadArray qa = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
    qa.setCoordinates(0, pnt);/*from ww  w.  j  ava 2s.c om*/
    qa.setTextureCoordinates(0, 0, texCoord);

    return new Shape3D(qa, appearance);
}

From source file:PickTest.java

TetrahedronIPA() {
    super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 4);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    int pntsIndex[] = new int[4];
    int clrsIndex[] = new int[4];

    pntsIndex[0] = clrsIndex[0] = 0;/*from  www.j  a  va  2  s .co  m*/
    pntsIndex[1] = clrsIndex[1] = 1;
    pntsIndex[2] = clrsIndex[2] = 2;
    pntsIndex[3] = clrsIndex[3] = 3;

    setCoordinates(0, verts);
    setCoordinateIndices(0, pntsIndex);
    setColors(0, colors);
    setColorIndices(0, clrsIndex);
}

From source file:AppearanceExplorer.java

Shape3D createColorCube() {

    // color cube
    int[] indices = { 0, 3, 4, 2, // left face x = -1
            0, 1, 5, 3, // bottom face y = -1
            0, 2, 6, 1, // back face z = -1
            7, 5, 1, 6, // right face x = 1
            7, 6, 2, 4, // top face y = 1
            7, 4, 3, 5 // front face z = 1
    };//w  w  w.jav  a  2  s .  c om

    Point3f pts[] = new Point3f[8];
    pts[0] = new Point3f(-1.0f, -1.0f, -1.0f);
    pts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    pts[2] = new Point3f(-1.0f, 1.0f, -1.0f);
    pts[3] = new Point3f(-1.0f, -1.0f, 1.0f);
    pts[4] = new Point3f(-1.0f, 1.0f, 1.0f);
    pts[5] = new Point3f(1.0f, -1.0f, 1.0f);
    pts[6] = new Point3f(1.0f, 1.0f, -1.0f);
    pts[7] = new Point3f(1.0f, 1.0f, 1.0f);
    Color3f colr[] = new Color3f[8];
    colr[0] = black;
    colr[1] = red;
    colr[2] = green;
    colr[3] = blue;
    colr[4] = cyan;
    colr[5] = magenta;
    colr[6] = yellow;
    colr[7] = white;
    // The normals point out from 0,0,0, through the verticies of the
    // cube. These can be calculated by copying the coordinates to
    // a Vector3f and normalizing.
    Vector3f norm[] = new Vector3f[8];
    for (int i = 0; i < 8; i++) {
        norm[i] = new Vector3f(pts[i]);
        norm[i].normalize();
    }

    IndexedQuadArray iqa = new IndexedQuadArray(8,
            GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS, 24);
    iqa.setCoordinates(0, pts);
    iqa.setColors(0, colr);
    iqa.setNormals(0, norm);
    iqa.setCoordinateIndices(0, indices);
    iqa.setColorIndices(0, indices);
    iqa.setNormalIndices(0, indices);
    return new Shape3D(iqa, appearance);
}

From source file:PickTest.java

IcosahedronTSA() {
    super(32, GeometryArray.COORDINATES | GeometryArray.COLOR_3, sVertCnt);

    Point3f verts[] = new Point3f[12];
    Color3f colors[] = new Color3f[12];

    verts[0] = new Point3f(0.0f, 1.4f, 0.8652f);
    verts[1] = new Point3f(0.0f, 1.4f, -0.8652f);
    verts[2] = new Point3f(1.4f, 0.8652f, 0.0f);
    verts[3] = new Point3f(1.4f, -0.8652f, 0.0f);
    verts[4] = new Point3f(0.0f, -1.4f, -0.8652f);
    verts[5] = new Point3f(0.0f, -1.4f, 0.8652f);
    verts[6] = new Point3f(0.8652f, 0.0f, 1.4f);
    verts[7] = new Point3f(-0.8652f, 0.0f, 1.4f);
    verts[8] = new Point3f(0.8652f, 0.0f, -1.4f);
    verts[9] = new Point3f(-0.8652f, 0.0f, -1.4f);
    verts[10] = new Point3f(-1.4f, 0.8652f, 0.0f);
    verts[11] = new Point3f(-1.4f, -0.8652f, 0.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
    colors[4] = new Color3f(0.0f, 1.0f, 1.0f);
    colors[5] = new Color3f(1.0f, 0.0f, 1.0f);
    colors[6] = new Color3f(0.0f, 0.5f, 0.0f);
    colors[7] = new Color3f(0.0f, 0.0f, 0.5f);
    colors[8] = new Color3f(0.5f, 0.5f, 0.0f);
    colors[9] = new Color3f(0.0f, 0.5f, 0.5f);
    colors[10] = new Color3f(0.5f, 0.0f, 0.5f);
    colors[11] = new Color3f(0.5f, 0.5f, 0.5f);

    Point3f pnts[] = new Point3f[32];
    Color3f clrs[] = new Color3f[32];

    pnts[0] = verts[4];//from  w  ww.  j a  v a2  s.c om
    clrs[0] = colors[4];
    pnts[1] = verts[5];
    clrs[1] = colors[5];
    pnts[2] = verts[11];
    clrs[2] = colors[11];

    pnts[3] = verts[11];
    clrs[3] = colors[11];
    pnts[4] = verts[5];
    clrs[4] = colors[5];
    pnts[5] = verts[7];
    clrs[5] = colors[7];

    pnts[6] = verts[6];
    clrs[6] = colors[6];

    pnts[7] = verts[0];
    clrs[7] = colors[0];

    pnts[8] = verts[2];
    clrs[8] = colors[2];

    pnts[9] = verts[1];
    clrs[9] = colors[1];

    pnts[10] = verts[8];
    clrs[10] = colors[8];

    pnts[11] = verts[9];
    clrs[11] = colors[9];

    pnts[12] = verts[4];
    clrs[12] = colors[4];

    pnts[13] = verts[11];
    clrs[13] = colors[11];

    pnts[14] = verts[2];
    clrs[14] = colors[2];
    pnts[15] = verts[6];
    clrs[15] = colors[6];
    pnts[16] = verts[3];
    clrs[16] = colors[3];

    pnts[17] = verts[5];
    clrs[17] = colors[5];

    pnts[18] = verts[4];
    clrs[18] = colors[4];

    pnts[19] = verts[4];
    clrs[19] = colors[4];
    pnts[20] = verts[8];
    clrs[20] = colors[8];
    pnts[21] = verts[3];
    clrs[21] = colors[3];

    pnts[22] = verts[2];
    clrs[22] = colors[2];

    pnts[23] = verts[0];
    clrs[23] = colors[0];
    pnts[24] = verts[1];
    clrs[24] = colors[1];
    pnts[25] = verts[10];
    clrs[25] = colors[10];

    pnts[26] = verts[9];
    clrs[26] = colors[9];

    pnts[27] = verts[11];
    clrs[27] = colors[11];

    pnts[28] = verts[0];
    clrs[28] = colors[0];
    pnts[29] = verts[10];
    clrs[29] = colors[10];
    pnts[30] = verts[7];
    clrs[30] = colors[7];

    pnts[31] = verts[11];
    clrs[31] = colors[11];

    setCoordinates(0, pnts);
    setColors(0, clrs);
}

From source file:ExSpotLight.java

public AnnotationLine(float x, float y, float z, float x2, float y2, float z2) {
    float[] coord = new float[3];
    float[] texcoord = new float[2];

    // Build a shape
    shape = new Shape3D();
    shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);

    // Create geometry for a 2-vertex straight line
    line = new LineArray(2, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
    line.setCapability(GeometryArray.ALLOW_COLOR_WRITE);

    // Starting point
    coord[0] = x;/*  w w w .java2 s. c o  m*/
    coord[1] = y;
    coord[2] = z;
    texcoord[0] = 0.0f;
    texcoord[1] = 0.0f;
    line.setCoordinate(0, coord);
    line.setTextureCoordinate(0, texcoord);

    // Ending point
    coord[0] = x2;
    coord[1] = y2;
    coord[2] = z2;
    texcoord[0] = 1.0f;
    texcoord[1] = 0.0f;
    line.setCoordinate(1, coord);
    line.setTextureCoordinate(1, texcoord);

    shape.setGeometry(line);

    // Create an appearance
    mainAppearance = new Appearance();
    mainAppearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    mainAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);

    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(lineWidth);
    mainAppearance.setLineAttributes(lineAttributes);

    coloringAttributes = new ColoringAttributes();
    coloringAttributes.setColor(lineColor);
    coloringAttributes.setShadeModel(ColoringAttributes.SHADE_FLAT);
    mainAppearance.setColoringAttributes(coloringAttributes);

    addChild(shape);
}