private final boolean prepareForInstancing(final Spatial spatial) { boolean skipRenderQueue = false; if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; final InstancingManager instancing = mesh.getMeshData().getInstancingManager(); // Only one instance needs to be added to the render queue if (instancing != null) { skipRenderQueue = instancing.isAddedToRenderQueue(); instancing.registerMesh(mesh); } } return skipRenderQueue; }
@Override public Mesh makeInstanced() { final Mesh mesh = (Mesh) super.makeInstanced(); if (_meshData.getInstancingManager() == null) { _meshData.setInstancingManager(new InstancingManager()); } mesh.setMeshData(_meshData); mesh.setModelBound(_modelBound != null ? _modelBound.clone(null) : null); mesh._defaultColor = _defaultColor; mesh.setVisible(_isVisible); return mesh; }
/** * Applies all instancing info to the mesh and returns if the current render call is allowed to continue * * @param mesh * @param renderer * @param shader * @return continue rendering or skip rendering all together */ public boolean apply(final Mesh mesh, final Renderer renderer, final GLSLShaderObjectsState shader) { final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); if (!caps.isGeometryInstancingSupported()) { throw new Ardor3dException("Geometry instancing not supported for current graphics configuration"); } if (_meshesToDraw <= 0) { // reset for next draw call _primCount = -1; shader.setUniform("nrOfInstances", -1); _visibleMeshes.clear(); return false; } shader.setUniform("transforms", fillTransformBuffer(), 4); shader.setUniform("nrOfInstances", getPrimitiveCount()); return true; }
while (instancing.apply(this, renderer, glsl)) { renderVBO(renderer, meshData, instancing.getPrimitiveCount()); } else { renderArrays(renderer, meshData, instancing.getPrimitiveCount(), caps);
@Override public Mesh makeInstanced() { final Mesh mesh = (Mesh) super.makeInstanced(); if (_meshData.getInstancingManager() == null) { _meshData.setInstancingManager(new InstancingManager()); } mesh.setMeshData(_meshData); mesh.setModelBound(_modelBound != null ? _modelBound.clone(null) : null); mesh.setVisible(_isVisible); return mesh; }
private final boolean prepareForInstancing(final Spatial spatial) { boolean skipRenderQueue = false; if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; final InstancingManager instancing = mesh.getMeshData().getInstancingManager(); // Only one instance needs to be added to the render queue if (instancing != null) { skipRenderQueue = instancing.isAddedToRenderQueue(); instancing.registerMesh(mesh); } } return skipRenderQueue; }