List of usage examples for javax.media.j3d IndexedTriangleArray IndexedTriangleArray
public IndexedTriangleArray(int vertexCount, int vertexFormat, int indexCount)
From source file:KeyNavigatorApp.java
Shape3D createPyramid() { IndexedTriangleArray pyGeom = new IndexedTriangleArray(5, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12);/*w ww .j a v a 2s . co m*/ pyGeom.setCoordinate(0, new Point3f(0.0f, 0.7f, 0.0f)); pyGeom.setCoordinate(1, new Point3f(-0.4f, 0.0f, -0.4f)); pyGeom.setCoordinate(2, new Point3f(-0.4f, 0.0f, 0.4f)); pyGeom.setCoordinate(3, new Point3f(0.4f, 0.0f, 0.4f)); pyGeom.setCoordinate(4, new Point3f(0.4f, 0.0f, -0.4f)); pyGeom.setCoordinateIndex(0, 0); pyGeom.setCoordinateIndex(1, 1); pyGeom.setCoordinateIndex(2, 2); pyGeom.setCoordinateIndex(3, 0); pyGeom.setCoordinateIndex(4, 2); pyGeom.setCoordinateIndex(5, 3); pyGeom.setCoordinateIndex(6, 0); pyGeom.setCoordinateIndex(7, 3); pyGeom.setCoordinateIndex(8, 4); pyGeom.setCoordinateIndex(9, 0); pyGeom.setCoordinateIndex(10, 4); pyGeom.setCoordinateIndex(11, 1); Color3f c = new Color3f(0.6f, 0.5f, 0.55f); pyGeom.setColor(0, c); pyGeom.setColor(1, c); pyGeom.setColor(2, c); pyGeom.setColor(3, c); pyGeom.setColor(4, c); Shape3D pyramid = new Shape3D(pyGeom); return pyramid; }
From source file:GeometryByReferenceNIOBuffer.java
public GeometryArray createGeometry(int type) { GeometryArray tetra = null;//from w ww.ja va 2 s. co m if (type == 1) { tetra = new TriangleArray(12, TriangleArray.COORDINATES | TriangleArray.COLOR_3 | TriangleArray.BY_REFERENCE | TriangleArray.USE_NIO_BUFFER); tetra.setCoordRefBuffer(floatBufferCoord); tetra.setColorRefBuffer(floatBufferColor); } else if (type == 2) { tetra = new TriangleStripArray( 12, TriangleStripArray.COORDINATES | TriangleStripArray.COLOR_3 | TriangleStripArray.BY_REFERENCE | TriangleStripArray.USE_NIO_BUFFER, stripVertexCounts); tetra.setCoordRefBuffer(floatBufferCoord); tetra.setColorRefBuffer(floatBufferColor); } else if (type == 3) { // Indexed Geometry tetra = new IndexedTriangleArray(4, IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3 | IndexedTriangleArray.BY_REFERENCE | IndexedTriangleArray.USE_NIO_BUFFER, //IndexedTriangleStripArray.USE_COORD_INDEX_ONLY, 12); tetra.setCoordRefBuffer(indexedFloatBufferCoord); tetra.setColorRefBuffer(indexedFloatBufferColor); ((IndexedTriangleArray) tetra).setCoordinateIndices(0, indices); ((IndexedTriangleArray) tetra).setColorIndices(0, indices); } else if (type == 4) { // Indexed strip geometry tetra = new IndexedTriangleStripArray(4, IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.COLOR_3 | IndexedTriangleStripArray.BY_REFERENCE | IndexedTriangleStripArray.USE_NIO_BUFFER | IndexedTriangleStripArray.USE_COORD_INDEX_ONLY, 12, stripVertexCounts); tetra.setCoordRefBuffer(indexedFloatBufferCoord); tetra.setColorRefBuffer(indexedFloatBufferColor); ((IndexedTriangleStripArray) tetra).setCoordinateIndices(0, indices); ((IndexedTriangleStripArray) tetra).setColorIndices(0, indices); } if (tetra != null) tetra.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE); return tetra; }
From source file:GeometryByReferenceTest.java
public GeometryArray createGeometry(int type) { GeometryArray tetra = null;//from www.ja v a 2 s . c o m if (type == 1) { tetra = new TriangleArray(12, TriangleArray.COORDINATES | TriangleArray.COLOR_3 | TriangleArray.BY_REFERENCE); tetra.setCoordRefFloat(floatVerts); tetra.setColorRefFloat(floatClrs); } else if (type == 2) { tetra = new TriangleStripArray(12, TriangleStripArray.COORDINATES | TriangleStripArray.COLOR_3 | TriangleStripArray.BY_REFERENCE, stripVertexCounts); tetra.setCoordRefFloat(floatVerts); tetra.setColorRefFloat(floatClrs); } else if (type == 3) { // Indexed Geometry tetra = new IndexedTriangleArray(4, IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3 | IndexedTriangleArray.BY_REFERENCE, 12); tetra.setCoordRefFloat(indexedFloatVerts); tetra.setColorRefFloat(indexedFloatClrs); ((IndexedTriangleArray) tetra).setCoordinateIndices(0, indices); ((IndexedTriangleArray) tetra).setColorIndices(0, indices); } else if (type == 4) { // Indexed strip geometry tetra = new IndexedTriangleStripArray(4, IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.COLOR_3 | IndexedTriangleStripArray.BY_REFERENCE, 12, stripVertexCounts); tetra.setCoordRefFloat(indexedFloatVerts); tetra.setColorRefFloat(indexedFloatClrs); ((IndexedTriangleStripArray) tetra).setCoordinateIndices(0, indices); ((IndexedTriangleStripArray) tetra).setColorIndices(0, indices); } if (tetra != null) tetra.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE); return tetra; }