/** * Sets all the default vertex normals to 'up', +1 in the Z direction. */ private void setNormalData() { final Vector3 zAxis = new Vector3(0, 0, 1); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.setInBuffer(zAxis, _meshData.getNormalBuffer(), i); } }
/** * Sets all the default vertex normals to 'up', +1 in the Z direction. */ private void setNormalData() { final Vector3 zAxis = new Vector3(0, 0, 1); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.setInBuffer(zAxis, _meshData.getNormalBuffer(), i); } }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * Rotate normals. * * @param rotate * the rotate */ public void rotateNormals(final Quaternion rotate) { final FloatBuffer normalBuffer = getNormalBuffer(); final Vector3 store = new Vector3(); for (int x = 0; x < _vertexCount; x++) { BufferUtils.populateFromBuffer(store, normalBuffer, x); rotate.apply(store, store); BufferUtils.setInBuffer(store, normalBuffer, x); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
private void setNormalData() { final Vector3 norm = new Vector3(); for (int i = 0; i < NUM_POINTS; i++) { BufferUtils.populateFromBuffer(norm, _meshData.getVertexBuffer(), i); norm.normalizeLocal(); BufferUtils.setInBuffer(norm, _meshData.getNormalBuffer(), i); } }
public void transformNormals(final Transform transform, final boolean normalize) { final FloatBuffer normalBuffer = getNormalBuffer(); final Vector3 store = new Vector3(); for (int x = 0; x < _vertexCount; x++) { BufferUtils.populateFromBuffer(store, normalBuffer, x); transform.applyForwardVector(store, store); if (normalize) { store.normalizeLocal(); } BufferUtils.setInBuffer(store, normalBuffer, x); } }
/** * rotates the normals of this Mesh to world normals based on its world settings. The results are stored in the * given FloatBuffer. If given FloatBuffer is null, one is created. * * @param store * the FloatBuffer to store the results in, or null if you want one created. * @return store or new FloatBuffer if store == null. */ public FloatBuffer getWorldNormals(FloatBuffer store) { final FloatBuffer normBuf = _meshData.getNormalBuffer(); if (store == null || store.capacity() != normBuf.limit()) { store = BufferUtils.createFloatBuffer(normBuf.limit()); } final Vector3 compVect = Vector3.fetchTempInstance(); for (int v = 0, vSize = store.capacity() / 3; v < vSize; v++) { BufferUtils.populateFromBuffer(compVect, normBuf, v); _worldTransform.applyForwardVector(compVect); BufferUtils.setInBuffer(compVect, store, v); } Vector3.releaseTempInstance(compVect); return store; }
private void setData() { getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(getMeshData().getVertexBuffer(), trailVertices)); getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(getMeshData().getNormalBuffer(), trailVertices)); setDefaultColor(new ColorRGBA(ColorRGBA.WHITE)); setTextureData(); 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() { 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(); }