List of usage examples for java.nio FloatBuffer rewind
public final Buffer rewind()
From source file:org.shaman.terrain.polygonal.PolygonalMapGenerator.java
private void updateGraphNode() { if (graphNode == null) { return;// w w w. j av a 2s . c om } //edges Mesh edgeMesh = new Mesh(); FloatBuffer pos = BufferUtils.createVector3Buffer(graph.corners.size()); IntBuffer index = BufferUtils.createIntBuffer(graph.edges.size() * 2); pos.rewind(); for (Graph.Corner c : graph.corners) { pos.put(c.point.x).put(c.point.y).put(0); } pos.rewind(); index.rewind(); for (Graph.Edge e : graph.edges) { index.put(e.v0.index).put(e.v1.index); } index.rewind(); edgeMesh.setBuffer(VertexBuffer.Type.Position, 3, pos); edgeMesh.setBuffer(VertexBuffer.Type.Index, 1, index); edgeMesh.setMode(Mesh.Mode.Lines); edgeMesh.setLineWidth(1); edgeMesh.updateCounts(); edgeMesh.updateBound(); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Gray); Geometry edgeGeom = new Geometry("edgeGeom", edgeMesh); edgeGeom.setMaterial(mat); edgeGeom.setCullHint(Spatial.CullHint.Never); edgeNode.detachAllChildren(); edgeNode.attachChild(edgeGeom); LOG.info("edge geometry updated"); }