/** * Indicates to the GPU that this mesh will be modified occasionally (a hint). * Sets the usage mode to {@link Usage#Dynamic} * for all {@link VertexBuffer vertex buffers} on this Mesh. */ public void setDynamic() { for (VertexBuffer vb : buffersList.getArray()){ vb.setUsage(Usage.Dynamic); } }
@Override public void setImagesXY(int imagesX, int imagesY) { this.imagesX = imagesX; this.imagesY = imagesY; if (imagesX != 1 || imagesY != 1){ uniqueTexCoords = true; getBuffer(VertexBuffer.Type.TexCoord).setUsage(Usage.Stream); } }
/** * Indicates to the GPU that this mesh will not be modified (a hint). * Sets the usage mode to {@link Usage#Static} * for all {@link VertexBuffer vertex buffers} on this Mesh. */ public void setStatic() { for (VertexBuffer vb : buffersList.getArray()){ vb.setUsage(Usage.Static); } }
/** * Indicates to the GPU that this mesh will be modified every frame (a hint). * Sets the usage mode to {@link Usage#Stream} * for all {@link VertexBuffer vertex buffers} on this Mesh. */ public void setStreamed(){ for (VertexBuffer vb : buffersList.getArray()){ vb.setUsage(Usage.Stream); } }
mesh.setBuffer(VertexBuffer.Type.BoneWeight, 4, boneWeightData); mesh.setBuffer(VertexBuffer.Type.BoneIndex, 4, boneIndicesData); mesh.getBuffer(VertexBuffer.Type.BoneWeight).setUsage(Usage.CpuOnly); mesh.getBuffer(VertexBuffer.Type.BoneIndex).setUsage(Usage.CpuOnly); VertexBuffer weightsHW = new VertexBuffer(Type.HWBoneWeight); VertexBuffer indicesHW = new VertexBuffer(Type.HWBoneIndex); indicesHW.setUsage(Usage.CpuOnly); // Setting usage to CpuOnly so that the buffer is not send empty to the GPU weightsHW.setUsage(Usage.CpuOnly); mesh.setBuffer(weightsHW); mesh.setBuffer(indicesHW);
public static void setSkinBuffers(Mesh mesh, short[] jointsArray, float[] weightsArray, int componentSize) { if (componentSize == 1) { mesh.setBuffer(VertexBuffer.Type.BoneIndex, 4, BufferUtils.createByteBuffer(toByteArray(jointsArray))); } else { mesh.setBuffer(VertexBuffer.Type.BoneIndex, 4, BufferUtils.createShortBuffer(jointsArray)); } mesh.setBuffer(VertexBuffer.Type.BoneWeight, 4, BufferUtils.createFloatBuffer(weightsArray)); mesh.getBuffer(VertexBuffer.Type.BoneIndex).setUsage(VertexBuffer.Usage.CpuOnly); mesh.getBuffer(VertexBuffer.Type.BoneWeight).setUsage(VertexBuffer.Usage.CpuOnly); }
private static void initGeom(Mesh m, Vector3f[] points) { if (points != null) m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(points)); m.setBuffer(Type.Index, 2, new short[]{ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7, } ); m.getBuffer(Type.Index).setUsage(Usage.Static); m.setMode(Mode.Lines); }
indices.setUsage(Usage.CpuOnly); weights.updateData(arrayWeight); weights.setUsage(Usage.CpuOnly); positions.setUsage(Usage.Stream); if (normals != null) { normals.setUsage(Usage.Stream); tangents.setUsage(Usage.Stream); VertexBuffer tangentsBP = getBuffer(Type.BindPoseTangent); positions.setUsage(Usage.Static); positionsBP.copyElements(0, positions, 0, positionsBP.getNumElements()); positions.setUpdateNeeded(); normals.setUsage(Usage.Static); normalsBP.copyElements(0, normals, 0, normalsBP.getNumElements()); normals.setUpdateNeeded(); tangents.setUsage(Usage.Static); tangentsBP.copyElements(0, tangents, 0, tangentsBP.getNumElements()); tangents.setUpdateNeeded();
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); } } } }
public RenderDeviceJme(NiftyJmeDisplay display) { this.display = display; quadColor = new VertexBuffer(Type.Color); quadColor.setNormalized(true); ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4); quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb); quad.setBuffer(quadColor); quadModTC.setUsage(Usage.Stream); // Load the 3 material types separately to avoid // reloading the shader when the defines change. // Material with a single color (no texture or vertex color) colorMaterial = new Material(display.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); // Material with a texture and a color (no vertex color) textureColorMaterial = new Material(display.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); // Material with vertex color, used for gradients (no texture) vertexColorMaterial = new Material(display.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); vertexColorMaterial.setBoolean("VertexColor", true); // Shared render state for all materials renderState.setDepthTest(false); renderState.setDepthWrite(false); }
/** * Indicates to the GPU that this mesh will be modified occasionally (a hint). * Sets the usage mode to {@link Usage#Dynamic} * for all {@link VertexBuffer vertex buffers} on this Mesh. */ public void setDynamic() { for (VertexBuffer vb : buffersList.getArray()){ vb.setUsage(Usage.Dynamic); } }