@Override public boolean step() { if (blockFamilyIterator.hasNext()) { BlockFamily family = blockFamilyIterator.next(); family.getArchetypeBlock().getMeshGenerator(); stepDone(); } return !blockFamilyIterator.hasNext(); }
public ChunkMesh generateMesh(ChunkView chunkView, int meshHeight, int verticalOffset) { PerformanceMonitor.startActivity("GenerateMesh"); ChunkMesh mesh = new ChunkMesh(bufferPool); final Stopwatch watch = Stopwatch.createStarted(); for (int x = 0; x < ChunkConstants.SIZE_X; x++) { for (int z = 0; z < ChunkConstants.SIZE_Z; z++) { for (int y = verticalOffset; y < verticalOffset + meshHeight; y++) { Block block = chunkView.getBlock(x, y, z); if (block != null && block.getMeshGenerator() != null) { block.getMeshGenerator().generateChunkMesh(chunkView, mesh, x, y, z); } } } } watch.stop(); mesh.setTimeToGenerateBlockVertices((int) watch.elapsed(TimeUnit.MILLISECONDS)); watch.reset().start(); generateOptimizedBuffers(chunkView, mesh); watch.stop(); mesh.setTimeToGenerateOptimizedBuffers((int) watch.elapsed(TimeUnit.MILLISECONDS)); statVertexArrayUpdateCount++; PerformanceMonitor.endActivity(); return mesh; }
@Override public Mesh get() { BlockItemComponent blockItemComp = getItem().getComponent(BlockItemComponent.class); if (blockItemComp != null && blockItemComp.blockFamily != null) { return blockItemComp.blockFamily.getArchetypeBlock().getMeshGenerator().getStandaloneMesh(); } return null; } });
@Override public Mesh get() { BlockItemComponent blockItemComp = getTargetItem().getComponent(BlockItemComponent.class); if (blockItemComp != null && blockItemComp.blockFamily != null) { return blockItemComp.blockFamily.getArchetypeBlock().getMeshGenerator().getStandaloneMesh(); } return null; } });
/** * Returns true if the side should be rendered adjacent to the second side provided. * * @param blockToCheck The block to check * @param currentBlock The current block * @return True if the side is visible for the given block types */ private boolean isSideVisibleForBlockTypes(Block blockToCheck, Block currentBlock, Side side) { // Liquids can be transparent but there should be no visible adjacent faces if (currentBlock.isLiquid() && blockToCheck.isLiquid()) { return false; } return currentBlock.isWaving() != blockToCheck.isWaving() || blockToCheck.getMeshGenerator() == null || !blockToCheck.isFullSide(side.reverse()) || (!currentBlock.isTranslucent() && blockToCheck.isTranslucent()); }
public static void addOrUpdateBlockMeshComponent(BlockItemComponent blockItemComponent, MutableComponentContainer entity) { if (blockItemComponent != null) { MeshComponent meshComponent = null; if (entity.hasComponent(MeshComponent.class)) { meshComponent = entity.getComponent(MeshComponent.class); } else { meshComponent = new MeshComponent(); } BlockFamily blockFamily = blockItemComponent.blockFamily; if (blockFamily == null) { return; } meshComponent.mesh = blockFamily.getArchetypeBlock().getMeshGenerator().getStandaloneMesh(); meshComponent.material = Assets.getMaterial("engine:terrain").get(); meshComponent.translucent = blockFamily.getArchetypeBlock().isTranslucent(); float luminance = blockFamily.getArchetypeBlock().getLuminance() / 15f; meshComponent.selfLuminance = luminance; if (luminance > 0 && !entity.hasComponent(LightComponent.class)) { LightComponent lightComponent = entity.addComponent(new LightComponent()); //scale the light back if it is a less bright block lightComponent.lightAttenuationRange *= luminance; } entity.addOrSaveComponent(meshComponent); } } }