if (geometry.getMesh().getMode() == Mode.Triangles) {// there is no need to flip the indexes for lines and points LOGGER.finer("Flipping index order in triangle mesh."); Buffer indexBuffer = geometry.getMesh().getBuffer(Type.Index).getData();
boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing); if (mesh.getMode() == Mode.Hybrid) { int[] modeStart = mesh.getModeStart(); int[] elementLengths = mesh.getElementLengths(); glext.glDrawElementsInstancedARB(convertElementMode(mesh.getMode()), indexBuf.getData().limit(), convertFormat(indexBuf.getFormat()), count); } else { gl.glDrawRangeElements(convertElementMode(mesh.getMode()), 0, vertCount,
public BIHTree(Mesh mesh, int maxTrisPerNode) { this.mesh = mesh; this.maxTrisPerNode = maxTrisPerNode; if (maxTrisPerNode < 1) { throw new IllegalArgumentException("maxTrisPerNode cannot be less than 1"); } if (mesh == null) { throw new IllegalArgumentException("Mesh cannot be null"); } bihSwapTmp = new float[9]; VertexBuffer vBuffer = mesh.getBuffer(Type.Position); if(vBuffer == null){ throw new IllegalArgumentException("A mesh should at least contain a Position buffer"); } IndexBuffer ib = mesh.getIndexBuffer(); FloatBuffer vb = (FloatBuffer) vBuffer.getData(); if (ib == null) { ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode()); } else if (mesh.getMode() != Mode.Triangles) { ib = new WrappedIndexBuffer(mesh); } numTris = ib.size() / 3; initTriList(vb, ib); }
public WrappedIndexBuffer(Mesh mesh){ super(mesh.getVertexCount(), mesh.getMode()); this.ib = mesh.getIndexBuffer(); switch (meshMode){ case Points: numIndices = mesh.getTriangleCount(); break; case Lines: case LineLoop: case LineStrip: numIndices = mesh.getTriangleCount() * 2; break; case Triangles: case TriangleStrip: case TriangleFan: numIndices = mesh.getTriangleCount() * 3; break; default: throw new UnsupportedOperationException(); } }
/** * This type of collision shape is mesh-accurate and meant for immovable * "world objects". Examples include terrain, houses or whole shooter * levels. * <p> * Objects with "mesh" type collision shape will not collide with each * other. */ private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) { MeshCollisionShape mColl = new MeshCollisionShape(mesh); mColl.setScale(trans.getScale()); return mColl; } else { return null; } }
/** * This type of collision shape is mesh-accurate and meant for immovable * "world objects". Examples include terrain, houses or whole shooter * levels. * <p> * Objects with "mesh" type collision shape will not collide with each * other. */ private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) { MeshCollisionShape mColl = new MeshCollisionShape(mesh); mColl.setScale(trans.getScale()); return mColl; } else { return null; } }
private void startFaces(String count) throws SAXException { int numFaces = parseInt(count); int indicesPerFace = 0; switch (mesh.getMode()) { case Triangles: indicesPerFace = 3; break; case Lines: indicesPerFace = 2; break; case Points: indicesPerFace = 1; break; default: throw new SAXException("Strips or fans not supported!"); } int numIndices = indicesPerFace * numFaces; vb = new VertexBuffer(VertexBuffer.Type.Index); if (!usesBigIndices) { sb = BufferUtils.createShortBuffer(numIndices); ib = null; vb.setupData(Usage.Static, indicesPerFace, Format.UnsignedShort, sb); } else { ib = BufferUtils.createIntBuffer(numIndices); sb = null; vb.setupData(Usage.Static, indicesPerFace, Format.UnsignedInt, ib); } mesh.setBuffer(vb); }
public void renderMesh(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) { if (mesh.getVertexCount() == 0 || mesh.getTriangleCount() == 0 || count == 0) { return; } if (count > 1 && !caps.contains(Caps.MeshInstancing)) { throw new RendererException("Mesh instancing is not supported by the video hardware"); } if (mesh.getLineWidth() != 1f && context.lineWidth != mesh.getLineWidth()) { gl.glLineWidth(mesh.getLineWidth()); context.lineWidth = mesh.getLineWidth(); } if (gl4 != null && mesh.getMode().equals(Mode.Patch)) { gl4.glPatchParameter(mesh.getPatchVertexCount()); } statistics.onMeshDrawn(mesh, lod, count); // if (ctxCaps.GL_ARB_vertex_array_object){ // renderMeshVertexArray(mesh, lod, count); // }else{ renderMeshDefault(mesh, lod, count, instanceData); // } }
private void pushFace(String v1, String v2, String v3) throws SAXException { // TODO: fan/strip support switch (mesh.getMode()) { case Triangles: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); pushIndex(parseInt(v3)); break; case Lines: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); break; case Points: pushIndex(parseInt(v1)); break; } }
private void renderMeshVertexArray(Mesh mesh, int lod, int count, VertexBuffer instanceData) { if (mesh.getId() == -1) { updateVertexArray(mesh, instanceData); } else { // TODO: Check if it was updated } if (context.boundVertexArray != mesh.getId()) { gl3.glBindVertexArray(mesh.getId()); context.boundVertexArray = mesh.getId(); } // IntMap<VertexBuffer> buffers = mesh.getBuffers(); VertexBuffer indices; if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); } else { indices = mesh.getBuffer(Type.Index); } if (indices != null) { drawTriangleList(indices, mesh, count); } else { drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount()); } clearVertexAttribs(); }
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()); } }
drawTriangleList(indices, mesh, count); } else { drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());
switch (geom.getMesh().getMode()) { case Points: listMode = Mesh.Mode.Points;
switch (geom.getMesh().getMode()) { case Points: listMode = Mode.Points;
public BIHTree(Mesh mesh, int maxTrisPerNode) { this.mesh = mesh; this.maxTrisPerNode = maxTrisPerNode; if (maxTrisPerNode < 1 || mesh == null) { throw new IllegalArgumentException(); } bihSwapTmp = new float[9]; FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); IndexBuffer ib = mesh.getIndexBuffer(); if (ib == null) { ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode()); } else if (mesh.getMode() != Mode.Triangles) { ib = new WrappedIndexBuffer(mesh); } numTris = ib.size() / 3; initTriList(vb, ib); }
/** * This type of collision shape is mesh-accurate and meant for immovable "world objects". * Examples include terrain, houses or whole shooter levels.<br> * Objects with "mesh" type collision shape will not collide with each other. */ private static MeshCollisionShape createSingleMeshShape(Geometry geom, Spatial parent) { Mesh mesh = geom.getMesh(); Transform trans = getTransform(geom, parent); if (mesh != null && mesh.getMode() == Mesh.Mode.Triangles) { MeshCollisionShape mColl = new MeshCollisionShape(mesh); mColl.setScale(trans.getScale()); return mColl; } else { return null; } }
private void pushFace(String v1, String v2, String v3) throws SAXException { // TODO: fan/strip support switch (mesh.getMode()) { case Triangles: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); pushIndex(parseInt(v3)); break; case Lines: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); break; case Points: pushIndex(parseInt(v1)); break; } }
private void pushFace(String v1, String v2, String v3) throws SAXException { // TODO: fan/strip support switch (mesh.getMode()) { case Triangles: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); pushIndex(parseInt(v3)); break; case Lines: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); break; case Points: pushIndex(parseInt(v1)); break; } }
private void pushFace(String v1, String v2, String v3) throws SAXException { // TODO: fan/strip support switch (mesh.getMode()) { case Triangles: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); pushIndex(parseInt(v3)); break; case Lines: pushIndex(parseInt(v1)); pushIndex(parseInt(v2)); break; case Points: pushIndex(parseInt(v1)); break; } }