private void setIndexData() { final IndexBufferData<?> indices = _meshData.getIndices(); indices.getBuffer().rewind(); indices.put(4).put(0).put(2); indices.put(4).put(2).put(1); indices.put(4).put(1).put(3); indices.put(4).put(3).put(0); indices.put(5).put(2).put(0); indices.put(5).put(1).put(2); indices.put(5).put(3).put(1); indices.put(5).put(0).put(3); }
private void setIndexData() { final IndexBufferData<?> indices = _meshData.getIndices(); indices.getBuffer().rewind(); indices.put(4).put(0).put(2); indices.put(4).put(2).put(1); indices.put(4).put(1).put(3); indices.put(4).put(3).put(0); indices.put(5).put(2).put(0); indices.put(5).put(1).put(2); indices.put(5).put(3).put(1); indices.put(5).put(0).put(3); }
private void setIndexData() { final IndexBufferData<?> indices = _meshData.getIndices(); indices.getBuffer().rewind(); indices.put(9).put(5).put(10).put(6); indices.put(4).put(0).put(5).put(1).put(6).put(2); indices.put(2).put(3).put(6).put(7).put(10).put(11); indices.put(11).put(15).put(10).put(14).put(9).put(13); indices.put(13).put(12).put(9).put(8).put(5).put(4); _meshData.setIndexLengths(new int[] { 4, 6, 6, 6, 6 }); _meshData.setIndexMode(IndexMode.TriangleStrip); _meshData.markIndicesDirty(); }
/** * <code>setIndexData</code> sets the indices into the list of vertices, defining all triangles that constitute the * pyramid. */ private void setIndexData() { final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, 16 - 1); indices.put(3).put(2).put(1); indices.put(3).put(1).put(0); indices.put(6).put(5).put(4); indices.put(9).put(8).put(7); indices.put(12).put(11).put(10); indices.put(15).put(14).put(13); indices.getBuffer().rewind(); _meshData.setIndices(indices); }
/** * <code>setIndexData</code> sets the indices into the list of vertices, defining all triangles that constitute the * pyramid. */ private void setIndexData() { final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(18, 16 - 1); indices.put(3).put(2).put(1); indices.put(3).put(1).put(0); indices.put(6).put(5).put(4); indices.put(9).put(8).put(7); indices.put(12).put(11).put(10); indices.put(15).put(14).put(13); indices.getBuffer().rewind(); _meshData.setIndices(indices); }
public static IndexBufferData<?> convertQuadIndicesToTriangles(final int[] quadIndices, final int vertexCount) { final int qIndices = quadIndices.length; if (qIndices < 4 || (qIndices % 4) != 0) { throw new IllegalArgumentException("Quad data should have 4*N indices where N=[1,R]"); } final int quads = qIndices / 4; final int tris = 2 * quads; final int tVerts = tris * 3; final IndexBufferData<?> rVal = BufferUtils.createIndexBufferData(tVerts, vertexCount - 1); // write our new data by walking through our quads for (int q = 0; q < quads; q++) { final int offsetSrc = q * 4; // 0 1 2 rVal.put(quadIndices[offsetSrc + 0]); rVal.put(quadIndices[offsetSrc + 1]); rVal.put(quadIndices[offsetSrc + 2]); // 2 1 3 rVal.put(quadIndices[offsetSrc + 2]); rVal.put(quadIndices[offsetSrc + 1]); rVal.put(quadIndices[offsetSrc + 3]); } return rVal; } }
private void setIndexData() { // generate connectivity for (int radialCount0 = _radialSamples - 1, radialCount1 = 0; radialCount1 < _radialSamples; radialCount0 = radialCount1++) { final int i00 = 2 * radialCount0; final int i01 = 2 * radialCount1; final int i10 = i00 + 1; final int i11 = i01 + 1; _meshData.getIndices().put(i00); _meshData.getIndices().put(i10); _meshData.getIndices().put(i11); _meshData.getIndices().put(i00); _meshData.getIndices().put(i11); _meshData.getIndices().put(i01); } }
private void setIndexData(final int radialless, final int shellLess) { // generate connectivity for (int radialCount0 = radialless, radialCount1 = 0; radialCount1 < _radialSamples; radialCount0 = radialCount1++) { _meshData.getIndices().put(0); _meshData.getIndices().put(1 + shellLess * radialCount0); _meshData.getIndices().put(1 + shellLess * radialCount1); for (int iS = 1; iS < shellLess; iS++) { final int i00 = iS + shellLess * radialCount0; final int i01 = iS + shellLess * radialCount1; final int i10 = i00 + 1; final int i11 = i01 + 1; _meshData.getIndices().put(i00); _meshData.getIndices().put(i10); _meshData.getIndices().put(i11); _meshData.getIndices().put(i00); _meshData.getIndices().put(i11); _meshData.getIndices().put(i01); } } }
/** * Sets the correct indices array for the box. */ private void setIndexData() { if (_meshData.getIndices() == null) { _meshData.setIndexBuffer(BufferUtils.createByteBuffer(36)); for (int i = 0; i < 6; i++) { _meshData.getIndices().put(i * 4 + 0); _meshData.getIndices().put(i * 4 + 1); _meshData.getIndices().put(i * 4 + 3); _meshData.getIndices().put(i * 4 + 1); _meshData.getIndices().put(i * 4 + 2); _meshData.getIndices().put(i * 4 + 3); } } }
/** * Sets the correct indices array for the box. */ private void setIndexData() { if (_meshData.getIndices() == null) { _meshData.setIndexBuffer(BufferUtils.createByteBuffer(36)); for (int i = 0; i < 6; i++) { _meshData.getIndices().put(i * 4 + 0); _meshData.getIndices().put(i * 4 + 1); _meshData.getIndices().put(i * 4 + 3); _meshData.getIndices().put(i * 4 + 1); _meshData.getIndices().put(i * 4 + 2); _meshData.getIndices().put(i * 4 + 3); } } }
private void setIndexData() { final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(6 * _meshData.getVertexCount(), _meshData.getVertexCount() - 1); for (int i = _radialSamples; i < _meshData.getVertexCount() + (_radialSamples); i++) { indices.put(i); indices.put(i - _radialSamples); indices.put(i + 1); indices.put(i + 1); indices.put(i - _radialSamples); indices.put(i - _radialSamples + 1); } for (int i = 0, len = indices.getBufferCapacity(); i < len; i++) { int ind = indices.get(i); if (ind < 0) { ind += _meshData.getVertexCount(); indices.put(i, ind); } if (ind >= _meshData.getVertexCount()) { ind -= _meshData.getVertexCount(); indices.put(i, ind); } } indices.getBuffer().rewind(); _meshData.setIndices(indices); }
private void setIndexData() { final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(6 * _meshData.getVertexCount(), _meshData.getVertexCount() - 1); for (int i = _radialSamples; i < _meshData.getVertexCount() + (_radialSamples); i++) { indices.put(i); indices.put(i - _radialSamples); indices.put(i + 1); indices.put(i + 1); indices.put(i - _radialSamples); indices.put(i - _radialSamples + 1); } for (int i = 0, len = indices.getBufferCapacity(); i < len; i++) { int ind = indices.get(i); if (ind < 0) { ind += _meshData.getVertexCount(); indices.put(i, ind); } if (ind >= _meshData.getVertexCount()) { ind -= _meshData.getVertexCount(); indices.put(i, ind); } } indices.getBuffer().rewind(); _meshData.setIndices(indices); }
private void setIndexData() { if (_meshData.getIndices() == null) { final IndexBufferData<?> buff = BufferUtils.createIndexBufferData(180, 48 - 1); final int[] data = new int[] { 0, 4, 1, 1, 4, 5, 1, 5, 3, 3, 5, 7, 3, 7, 2, 2, 7, 6, 2, 6, 0, 0, 6, 4, 4, 6, 5, 5, 6, 7 }; for (int i = 0; i < 6; i++) { for (int n = 0; n < 30; n++) { buff.put(30 * i + n, 8 * i + data[n]); } } _meshData.setIndices(buff); } }
private void setIndexData() { if (_meshData.getIndices() == null) { final IndexBufferData<?> buff = BufferUtils.createIndexBufferData(180, 48 - 1); final int[] data = new int[] { 0, 4, 1, 1, 4, 5, 1, 5, 3, 3, 5, 7, 3, 7, 2, 2, 7, 6, 2, 6, 0, 0, 6, 4, 4, 6, 5, 5, 6, 7 }; for (int i = 0; i < 6; i++) { for (int n = 0; n < 30; n++) { buff.put(30 * i + n, 8 * i + data[n]); } } _meshData.setIndices(buff); } }
/** * Create a new IndexBufferData large enough to fit the contents of the given array. The specific implementation * will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a * ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used. * * @param contents * an array of index values to store in your newly created IndexBufferData. * @param maxValue * the largest value you will need to store in your buffer. Often this is equal to * ("size of vertex buffer" - 1). * @return the new IndexBufferData */ public static IndexBufferData<?> createIndexBufferData(final int[] contents, final int maxValue) { final IndexBufferData<?> buffer; if (maxValue < 256) { // 2^8 buffer = createIndexBufferData(contents.length, ByteBufferData.class); } else if (maxValue < 65536) { // 2^16 buffer = createIndexBufferData(contents.length, ShortBufferData.class); } else { buffer = createIndexBufferData(contents.length, IntBufferData.class); } buffer.put(contents); return buffer; }
/** * Create a new IndexBufferData large enough to fit the contents of the given array. The specific implementation * will be chosen based on the max value you need to store in your buffer. If that value is less than 2^8, a * ByteBufferData is used. If it is less than 2^16, a ShortBufferData is used. Otherwise an IntBufferData is used. * * @param contents * an array of index values to store in your newly created IndexBufferData. * @param maxValue * the largest value you will need to store in your buffer. Often this is equal to * ("size of vertex buffer" - 1). * @return the new IndexBufferData */ public static IndexBufferData<?> createIndexBufferData(final int[] contents, final int maxValue) { final IndexBufferData<?> buffer; if (maxValue < 256) { // 2^8 buffer = createIndexBufferData(contents.length, ByteBufferData.class); } else if (maxValue < 65536) { // 2^16 buffer = createIndexBufferData(contents.length, ShortBufferData.class); } else { buffer = createIndexBufferData(contents.length, IntBufferData.class); } buffer.put(contents); return buffer; }
/** * Creates a new IndexBufferData with the same contents as the given IndexBufferData. The new IndexBufferData is * separate from the old one and changes are not reflected across. * * @param buf * the IndexBufferData to copy * @return the copy */ @SuppressWarnings("unchecked") public static IndexBufferData<?> clone(final IndexBufferData<?> buf) { if (buf == null) { return null; } final IndexBufferData<?> copy = createIndexBufferData(buf.getBufferLimit(), (Class<? extends IndexBufferData<?>>) buf.getClass()); if (buf.getBuffer() == null) { copy.setBuffer(null); } else { buf.getBuffer().rewind(); copy.put(buf); } return copy; }
/** * Creates a new IndexBufferData with the same contents as the given IndexBufferData. The new IndexBufferData is * separate from the old one and changes are not reflected across. * * @param buf * the IndexBufferData to copy * @return the copy */ @SuppressWarnings("unchecked") public static IndexBufferData<?> clone(final IndexBufferData<?> buf) { if (buf == null) { return null; } final IndexBufferData<?> copy = createIndexBufferData(buf.getBufferLimit(), (Class<? extends IndexBufferData<?>>) buf.getClass()); if (buf.getBuffer() == null) { copy.setBuffer(null); } else { buf.getBuffer().rewind(); copy.put(buf); } return copy; }
private static Mesh createMesh() { // create a triangle strip of 8 triangles. final Mesh mesh = new Mesh(); mesh.setRenderMaterial("ui/untextured/vertex_color_flat.yaml"); mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2)); mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8)); mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip); final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7); indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 }); mesh.getMeshData().setIndices(indices); // set up alpha blending. final BlendState blend = new BlendState(); blend.setBlendEnabled(true); blend.setSourceFunction(SourceFunction.SourceAlpha); blend.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha); mesh.setRenderState(blend); mesh.updateWorldRenderStates(false); return mesh; } }
private static Mesh createMesh() { // create a triangle strip of 8 triangles. final Mesh mesh = new Mesh(); mesh.getMeshData().setVertexCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2)); mesh.getMeshData().setColorBuffer(BufferUtils.createColorBuffer(8)); mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip); final IndexBufferData<?> indices = BufferUtils.createIndexBufferData(10, 7); indices.put(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1 }); mesh.getMeshData().setIndices(indices); // set up alpha blending. final BlendState blend = new BlendState(); blend.setBlendEnabled(true); blend.setSourceFunction(SourceFunction.SourceAlpha); blend.setDestinationFunction(DestinationFunction.OneMinusSourceAlpha); mesh.setRenderState(blend); // use flat shade so our borders will have a solid color. final ShadingState shading = new ShadingState(); shading.setShadingMode(ShadingMode.Flat); mesh.setRenderState(shading); mesh.updateWorldRenderStates(false); return mesh; } }