Java Code Examples for com.jme3.util.SafeArrayList#get()
The following examples show how to use
com.jme3.util.SafeArrayList#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TerrainGridLodControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void updateLOD(SafeArrayList<Vector3f> locations, LodCalculator lodCalculator) { TerrainGrid terrainGrid = (TerrainGrid)getSpatial(); // for now, only the first camera is handled. // to accept more, there are two ways: // 1: every camera has an associated grid, then the location is not enough to identify which camera location has changed // 2: grids are associated with locations, and no incremental update is done, we load new grids for new locations, and unload those that are not needed anymore Vector3f cam = locations.isEmpty() ? Vector3f.ZERO.clone() : locations.get(0); Vector3f camCell = terrainGrid.getCamCell(cam); // get the grid index value of where the camera is (ie. 2,1) if (terrainGrid.cellsLoaded > 1) { // Check if cells are updated before updating gridoffset. terrainGrid.gridOffset[0] = Math.round(camCell.x * (terrainGrid.size / 2)); terrainGrid.gridOffset[1] = Math.round(camCell.z * (terrainGrid.size / 2)); terrainGrid.cellsLoaded = 0; } if (camCell.x != terrainGrid.currentCamCell.x || camCell.z != terrainGrid.currentCamCell.z || !terrainGrid.runOnce) { // if the camera has moved into a new cell, load new terrain into the visible 4 center quads terrainGrid.updateChildren(camCell); for (TerrainGridListener l : terrainGrid.listeners) { l.gridMoved(camCell); } } terrainGrid.runOnce = true; super.updateLOD(locations, lodCalculator); }
Example 2
Source File: GdxRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void updateVertexArray(Mesh mesh) { logger.log(Level.INFO, "updateVertexArray({0})", mesh); int id = mesh.getId(); /* if (id == -1){ IntBuffer temp = intBuf1; // ARBVertexArrayObject.glGenVertexArrays(temp); GLES20.glGenVertexArrays(temp); id = temp.get(0); mesh.setId(id); } if (context.boundVertexArray != id){ // ARBVertexArrayObject.glBindVertexArray(id); GLES20.glBindVertexArray(id); context.boundVertexArray = id; } */ VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); if (interleavedData != null && interleavedData.isUpdateNeeded()) { updateBufferData(interleavedData); } SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList(); for (int i = 0; i < buffersList.size(); i++) { VertexBuffer vb = buffersList.get(i); if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { continue; } if (vb.getStride() == 0) { // not interleaved setVertexAttrib(vb); } else { // interleaved setVertexAttrib(vb, interleavedData); } } }
Example 3
Source File: GdxRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
private void renderMeshDefault(Mesh mesh, int lod, int count) { if (verboseLogging) { logger.log(Level.INFO, "renderMeshDefault({0}, {1}, {2})", new Object[]{mesh, lod, count}); } VertexBuffer indices = null; VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); if (interleavedData != null && interleavedData.isUpdateNeeded()) { updateBufferData(interleavedData); } //IntMap<VertexBuffer> buffers = mesh.getBuffers(); ; if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); } else { indices = mesh.getBuffer(Type.Index);// buffers.get(Type.Index.ordinal()); } SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList(); for (int i = 0; i < buffersList.size(); i++) { VertexBuffer vb = buffersList.get(i); if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { continue; } if (vb.getStride() == 0) { // not interleaved setVertexAttrib(vb); } else { // interleaved setVertexAttrib(vb, interleavedData); } } clearVertexAttribs(); // clearTextureUnits(); if (indices != null) { drawTriangleList(indices, mesh, count); } else { // throw new UnsupportedOperationException("Cannot render without index buffer"); if (verboseLogging) { logger.log(Level.INFO, "GLES20.glDrawArrays({0}, 0, {1})", new Object[]{convertElementMode(mesh.getMode()), mesh.getVertexCount()}); } Gdx.gl20.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount()); } }
Example 4
Source File: OGLESShaderRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void updateVertexArray(Mesh mesh) { logger.log(Level.INFO, "updateVertexArray({0})", mesh); int id = mesh.getId(); /* if (id == -1){ IntBuffer temp = intBuf1; // ARBVertexArrayObject.glGenVertexArrays(temp); GLES20.glGenVertexArrays(temp); id = temp.get(0); mesh.setId(id); } if (context.boundVertexArray != id){ // ARBVertexArrayObject.glBindVertexArray(id); GLES20.glBindVertexArray(id); context.boundVertexArray = id; } */ VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); if (interleavedData != null && interleavedData.isUpdateNeeded()) { updateBufferData(interleavedData); } SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList(); for (int i = 0; i < buffersList.size(); i++) { VertexBuffer vb = buffersList.get(i); if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { continue; } if (vb.getStride() == 0) { // not interleaved setVertexAttrib(vb); } else { // interleaved setVertexAttrib(vb, interleavedData); } } }
Example 5
Source File: OGLESShaderRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
private void renderMeshDefault(Mesh mesh, int lod, int count) { if (verboseLogging) { logger.log(Level.INFO, "renderMeshDefault({0}, {1}, {2})", new Object[]{mesh, lod, count}); } VertexBuffer indices = null; VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); if (interleavedData != null && interleavedData.isUpdateNeeded()) { updateBufferData(interleavedData); } //IntMap<VertexBuffer> buffers = mesh.getBuffers(); ; if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); } else { indices = mesh.getBuffer(Type.Index);// buffers.get(Type.Index.ordinal()); } SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList(); for (int i = 0; i < buffersList.size(); i++) { VertexBuffer vb = buffersList.get(i); if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { continue; } if (vb.getStride() == 0) { // not interleaved setVertexAttrib(vb); } else { // interleaved setVertexAttrib(vb, interleavedData); } } clearVertexAttribs(); // clearTextureUnits(); if (indices != null) { drawTriangleList(indices, mesh, count); } else { // throw new UnsupportedOperationException("Cannot render without index buffer"); if (verboseLogging) { logger.log(Level.INFO, "GLES20.glDrawArrays({0}, 0, {1})", new Object[]{convertElementMode(mesh.getMode()), mesh.getVertexCount()}); } GLES20.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount()); } }
Example 6
Source File: LwjglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
private void renderMeshDefault(Mesh mesh, int lod, int count) { VertexBuffer indices = null; VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); if (interleavedData != null && interleavedData.isUpdateNeeded()) { updateBufferData(interleavedData); } //IntMap<VertexBuffer> buffers = mesh.getBuffers(); SafeArrayList<VertexBuffer> buffersList = mesh.getBufferList(); if (mesh.getNumLodLevels() > 0) { indices = mesh.getLodLevel(lod); } else { indices = mesh.getBuffer(Type.Index); } //for (Entry<VertexBuffer> entry : buffers) { // VertexBuffer vb = entry.getValue(); for (int i = 0; i < buffersList.size(); i++){ VertexBuffer vb = buffersList.get(i); if (vb.getBufferType() == Type.InterleavedData || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getBufferType() == Type.Index) { continue; } if (vb.getStride() == 0) { // not interleaved setVertexAttrib(vb); } else { // interleaved setVertexAttrib(vb, interleavedData); } } if (indices != null) { drawTriangleList(indices, mesh, count); } else { drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount()); } clearVertexAttribs(); clearTextureUnits(); }