Example usage for javax.media.j3d QuadArray QuadArray

List of usage examples for javax.media.j3d QuadArray QuadArray

Introduction

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

Prototype

public QuadArray(int vertexCount, int vertexFormat) 

Source Link

Document

Constructs an empty QuadArray object using the specified parameters.

Usage

From source file:Demo3D.java

/**
 * Constructor that allows to specify the desired scale factor for the
 * colored cube./*from   w  w w  .j a  v a 2 s  .com*/
 * 
 * @param type
 *            float s_XYZ - the scale factor to adjust the edges's length of
 *            the colored cube
 */
public ColorCube(float scale_XYZ) { // 24
    cube = new QuadArray(cubeFaces.length, QuadArray.COORDINATES | QuadArray.COLOR_3);

    // Scaling of vertices
    for (int i = 0; i < cubeFaces.length; i++)
        cubeFaces[i].scale(scale_XYZ);

    cube.setCoordinates(0, cubeFaces);
    cube.setColors(0, colorsFaces);

    this.setGeometry(cube);
}

From source file:FourByFour.java

public Cube(Appearance appearance) {

    QuadArray quadArray = new QuadArray(24,
            QuadArray.COORDINATES | QuadArray.NORMALS | QuadArray.TEXTURE_COORDINATE_2);
    quadArray.setCoordinates(0, verts);/* w w w  .j av  a  2 s . co m*/
    quadArray.setNormals(0, normals);

    shape3D = new Shape3D(quadArray, appearance);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
}

From source file:FourByFour.java

public Cube(Appearance appearance, float size) {

    QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES | QuadArray.NORMALS);
    for (int i = 0; i < 72; i++)
        verts[i] *= size;// w w  w .  j  a  v a 2 s.  c o m

    quadArray.setCoordinates(0, verts);
    quadArray.setNormals(0, normals);

    shape3D = new Shape3D(quadArray, appearance);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
}

From source file:FourByFour.java

public BigCube(Appearance appearance) {

    QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES | QuadArray.NORMALS);
    quadArray.setCoordinates(0, verts);/* w  w  w.j a  v  a  2s.  c  o  m*/
    quadArray.setNormals(0, normals);

    shape3D = new Shape3D(quadArray, appearance);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
}

From source file:FourByFour.java

public BigCube(Appearance appearance, float size) {

    QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES | QuadArray.NORMALS);

    for (int i = 0; i < 72; i++)
        verts[i] *= size;//w  ww .j  av a2 s.  co  m

    quadArray.setCoordinates(0, verts);
    quadArray.setNormals(0, normals);

    shape3D = new Shape3D(quadArray, appearance);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
}

From source file:FourByFour.java

public Cylinder(float x, float z, float radius, float length, int quality, Appearance a) {

    if (quality < 3)
        quality = 3;/*from   ww w  .j  a  v  a2 s. c  o m*/

    div = (float) quality;

    verts = new float[quality * 12];
    normals = new float[quality * 12];

    double inc = 2.0 * Math.PI / (double) div;
    for (int i = 0; i < quality; i++) {
        float z1 = radius * (float) Math.sin((double) i * inc) + z;
        float x1 = radius * (float) Math.cos((double) i * inc) + x;
        float z2 = radius * (float) Math.sin((double) (i + 1) * inc) + z;
        float x2 = radius * (float) Math.cos((double) (i + 1) * inc) + x;

        verts[12 * i] = x1;
        verts[12 * i + 1] = -length / 2.f;
        verts[12 * i + 2] = z1;
        verts[12 * i + 3] = x1;
        verts[12 * i + 4] = length / 2.f;
        verts[12 * i + 5] = z1;
        verts[12 * i + 6] = x2;
        verts[12 * i + 7] = length / 2.f;
        verts[12 * i + 8] = z2;
        verts[12 * i + 9] = x2;
        verts[12 * i + 10] = -length / 2.f;
        verts[12 * i + 11] = z2;

        float nz1 = (float) Math.sin((double) i * inc);
        float nx1 = (float) Math.cos((double) i * inc);
        float nz2 = (float) Math.sin((double) (i + 1) * inc);
        float nx2 = (float) Math.cos((double) (i + 1) * inc);

        normals[12 * i] = nx1;
        normals[12 * i + 1] = 0.0f;
        normals[12 * i + 2] = nz1;
        normals[12 * i + 3] = nx1;
        normals[12 * i + 4] = 0.0f;
        normals[12 * i + 5] = nz1;
        normals[12 * i + 6] = nx2;
        normals[12 * i + 7] = 0.0f;
        normals[12 * i + 8] = nz2;
        normals[12 * i + 9] = nx2;
        normals[12 * i + 10] = 0.0f;
        normals[12 * i + 11] = nz2;
    }

    quad = new QuadArray(quality * 4, QuadArray.COORDINATES | QuadArray.NORMALS);
    quad.setCoordinates(0, verts);
    quad.setNormals(0, normals);
    shape = new Shape3D(quad, a);
}