/** * Locks the mesh (sets it static) to improve performance. * But it it not editable then. Set unlock to make it editable. */ public void lockMesh() { getMesh().setStatic(); }
m.setStatic(); m.updateBound(); m.updateCounts();
jmeMesh.setStatic();
public Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center){ FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer tb = writeTexCoordArray(null, Vector2f.ZERO, tcScale); FloatBuffer nb = writeNormalArray(null, scale); IntBuffer ib = writeIndexArray(null); Mesh m = new Mesh(); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.TexCoord, 2, tb); m.setBuffer(Type.Index, 3, ib); m.setStatic(); m.updateBound(); return m; }
lineMesh.setBuffer(Type.Color, 4, lineColor); lineMesh.setStatic();
distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); distortionMesh.setStatic(); return distortionMesh;
distortionMesh.setBuffer(VertexBuffer.Type.TexCoord2, 2, texcoordG); distortionMesh.setBuffer(VertexBuffer.Type.TexCoord3, 2, texcoordB); distortionMesh.setStatic(); return distortionMesh;
lineMesh.setBuffer(Type.Color, 4, lineColor); lineMesh.setStatic();
public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) { FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize); FloatBuffer nb = writeNormalArray(null, scale); Buffer ib; IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize); if (idxB.getBuffer() instanceof IntBuffer) ib = (IntBuffer)idxB.getBuffer(); else ib = (ShortBuffer)idxB.getBuffer(); FloatBuffer bb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); FloatBuffer tanb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); writeTangentArray(nb, tanb, bb, texb, scale); Mesh m = new Mesh(); m.setMode(Mode.TriangleStrip); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.Tangent, 3, tanb); m.setBuffer(Type.Binormal, 3, bb); m.setBuffer(Type.TexCoord, 2, texb); if (ib instanceof IntBuffer) m.setBuffer(Type.Index, 3, (IntBuffer)ib); else if (ib instanceof ShortBuffer) m.setBuffer(Type.Index, 3, (ShortBuffer)ib); m.setStatic(); m.updateBound(); return m; }
lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl);
lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl);
lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl);
lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl);
/** * Locks the mesh (sets it static) to improve performance. * But it it not editable then. Set unlock to make it editable. */ public void lockMesh() { getMesh().setStatic(); }
public Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center){ FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer tb = writeTexCoordArray(null, Vector2f.ZERO, tcScale); FloatBuffer nb = writeNormalArray(null, scale); IntBuffer ib = writeIndexArray(null); Mesh m = new Mesh(); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.TexCoord, 2, tb); m.setBuffer(Type.Index, 3, ib); m.setStatic(); m.updateBound(); return m; }
protected Node generatePointCloudGraphFrom(FloatBuffer pointCoordinates3d, FloatBuffer colorsRGBA, FloatBuffer sizes, float size) { Node result = new Node("Autogenerated Point Cloud Node"); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.getAdditionalRenderState().setPointSprite(true); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); mat.setBoolean("PointSprite", true); mat.setFloat("Quadratic", size); Mesh m = new Mesh(); m.setMode(Mode.Points); m.setBuffer(VertexBuffer.Type.Position, 3, pointCoordinates3d); m.setBuffer(VertexBuffer.Type.Color, 4, colorsRGBA); m.setBuffer(VertexBuffer.Type.Size, 1, sizes); m.setStatic(); m.updateBound(); Geometry g = new Geometry("AutoGenerated Point Cloud", m); g.setShadowMode(ShadowMode.Off); g.setQueueBucket(Bucket.Transparent); g.setMaterial(mat); g.updateModelBound(); g.setCullHint(CullHint.Never); result.attachChild(g); result.updateModelBound(); return result; }
public static Mesh genNormalLines(Mesh mesh, float scale) { FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData(); ColorRGBA originColor = ColorRGBA.White; ColorRGBA normalColor = ColorRGBA.Blue; Mesh lineMesh = new Mesh(); lineMesh.setMode(Mesh.Mode.Lines); Vector3f origin = new Vector3f(); Vector3f point = new Vector3f(); FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.limit() * 2); FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.limit() / 3 * 4 * 2); for (int i = 0; i < vertexBuffer.limit() / 3; i++) { populateFromBuffer(origin, vertexBuffer, i); populateFromBuffer(point, normalBuffer, i); int index = i * 2; setInBuffer(origin, lineVertex, index); setInBuffer(originColor, lineColor, index); point.multLocal(scale); point.addLocal(origin); setInBuffer(point, lineVertex, index + 1); setInBuffer(normalColor, lineColor, index + 1); } lineMesh.setBuffer(Type.Position, 3, lineVertex); lineMesh.setBuffer(Type.Color, 4, lineColor); lineMesh.setStatic(); //lineMesh.setInterleaved(); return lineMesh; }
public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) { FloatBuffer pb = writeVertexArray(null, scale, center); FloatBuffer texb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize); FloatBuffer nb = writeNormalArray(null, scale); Buffer ib; IndexBuffer idxB = writeIndexArrayLodDiff(lod, rightLod, topLod, leftLod, bottomLod, totalSize); if (idxB.getBuffer() instanceof IntBuffer) ib = (IntBuffer)idxB.getBuffer(); else ib = (ShortBuffer)idxB.getBuffer(); FloatBuffer bb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); FloatBuffer tanb = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3); writeTangentArray(nb, tanb, bb, texb, scale); Mesh m = new Mesh(); m.setMode(Mode.TriangleStrip); m.setBuffer(Type.Position, 3, pb); m.setBuffer(Type.Normal, 3, nb); m.setBuffer(Type.Tangent, 3, tanb); m.setBuffer(Type.Binormal, 3, bb); m.setBuffer(Type.TexCoord, 2, texb); if (ib instanceof IntBuffer) m.setBuffer(Type.Index, 3, (IntBuffer)ib); else if (ib instanceof ShortBuffer) m.setBuffer(Type.Index, 3, (ShortBuffer)ib); m.setStatic(); m.updateBound(); return m; }