use of org.terasology.world.block.shapes.BlockMeshPart in project Terasology by MovingBlocks.
the class BlockMeshGeneratorSingleShape method generateMesh.
private void generateMesh() {
Tessellator tessellator = new Tessellator();
for (BlockPart dir : BlockPart.values()) {
BlockMeshPart part = block.getPrimaryAppearance().getPart(dir);
if (part != null) {
if (block.isDoubleSided()) {
tessellator.addMeshPartDoubleSided(part);
} else {
tessellator.addMeshPart(part);
}
}
}
mesh = tessellator.generateMesh(new ResourceUrn("engine", "blockmesh", block.getURI().toString()));
}
use of org.terasology.world.block.shapes.BlockMeshPart in project Terasology by MovingBlocks.
the class BlockBuilder method createAppearance.
private BlockAppearance createAppearance(BlockShape shape, Map<BlockPart, BlockTile> tiles, Rotation rot) {
Map<BlockPart, BlockMeshPart> meshParts = Maps.newEnumMap(BlockPart.class);
Map<BlockPart, Vector2f> textureAtlasPositions = Maps.newEnumMap(BlockPart.class);
for (BlockPart part : BlockPart.values()) {
// TODO: Need to be more sensible with the texture atlas. Because things like block particles read from a part that may not exist, we're being fairly lenient
Vector2f atlasPos;
if (tiles.get(part) == null) {
atlasPos = new Vector2f();
} else {
atlasPos = worldAtlas.getTexCoords(tiles.get(part), shape.getMeshPart(part) != null);
}
BlockPart targetPart = part.rotate(rot);
textureAtlasPositions.put(targetPart, atlasPos);
if (shape.getMeshPart(part) != null) {
meshParts.put(targetPart, shape.getMeshPart(part).rotate(rot.getQuat4f()).mapTexCoords(atlasPos, worldAtlas.getRelativeTileSize()));
}
}
return new BlockAppearance(meshParts, textureAtlasPositions);
}
use of org.terasology.world.block.shapes.BlockMeshPart in project Terasology by MovingBlocks.
the class BlockBuilder method applyLoweredShape.
private void applyLoweredShape(Block block, BlockShape shape, Map<BlockPart, BlockTile> tiles) {
for (Side side : Side.values()) {
BlockPart part = BlockPart.fromSide(side);
BlockTile blockTile = tiles.get(part);
if (blockTile != null) {
BlockMeshPart meshPart = shape.getMeshPart(part).rotate(Rotation.none().getQuat4f()).mapTexCoords(worldAtlas.getTexCoords(blockTile, true), worldAtlas.getRelativeTileSize());
block.setLoweredLiquidMesh(part.getSide(), meshPart);
}
}
}
Aggregations