/** * Let this mesh know we want to change its indices to the provided new order. Override this to provide extra * functionality for sub types as needed. * * @param newIndices * the IntBufferData to switch to. * @param modes * the new segment modes to use. * @param lengths * the new lengths to use. */ public void reorderIndices(final IndexBufferData<?> newIndices, final IndexMode[] modes, final int[] lengths) { _meshData.setIndices(newIndices); _meshData.setIndexModes(modes); _meshData.setIndexLengths(lengths); }
/** * Let this mesh know we want to change its indices to the provided new order. Override this to provide extra * functionality for sub types as needed. * * @param newIndices * the IntBufferData to switch to. * @param modes * the new segment modes to use. * @param lengths * the new lengths to use. */ public void reorderIndices(final IndexBufferData<?> newIndices, final IndexMode[] modes, final int[] lengths) { _meshData.setIndices(newIndices); _meshData.setIndexModes(modes); _meshData.setIndexLengths(lengths); }
@Override public void reorderIndices(final IndexBufferData<?> newIndices, final IndexMode[] modes, final int[] lengths) { super.reorderIndices(newIndices, modes, lengths); _bindPoseData.setIndices(newIndices); _bindPoseData.setIndexModes(modes); _bindPoseData.setIndexLengths(lengths); }
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); } }
@Override public void reorderIndices(final IndexBufferData<?> newIndices, final IndexMode[] modes, final int[] lengths) { super.reorderIndices(newIndices, modes, lengths); _bindPoseData.setIndices(newIndices); _bindPoseData.setIndexModes(modes); _bindPoseData.setIndexLengths(lengths); }
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); } }
/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); _meshData.setIndices(null); }
/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); _meshData.setIndices(null); }
/** * Construct a new TextCaret */ public TextCaret() { final MeshData md = _strip.getMeshData(); md.setVertexBuffer(BufferUtils.createVector3Buffer(4)); md.setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 2 }, 3)); md.setIndexMode(IndexMode.TriangleStrip); final float[] vals = new float[] { 0, 0, 0, // 1, 0, 0, // 1, 1, 0, // 0, 1, 0 // }; md.getVertexBuffer().put(vals); _strip.updateGeometricState(0); setCaretColor(ColorRGBA.BLACK); }
public BMTextBackground(final String name, final BMText text, final Texture texture, final ReadOnlyVector4 textureBorderOffsets) { super(name); _text = text; _texture = texture; _textureBorderOffsets.set(textureBorderOffsets); setRenderStates(texture); // allocate vertex data _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(16)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(16), 0); _meshData.setIndices(BufferUtils.createIndexBufferData(28, 15)); // Set initial static data. setTextureData(); setIndexData(); setRenderMaterial("ui/textured/default_color.yaml"); // -- add self as change listener _text.addChangeListener(this); }
private void allocateVertices() { final int verts = (2 * (_axisSamples + 1) * (_radialSamples + 1) + _radialSamples * 4); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(_meshData.getTextureBuffer(0), verts), 0); final int tris = (4 * _radialSamples * (1 + _axisSamples)); if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
private void allocateVertices() { final int verts = (2 * (_axisSamples + 1) * (_radialSamples + 1) + _radialSamples * 4); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(_meshData.getTextureBuffer(0), verts), 0); final int tris = (4 * _radialSamples * (1 + _axisSamples)); if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
private void allocateVertices() { // allocate vertices final int verts = _axisSamples * (_radialSamples + 1) + (_closed ? 2 : 0); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals if requested _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); final int count = ((_closed ? 2 : 0) + 2 * (_axisSamples - 1)) * _radialSamples; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * count) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * count, verts - 1)); } setGeometryData(); setIndexData(); }
private void allocateVertices() { // allocate vertices final int verts = _axisSamples * (_radialSamples + 1) + (_closed ? 2 : 0); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals if requested _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); final int count = ((_closed ? 2 : 0) + 2 * (_axisSamples - 1)) * _radialSamples; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * count) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * count, verts - 1)); } setGeometryData(); setIndexData(); }
private void recreateBuffers() { // determine vert quantity - first the sphere caps final int sampleLines = (2 * sphereSamples - 1 + axisSamples); final int verts = (radialSamples + 1) * sampleLines + 2; _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); // determine tri quantity final int tris = 2 * radialSamples * sampleLines; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
private void recreateBuffers() { // determine vert quantity - first the sphere caps final int sampleLines = (2 * sphereSamples - 1 + axisSamples); final int verts = (radialSamples + 1) * sampleLines + 2; _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); // determine tri quantity final int tris = 2 * radialSamples * sampleLines; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
protected Mesh getFullScreenQuad() { if (_fsq != null) { return _fsq; } _fsq = new Mesh("fsq"); _fsq.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1)); _fsq.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(0, 0, 1, 0, 1, 1, 0, 1), 0); _fsq.getMeshData().setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 1, 2, 3 }, 3)); _fsq.getSceneHints().setCullHint(CullHint.Never); _fsq.getSceneHints().setLightCombineMode(LightCombineMode.Off); final ZBufferState zState = new ZBufferState(); zState.setEnabled(false); _fsq.setRenderState(zState); _fsq.updateGeometricState(0); return _fsq; }
/** * <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); }
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; } }