Example usage for javax.media.j3d QuadArray setTextureCoordinates

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

Introduction

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

Prototype

public void setTextureCoordinates(int texCoordSet, int index, float texCoords[], int start, int length) 

Source Link

Document

Sets the texture coordinates associated with the vertices starting at the specified index in the specified texture coordinate set for this object using data in texCoords starting at index start and ending at index start+length.

Usage

From source file:AvatarTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {//from  w  w w. j  a  va2 s .c o m
    QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);

    float[] coordArray = { -LAND_WIDTH, LAND_HEIGHT, 0, LAND_WIDTH, LAND_HEIGHT, 0, LAND_WIDTH, LAND_HEIGHT,
            LAND_LENGTH, -LAND_WIDTH, LAND_HEIGHT, LAND_LENGTH };

    float[] texArray = { 0, 0, 1, 0, 1, 1, 0, 1 };

    quadArray.setCoordinates(0, coordArray, 0, 4);

    if ((m_nFlags & TEXTURE) == TEXTURE) {
        quadArray.setTextureCoordinates(0, 0, texArray, 0, 4);
        setTexture(app, szTextureFile);
    }

    Shape3D sh = new Shape3D(quadArray, app);

    BranchGroup bg = new BranchGroup();
    bg.addChild(sh);
    return bg;
}

From source file:AvatarTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {/*from  w w  w  . j  av a 2  s  . c o m*/
    // creates a segment of road 200 x 2

    QuadArray quadArray = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);

    float[] coordArray = { -ROAD_WIDTH, ROAD_HEIGHT, 0, ROAD_WIDTH, ROAD_HEIGHT, 0, ROAD_WIDTH, ROAD_HEIGHT,
            ROAD_LENGTH, -ROAD_WIDTH, ROAD_HEIGHT, ROAD_LENGTH };

    float[] texArray = { 0, 0, 1, 0, 1, 1, 0, 1 };

    quadArray.setCoordinates(0, coordArray, 0, 4);

    if ((m_nFlags & TEXTURE) == TEXTURE) {
        quadArray.setTextureCoordinates(0, 0, texArray, 0, 4);
        setTexture(app, szTextureFile);
    }

    Shape3D sh = new Shape3D(quadArray, app);

    BranchGroup bg = new BranchGroup();
    bg.addChild(sh);
    return bg;
}

From source file:KeyNavigateTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {// ww w. jav  a2s .c  o m
    int nFlags = GeometryArray.COORDINATES | GeometryArray.NORMALS;

    if ((m_nFlags & TEXTURE) == TEXTURE)
        nFlags |= GeometryArray.TEXTURE_COORDINATE_2;

    QuadArray quadArray = new QuadArray(24, nFlags);

    quadArray.setCoordinates(0, verts, 0, 24);

    for (int n = 0; n < 24; n++)
        quadArray.setNormal(n, normals[n / 4]);

    if ((m_nFlags & TEXTURE) == TEXTURE) {
        quadArray.setTextureCoordinates(0, 0, tcoords, 0, 24);
        setTexture(app, szTextureFile);
    }

    Shape3D shape = new Shape3D(quadArray, app);

    BranchGroup bg = new BranchGroup();
    bg.addChild(shape);
    return bg;
}

From source file:KeyNavigateTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {//from  w w w .j  a  va 2s. c  o m
    int nFlags = GeometryArray.COORDINATES | GeometryArray.NORMALS;

    if ((m_nFlags & TEXTURE) == TEXTURE)
        nFlags |= GeometryArray.TEXTURE_COORDINATE_2;

    QuadArray quadArray = new QuadArray(4, nFlags);

    float[] coordArray = { -WIDTH, HEIGHT, LENGTH, WIDTH, HEIGHT, LENGTH, WIDTH, HEIGHT, -LENGTH, -WIDTH,
            HEIGHT, -LENGTH };

    quadArray.setCoordinates(0, coordArray, 0, coordArray.length / 3);

    for (int n = 0; n < coordArray.length / 3; n++)
        quadArray.setNormal(n, new Vector3f(0, 1, 0));

    if ((m_nFlags & TEXTURE) == TEXTURE) {
        float[] texArray = { 0, 0, 1, 0, 1, 1, 0, 1 };

        quadArray.setTextureCoordinates(0, 0, texArray, 0, coordArray.length / 3);
        setTexture(app, szTextureFile);
    }

    BranchGroup bg = new BranchGroup();
    Shape3D shape = new Shape3D(quadArray, app);
    bg.addChild(shape);

    return bg;
}