public void put(int value) { delegate.put(count, value); count++; } /*public void put(int value) {
public static Mesh convert(IndexedMesh mesh) { Mesh jmeMesh = new Mesh(); jmeMesh.setBuffer(Type.Index, 3, BufferUtils.createShortBuffer(mesh.numTriangles * 3)); jmeMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(mesh.numVertices * 3)); IndexBuffer indicess = jmeMesh.getIndexBuffer(); FloatBuffer vertices = jmeMesh.getFloatBuffer(Type.Position); for (int i = 0; i < mesh.numTriangles * 3; i++) { indicess.put(i, mesh.triangleIndexBase.getInt(i * 4)); } for (int i = 0; i < mesh.numVertices * 3; i++) { vertices.put(i, mesh.vertexBase.getFloat(i * 4)); } jmeMesh.updateCounts(); jmeMesh.updateBound(); jmeMesh.getFloatBuffer(Type.Position).clear(); return jmeMesh; }
indexBuf.put(i, indexes.get(i));
public static void convertToList(Mesh mesh){ IndexBuffer inBuf = mesh.getIndicesAsList(); IndexBuffer outBuf = IndexBuffer.createIndexBuffer(mesh.getVertexCount(), inBuf.size()); for (int i = 0; i < inBuf.size(); i++){ outBuf.put(i, inBuf.get(i)); } mesh.clearBuffer(Type.Index); switch (mesh.getMode()){ case LineLoop: case LineStrip: mesh.setMode(Mode.Lines); break; case TriangleStrip: case TriangleFan: mesh.setMode(Mode.Triangles); break; default: break; } if (outBuf instanceof IndexIntBuffer){ mesh.setBuffer(Type.Index, 3, (IntBuffer)outBuf.getBuffer()); }else{ mesh.setBuffer(Type.Index, 3, (ShortBuffer)outBuf.getBuffer()); } }
newIndex = oldIndicesToNewIndices.get(oldIndex); newIndexBuf.put(i, newIndex);
for (int comp = 0; comp < components; comp++) { int idx = inIdx.get(tri * components + comp) + globalVertIndex; outIdx.put((globalTriIndex + tri) * components + comp, idx);
for (int comp = 0; comp < components; comp++) { int idx = inIdx.get(tri * components + comp) + globalVertIndex; outIdx.put((globalTriIndex + tri) * components + comp, idx);
public void put(int value) { delegate.put(count, value); count++; } /*public void put(int value) {
public static Mesh convert(IndexedMesh mesh) { Mesh jmeMesh = new Mesh(); jmeMesh.setBuffer(Type.Index, 3, BufferUtils.createShortBuffer(mesh.numTriangles * 3)); jmeMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(mesh.numVertices * 3)); IndexBuffer indicess = jmeMesh.getIndexBuffer(); FloatBuffer vertices = jmeMesh.getFloatBuffer(Type.Position); for (int i = 0; i < mesh.numTriangles * 3; i++) { indicess.put(i, mesh.triangleIndexBase.getInt(i * 4)); } for (int i = 0; i < mesh.numVertices * 3; i++) { vertices.put(i, mesh.vertexBase.getFloat(i * 4)); } jmeMesh.updateCounts(); jmeMesh.updateBound(); jmeMesh.getFloatBuffer(Type.Position).clear(); return jmeMesh; }
public static void convertToList(Mesh mesh){ IndexBuffer inBuf = mesh.getIndicesAsList(); IndexBuffer outBuf = IndexBuffer.createIndexBuffer(mesh.getVertexCount(), inBuf.size()); for (int i = 0; i < inBuf.size(); i++){ outBuf.put(i, inBuf.get(i)); } mesh.clearBuffer(Type.Index); switch (mesh.getMode()){ case LineLoop: case LineStrip: mesh.setMode(Mode.Lines); break; case TriangleStrip: case TriangleFan: mesh.setMode(Mode.Triangles); break; default: break; } if (outBuf instanceof IndexIntBuffer){ mesh.setBuffer(Type.Index, 3, (IntBuffer)outBuf.getBuffer()); }else{ mesh.setBuffer(Type.Index, 3, (ShortBuffer)outBuf.getBuffer()); } }
public static void convertToList(Mesh mesh){ IndexBuffer inBuf = mesh.getIndicesAsList(); IndexBuffer outBuf = IndexBuffer.createIndexBuffer(mesh.getVertexCount(), inBuf.size()); for (int i = 0; i < inBuf.size(); i++){ outBuf.put(i, inBuf.get(i)); } mesh.clearBuffer(Type.Index); switch (mesh.getMode()){ case LineLoop: case LineStrip: mesh.setMode(Mode.Lines); break; case TriangleStrip: case TriangleFan: mesh.setMode(Mode.Triangles); break; default: break; } if (outBuf instanceof IndexIntBuffer){ mesh.setBuffer(Type.Index, 3, (IntBuffer)outBuf.getBuffer()); }else{ mesh.setBuffer(Type.Index, 3, (ShortBuffer)outBuf.getBuffer()); } }
public static void compressIndexBuffer(Mesh mesh){ int vertCount = mesh.getVertexCount(); VertexBuffer vb = mesh.getBuffer(Type.Index); Format targetFmt; if (vb.getFormat() == Format.UnsignedInt && vertCount <= 0xffff){ if (vertCount <= 256) targetFmt = Format.UnsignedByte; else targetFmt = Format.UnsignedShort; }else if (vb.getFormat() == Format.UnsignedShort && vertCount <= 0xff){ targetFmt = Format.UnsignedByte; }else{ return; } IndexBuffer src = mesh.getIndexBuffer(); Buffer newBuf = VertexBuffer.createBuffer(targetFmt, vb.getNumComponents(), src.size()); VertexBuffer newVb = new VertexBuffer(Type.Index); newVb.setupData(vb.getUsage(), vb.getNumComponents(), targetFmt, newBuf); mesh.clearBuffer(Type.Index); mesh.setBuffer(newVb); IndexBuffer dst = mesh.getIndexBuffer(); for (int i = 0; i < src.size(); i++){ dst.put(i, src.get(i)); } }
newIndex = oldIndicesToNewIndices.get(oldIndex); newIndexBuf.put(i, newIndex);
ib.put(curIndex + j, trimmedIndices[j]);
newIndex = oldIndicesToNewIndices.get(oldIndex); newIndexBuf.put(i, newIndex);
for (int comp = 0; comp < components; comp++) { int idx = inIdx.get(tri * components + comp) + globalVertIndex; outIdx.put((globalTriIndex + tri) * components + comp, idx);
for (int comp = 0; comp < components; comp++) { int idx = inIdx.get(tri * components + comp) + globalVertIndex; outIdx.put((globalTriIndex + tri) * components + comp, idx);