List of usage examples for javax.media.j3d GeometryArray setCoordRefBuffer
public void setCoordRefBuffer(J3DBuffer coords)
From source file:GeometryByReferenceNIOBuffer.java
public GeometryArray createGeometry(int type) { GeometryArray tetra = null; 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);//from www .j a v a 2 s. com 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:GeometryByReferenceNIOBuffer.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); GeometryArray geo; boolean setColor = false, setVertex = false; if (target == geomType) { geo = geoArrays[geomType.getSelectedIndex()]; // Set everything to null, and set it later .. geo.setColorRefBuffer(null);//from ww w . ja v a 2 s . c o m geo.setCoordRefBuffer(null); shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); setColor = true; setVertex = true; } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else { transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == updates) { updateIndex = updates.getSelectedIndex(); if (updateIndex == 1) { System.out.println("Doing coordinate update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } else if (updateIndex == 2) { System.out.println("Doing color update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } } if (setVertex) { geo = (GeometryArray) shape.getGeometry(); if (geo instanceof IndexedGeometryArray) geo.setCoordRefBuffer(indexedFloatBufferCoord); else geo.setCoordRefBuffer(floatBufferCoord); } if (setColor) { geo = (GeometryArray) shape.getGeometry(); if (geo instanceof IndexedGeometryArray) geo.setColorRefBuffer(indexedFloatBufferColor); else geo.setColorRefBuffer(floatBufferColor); } }