/** * Creates a clone of the given buffer. The clone's capacity is equal to the * given buffer's limit. * * @param buf * The buffer to clone * @return The cloned buffer */ public static Buffer clone(Buffer buf) { if (buf instanceof FloatBuffer) { return clone((FloatBuffer) buf); } else if (buf instanceof ShortBuffer) { return clone((ShortBuffer) buf); } else if (buf instanceof ByteBuffer) { return clone((ByteBuffer) buf); } else if (buf instanceof IntBuffer) { return clone((IntBuffer) buf); } else if (buf instanceof DoubleBuffer) { return clone((DoubleBuffer) buf); } else { throw new UnsupportedOperationException(); } }
/** * Creates a deep clone of this VertexBuffer but overrides the * {@link Type}. * * @param overrideType The type of the cloned VertexBuffer * @return A deep clone of the buffer */ public VertexBuffer clone(Type overrideType){ VertexBuffer vb = new VertexBuffer(overrideType); vb.components = components; vb.componentsLength = componentsLength; // Make sure to pass a read-only buffer to clone so that // the position information doesn't get clobbered by another // reading thread during cloning (and vice versa) since this is // a purely read-only operation. vb.data = BufferUtils.clone(getDataReadOnly()); vb.format = format; vb.handleRef = new Object(); vb.id = -1; vb.normalized = normalized; vb.instanceSpan = instanceSpan; vb.offset = offset; vb.stride = stride; vb.updateNeeded = true; vb.usage = usage; return vb; }
/** * Creates a deep clone of the {@link VertexBuffer}. * * @return Deep clone of this buffer */ @Override public VertexBuffer clone(){ // NOTE: Superclass GLObject automatically creates shallow clone // e.g re-use ID. VertexBuffer vb = (VertexBuffer) super.clone(); vb.handleRef = new Object(); vb.id = -1; if (data != null) { // Make sure to pass a read-only buffer to clone so that // the position information doesn't get clobbered by another // reading thread during cloning (and vice versa) since this is // a purely read-only operation. vb.updateData(BufferUtils.clone(getDataReadOnly())); } return vb; }
public static void generateBindPoseTangentsIfNecessary(Mesh mesh){ if (mesh.getBuffer(VertexBuffer.Type.BindPosePosition) != null) { VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); if (tangents != null) { VertexBuffer bindTangents = new VertexBuffer(VertexBuffer.Type.BindPoseTangent); bindTangents.setupData(VertexBuffer.Usage.CpuOnly, 4, VertexBuffer.Format.Float, BufferUtils.clone(tangents.getData())); if (mesh.getBuffer(VertexBuffer.Type.BindPoseTangent) != null) { mesh.clearBuffer(VertexBuffer.Type.BindPoseTangent); } mesh.setBuffer(bindTangents); tangents.setUsage(VertexBuffer.Usage.Stream); } } } }
pos.getNumComponents(), pos.getFormat(), BufferUtils.clone(pos.getData())); setBuffer(bindPos); norm.getNumComponents(), norm.getFormat(), BufferUtils.clone(norm.getData())); setBuffer(bindNorm); norm.setUsage(Usage.Stream); tangents.getNumComponents(), tangents.getFormat(), BufferUtils.clone(tangents.getData())); setBuffer(bindTangents); tangents.setUsage(Usage.Stream);
ArrayList<ByteBuffer> data = new ArrayList<ByteBuffer>(6); for (int i = 0; i < 6; ++i) { data.add(BufferUtils.clone(sourceData));
/** * Creates a clone of the given buffer. The clone's capacity is * equal to the given buffer's limit. * * @param buf The buffer to clone * @return The cloned buffer */ public static Buffer clone(Buffer buf) { if (buf instanceof FloatBuffer) { return clone((FloatBuffer) buf); } else if (buf instanceof ShortBuffer) { return clone((ShortBuffer) buf); } else if (buf instanceof ByteBuffer) { return clone((ByteBuffer) buf); } else if (buf instanceof IntBuffer) { return clone((IntBuffer) buf); } else if (buf instanceof DoubleBuffer) { return clone((DoubleBuffer) buf); } else { throw new UnsupportedOperationException(); } }
/** * Creates a clone of the given buffer. The clone's capacity is equal to the * given buffer's limit. * * @param buf * The buffer to clone * @return The cloned buffer */ public static Buffer clone(Buffer buf) { if (buf instanceof FloatBuffer) { return clone((FloatBuffer) buf); } else if (buf instanceof ShortBuffer) { return clone((ShortBuffer) buf); } else if (buf instanceof ByteBuffer) { return clone((ByteBuffer) buf); } else if (buf instanceof IntBuffer) { return clone((IntBuffer) buf); } else if (buf instanceof DoubleBuffer) { return clone((DoubleBuffer) buf); } else { throw new UnsupportedOperationException(); } }
/** * Creates a deep clone of this VertexBuffer but overrides the * {@link Type}. * * @param overrideType The type of the cloned VertexBuffer * @return A deep clone of the buffer */ public VertexBuffer clone(Type overrideType){ VertexBuffer vb = new VertexBuffer(overrideType); vb.components = components; vb.componentsLength = componentsLength; vb.data = BufferUtils.clone(data); vb.format = format; vb.handleRef = new Object(); vb.id = -1; vb.normalized = normalized; vb.offset = offset; vb.stride = stride; vb.updateNeeded = true; vb.usage = usage; return vb; }
/** * Creates a deep clone of the {@link VertexBuffer}. * * @return Deep clone of this buffer */ @Override public VertexBuffer clone(){ // NOTE: Superclass GLObject automatically creates shallow clone // e.g re-use ID. VertexBuffer vb = (VertexBuffer) super.clone(); vb.handleRef = new Object(); vb.id = -1; if (data != null) vb.updateData(BufferUtils.clone(data)); return vb; }
/** * Creates a deep clone of this VertexBuffer but overrides the * {@link Type}. * * @param overrideType The type of the cloned VertexBuffer * @return A deep clone of the buffer */ public VertexBuffer clone(Type overrideType){ VertexBuffer vb = new VertexBuffer(overrideType); vb.components = components; vb.componentsLength = componentsLength; // Make sure to pass a read-only buffer to clone so that // the position information doesn't get clobbered by another // reading thread during cloning (and vice versa) since this is // a purely read-only operation. vb.data = BufferUtils.clone(getDataReadOnly()); vb.format = format; vb.handleRef = new Object(); vb.id = -1; vb.normalized = normalized; vb.instanceSpan = instanceSpan; vb.offset = offset; vb.stride = stride; vb.updateNeeded = true; vb.usage = usage; return vb; }
/** * Creates a deep clone of the {@link VertexBuffer}. * * @return Deep clone of this buffer */ @Override public VertexBuffer clone(){ // NOTE: Superclass GLObject automatically creates shallow clone // e.g re-use ID. VertexBuffer vb = (VertexBuffer) super.clone(); vb.handleRef = new Object(); vb.id = -1; if (data != null) { // Make sure to pass a read-only buffer to clone so that // the position information doesn't get clobbered by another // reading thread during cloning (and vice versa) since this is // a purely read-only operation. vb.updateData(BufferUtils.clone(getDataReadOnly())); } return vb; }
VertexBuffer vb; vb = new VertexBuffer(VertexBuffer.Type.Position); FloatBuffer vfb = BufferUtils.clone((FloatBuffer) vbBackup.getData()); vb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, vfb); clearBuffer(VertexBuffer.Type.Position); VertexBuffer nb; nb = new VertexBuffer(VertexBuffer.Type.Normal); FloatBuffer nfb = BufferUtils.clone((FloatBuffer) nbBackup.getData()); nb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, nfb); clearBuffer(VertexBuffer.Type.Normal);
FloatBuffer skinvfb2 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData()); newMesh.skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2); FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.getBuffer(VertexBuffer.Type.Position).getData()); skinvb1.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb1); newMesh.clearBuffer(VertexBuffer.Type.Position);
private void createBindPose(Mesh jmeMesh) { // create bind pose. I have no idea of what/when/how this should be called... VertexBuffer pos = jmeMesh.getBuffer(Type.Position); VertexBuffer bindPos = new VertexBuffer(Type.BindPosePosition); bindPos.setupData(Usage.CpuOnly, 3, Format.Float, BufferUtils.clone(pos.getData())); jmeMesh.setBuffer(bindPos); pos.setUsage(Usage.Stream); VertexBuffer norm = jmeMesh.getBuffer(Type.Normal); if (norm != null) { VertexBuffer bindNorm = new VertexBuffer(Type.BindPoseNormal); bindNorm.setupData(Usage.CpuOnly, 3, Format.Float, BufferUtils.clone(norm.getData())); jmeMesh.setBuffer(bindNorm); norm.setUsage(Usage.Stream); } }
public static void generateBindPoseTangentsIfNecessary(Mesh mesh){ if (mesh.getBuffer(VertexBuffer.Type.BindPosePosition) != null) { VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); if (tangents != null) { VertexBuffer bindTangents = new VertexBuffer(VertexBuffer.Type.BindPoseTangent); bindTangents.setupData(VertexBuffer.Usage.CpuOnly, 4, VertexBuffer.Format.Float, BufferUtils.clone(tangents.getData())); if (mesh.getBuffer(VertexBuffer.Type.BindPoseTangent) != null) { mesh.clearBuffer(VertexBuffer.Type.BindPoseTangent); } mesh.setBuffer(bindTangents); tangents.setUsage(VertexBuffer.Usage.Stream); } } } }
pos.getNumComponents(), pos.getFormat(), BufferUtils.clone(pos.getData())); setBuffer(bindPos); norm.getNumComponents(), norm.getFormat(), BufferUtils.clone(norm.getData())); setBuffer(bindNorm); norm.setUsage(Usage.Stream); tangents.getNumComponents(), tangents.getFormat(), BufferUtils.clone(tangents.getData())); setBuffer(bindTangents); tangents.setUsage(Usage.Stream);
pos.getNumComponents(), pos.getFormat(), BufferUtils.clone(pos.getData())); setBuffer(bindPos); norm.getNumComponents(), norm.getFormat(), BufferUtils.clone(norm.getData())); setBuffer(bindNorm); norm.setUsage(Usage.Stream); tangents.getNumComponents(), tangents.getFormat(), BufferUtils.clone(tangents.getData())); setBuffer(bindTangents); tangents.setUsage(Usage.Stream);
4, Format.Float, BufferUtils.clone(tangents.getData()));