private void setTextureData() { _meshData.getTextureCoords(0).getBuffer().put(0.25f).put(0); _meshData.getTextureCoords(0).getBuffer().put(0.75f).put(0); _meshData.getTextureCoords(0).getBuffer().put(1.0f).put(0.5f); _meshData.getTextureCoords(0).getBuffer().put(0.75f).put(1.0f); _meshData.getTextureCoords(0).getBuffer().put(0.25f).put(1.0f); _meshData.getTextureCoords(0).getBuffer().put(0.0f).put(0.5f); _meshData.getTextureCoords(0).getBuffer().put(0.5f).put(0.5f); }
private void setTextureData() { _meshData.getTextureCoords(0).getBuffer().put(0.25f).put(0); _meshData.getTextureCoords(0).getBuffer().put(0.75f).put(0); _meshData.getTextureCoords(0).getBuffer().put(1.0f).put(0.5f); _meshData.getTextureCoords(0).getBuffer().put(0.75f).put(1.0f); _meshData.getTextureCoords(0).getBuffer().put(0.25f).put(1.0f); _meshData.getTextureCoords(0).getBuffer().put(0.0f).put(0.5f); _meshData.getTextureCoords(0).getBuffer().put(0.5f).put(0.5f); }
private void remap() { final FloatBuffer fb = _meshData.getTextureCoords(0).getBuffer(); fb.rewind(); for (int i = 0; i < 6; i++) { final float bottom = i / 8f; final float top = (i + 1) / 8f; final float[] tex = new float[] { 1, bottom, 0, bottom, 0, top, 1, top }; fb.put(tex); } } }
private void remap() { final FloatBuffer fb = _meshData.getTextureCoords(0).getBuffer(); fb.rewind(); for (int i = 0; i < 6; i++) { final float bottom = i / 8f; final float top = (i + 1) / 8f; final float[] tex = new float[] { 1, bottom, 0, bottom, 0, top, 1, top }; fb.put(tex); } } }
/** * * <code>setTextureData</code> sets the points that define the texture of the box. It's a one-to-one ratio, where * each plane of the box has it's own copy of the texture. That is, the texture is repeated one time for each six * faces. * */ private void setTextureData() { if (_meshData.getTextureCoords(0) == null) { _meshData.setTextureCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2), 0); final FloatBuffer tex = _meshData.getTextureCoords(0).getBuffer(); tex.put(1).put(0); // 0 tex.put(0).put(0); // 1 tex.put(0).put(1); // 2 tex.put(1).put(1); // 3 tex.put(1).put(0); // 4 tex.put(0).put(0); // 5 tex.put(1).put(1); // 6 tex.put(0).put(1); // 7 } }
/** * * <code>setTextureData</code> sets the points that define the texture of the box. It's a one-to-one ratio, where * each plane of the box has it's own copy of the texture. That is, the texture is repeated one time for each six * faces. * */ private void setTextureData() { if (_meshData.getTextureCoords(0) == null) { _meshData.setTextureCoords(new FloatBufferData(BufferUtils.createVector2Buffer(8), 2), 0); final FloatBuffer tex = _meshData.getTextureCoords(0).getBuffer(); tex.put(1).put(0); // 0 tex.put(0).put(0); // 1 tex.put(0).put(1); // 2 tex.put(1).put(1); // 3 tex.put(1).put(0); // 4 tex.put(0).put(0); // 5 tex.put(1).put(1); // 6 tex.put(0).put(1); // 7 } }
/** * <code>setTextureData</code> sets the points that define the texture of the box. It's a one-to-one ratio, where * each plane of the box has it's own copy of the texture. That is, the texture is repeated one time for each six * faces. */ private void setTextureData() { if (_meshData.getTextureCoords(0) == null) { _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(24), 0); final FloatBuffer tex = _meshData.getTextureBuffer(0); for (int i = 0; i < 6; i++) { tex.put(1).put(0); tex.put(0).put(0); tex.put(0).put(1); tex.put(1).put(1); } } }
/** * <code>setTextureData</code> sets the points that define the texture of the box. It's a one-to-one ratio, where * each plane of the box has it's own copy of the texture. That is, the texture is repeated one time for each six * faces. */ private void setTextureData() { if (_meshData.getTextureCoords(0) == null) { _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(24), 0); final FloatBuffer tex = _meshData.getTextureBuffer(0); for (int i = 0; i < 6; i++) { tex.put(1).put(0); tex.put(0).put(0); tex.put(0).put(1); tex.put(1).put(1); } } }
private void setTextureData() { if (getMeshData().getTextureCoords(0) == null) { final FloatBuffer tex = BufferUtils.createVector2Buffer(trailVertices); getMeshData().setTextureCoords(new FloatBufferData(tex, 2), 0); for (int i = 0; i < nrTrailSections; i++) { tex.put((float) i / nrTrailSections).put(0); tex.put((float) i / nrTrailSections).put(1); } } }
/** * Sets the correct texture array for the box. */ private void setTextureData() { if (_meshData.getTextureBuffer(0) == null) { _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(24), 0); for (int x = 0; x < 6; x++) { _meshData.getTextureCoords(0).getBuffer().put(_texTopRight.getXf()).put(_texTopRight.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texTopLeft.getXf()).put(_texTopLeft.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texBotLeft.getXf()).put(_texBotLeft.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texBotRight.getXf()).put(_texBotRight.getYf()); } } }
/** * Sets the correct texture array for the box. */ private void setTextureData() { if (_meshData.getTextureBuffer(0) == null) { _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(24), 0); for (int x = 0; x < 6; x++) { _meshData.getTextureCoords(0).getBuffer().put(_texTopRight.getXf()).put(_texTopRight.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texTopLeft.getXf()).put(_texTopLeft.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texBotLeft.getXf()).put(_texBotLeft.getYf()); _meshData.getTextureCoords(0).getBuffer().put(_texBotRight.getXf()).put(_texBotRight.getYf()); } } }
/** * Set the basic data for this mesh such as texture coordinates, index mode and our vertex buffer. */ private void initialize() { final FloatBufferData vbuf = new FloatBufferData(BufferUtils.createVector2Buffer(4), 2); vbuf.setVboAccessMode(VBOAccessMode.DynamicDraw); _meshData.setVertexCoords(vbuf); final FloatBuffer tbuf = BufferUtils.createVector2Buffer(4); _meshData.setTextureBuffer(tbuf, 0); _meshData.getTextureCoords(0).setVboAccessMode(VBOAccessMode.DynamicDraw); tbuf.put(0).put(1); tbuf.put(0).put(0); tbuf.put(1).put(0); tbuf.put(1).put(1); _meshData.setIndexMode(IndexMode.TriangleFan); }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
private void setTextureData() { final Vector2 tex = new Vector2(); final Vector3 vert = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(vert, _meshData.getVertexBuffer(), i); if (Math.abs(vert.getZ()) < _sideLength) { tex.setX(0.5 * (1.0 + Math.atan2(vert.getY(), vert.getX()) * MathUtils.INV_PI)); } else { tex.setX(0.5); } tex.setY(Math.acos(vert.getZ() / _sideLength) * MathUtils.INV_PI); _meshData.getTextureCoords(0).getBuffer().put((float) tex.getX()).put((float) tex.getY()); } }
/** * Check whether buffers have sufficient capacity to hold current string values; if not, increase capacity and set * the limit. * * @param text */ protected void checkBuffers(final String text) { final int chunkSize = 30; final int vertices = 6 * text.length(); final int chunks = 1 + (vertices / chunkSize); final int required = chunks * chunkSize; FloatBuffer vertexBuffer = getMeshData().getVertexBuffer(); FloatBuffer texCrdBuffer = getMeshData().getTextureBuffer(0); if (vertexBuffer == null || vertexBuffer.capacity() < required * 3) { vertexBuffer = BufferUtils.createVector3Buffer(required); texCrdBuffer = BufferUtils.createVector2Buffer(required); getMeshData().setVertexBuffer(vertexBuffer); getMeshData().setTextureBuffer(texCrdBuffer, 0); getMeshData().getVertexCoords().setVboAccessMode(VBOAccessMode.DynamicDraw); getMeshData().getTextureCoords(0).setVboAccessMode(VBOAccessMode.DynamicDraw); } vertexBuffer.limit(vertices * 3).rewind(); texCrdBuffer.limit(vertices * 2).rewind(); }
public void visit(final Spatial spatial) { if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; _deleter.deleteVBOs(mesh.getMeshData().getVertexCoords()); _deleter.deleteVBOs(mesh.getMeshData().getIndices()); _deleter.deleteVBOs(mesh.getMeshData().getInterleavedData()); _deleter.deleteVBOs(mesh.getMeshData().getNormalCoords()); _deleter.deleteVBOs(mesh.getMeshData().getTangentCoords()); for (final FloatBufferData coords : mesh.getMeshData().getTextureCoords()) { _deleter.deleteVBOs(coords); } _deleter.deleteVBOs(mesh.getMeshData().getColorCoords()); _deleter.deleteVBOs(mesh.getMeshData().getFogCoords()); } } }