Search in sources :

Example 1 with LPTranslation

use of logisticspipes.proxy.object3d.operation.LPTranslation in project LogisticsPipes by RS485.

the class LogisticsNewSolidBlockWorldRenderer method computeRotated.

private static Map<BlockRotation, IModel3D> computeRotated(IModel3D m) {
    m.apply(new LPUVScale(1, 0.75));
    Map<BlockRotation, IModel3D> map = new HashMap<>();
    for (BlockRotation rot : BlockRotation.values()) {
        IModel3D model = m.copy();
        switch(rot.getInteger()) {
            case 0:
                model.apply(LPRotation.sideOrientation(0, 3));
                model.apply(new LPTranslation(0, 0, 1));
                break;
            case 1:
                model.apply(LPRotation.sideOrientation(0, 1));
                model.apply(new LPTranslation(1, 0, 0));
                break;
            case 2:
                break;
            case 3:
                model.apply(LPRotation.sideOrientation(0, 2));
                model.apply(new LPTranslation(1, 0, 1));
                break;
        }
        model.computeNormals();
        model.computeStandardLighting();
        map.put(rot, model);
    }
    return map;
}
Also used : LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LPUVScale(logisticspipes.proxy.object3d.operation.LPUVScale) HashMap(java.util.HashMap)

Example 2 with LPTranslation

use of logisticspipes.proxy.object3d.operation.LPTranslation in project LogisticsPipes by RS485.

the class LogisticsNewSolidBlockWorldRenderer method renderWorldBlock.

public void renderWorldBlock(IBlockAccess world, LogisticsSolidTileEntity blockTile, RenderBlocks renderer, int x, int y, int z) {
    Tessellator tess = Tessellator.instance;
    SimpleServiceLocator.cclProxy.getRenderState().reset();
    SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
    SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
    BlockRotation rotation = BlockRotation.ZERO;
    int brightness = 0;
    IIconTransformation icon;
    if (blockTile != null) {
        BlockRotation.getRotation(blockTile.getRotation());
        brightness = new DoubleCoordinates(blockTile).getBlock(world).getMixedBrightnessForBlock(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord));
    } else {
        brightness = LogisticsPipes.LogisticsSolidBlock.getMixedBrightnessForBlock(world, x, y, z);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, x, y, z));
    }
    tess.setColorOpaque_F(1F, 1F, 1F);
    tess.setBrightness(brightness);
    //Draw
    LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new LPTranslation(x, y, z), icon);
    if (blockTile != null) {
        DoubleCoordinates pos = new DoubleCoordinates(blockTile);
        for (CoverSides side : CoverSides.values()) {
            boolean render = true;
            DoubleCoordinates newPos = CoordinateUtils.sum(pos, side.getDir(rotation));
            TileEntity sideTile = newPos.getTileEntity(blockTile.getWorldObj());
            if (sideTile instanceof LogisticsTileGenericPipe) {
                LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) sideTile;
                if (tilePipe.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation).getOpposite())) {
                    render = false;
                }
            }
            if (render) {
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
            }
        }
    }
}
Also used : LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Tessellator(net.minecraft.client.renderer.Tessellator) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 3 with LPTranslation

use of logisticspipes.proxy.object3d.operation.LPTranslation in project LogisticsPipes by RS485.

the class CurveTubeRenderer method loadModels.

public static void loadModels() {
    try {
        Map<String, IModel3D> pipePartModels = SimpleServiceLocator.cclProxy.parseObjModels(LogisticsPipes.class.getResourceAsStream("/logisticspipes/models/HSTube-Turn_result.obj"), 7, new LPScale(1 / 100f));
        //tubeTurnMounts
        for (TurnDirection turn : TurnDirection.values()) {
            CurveTubeRenderer.tubeTurnBase.put(turn, new ArrayList<>());
        }
        pipePartModels.entrySet().stream().filter(entry -> entry.getKey().startsWith("Lane ") || entry.getKey().contains(" Lane ") || entry.getKey().endsWith(" Lane")).forEach(entry -> {
            CurveTubeRenderer.tubeTurnBase.get(TurnDirection.SOUTH_WEST).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(0.0, 0.0, 0.0)).apply(new LPRotation(-Math.PI / 2, 0, 1, 0))));
            CurveTubeRenderer.tubeTurnBase.get(TurnDirection.EAST_SOUTH).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(0.0, 0.0, 1.0))));
            CurveTubeRenderer.tubeTurnBase.get(TurnDirection.NORTH_EAST).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(-1.0, 0.0, 1.0)).apply(new LPRotation(Math.PI / 2, 0, 1, 0))));
            CurveTubeRenderer.tubeTurnBase.get(TurnDirection.WEST_NORTH).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(-1.0, 0.0, 0.0)).apply(new LPRotation(Math.PI, 0, 1, 0))));
        });
        if (CurveTubeRenderer.tubeTurnBase.get(TurnDirection.NORTH_EAST).size() != 4) {
            throw new RuntimeException("Couldn't load Tube Lanes. Only loaded " + CurveTubeRenderer.tubeTurnBase.get(TurnDirection.NORTH_EAST).size());
        }
        for (TurnDirection turn : TurnDirection.values()) {
            CurveTubeRenderer.tubeCurve.put(turn, SimpleServiceLocator.cclProxy.combine(CurveTubeRenderer.tubeTurnBase.get(turn)));
        }
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
Also used : LogisticsNewRenderPipe(logisticspipes.renderer.newpipe.LogisticsNewRenderPipe) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LogisticsPipes(logisticspipes.LogisticsPipes) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) HashMap(java.util.HashMap) LPUVTranslation(logisticspipes.proxy.object3d.operation.LPUVTranslation) LPUVTransformationList(logisticspipes.proxy.object3d.operation.LPUVTransformationList) ArrayList(java.util.ArrayList) LPRotation(logisticspipes.proxy.object3d.operation.LPRotation) Map(java.util.Map) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) ISpecialPipeRenderer(logisticspipes.renderer.newpipe.ISpecialPipeRenderer) I3DOperation(logisticspipes.proxy.object3d.interfaces.I3DOperation) LPColourMultiplier(logisticspipes.proxy.object3d.operation.LPColourMultiplier) HSTubeCurve(logisticspipes.pipes.tubes.HSTubeCurve) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) IHighlightPlacementRenderer(logisticspipes.renderer.newpipe.IHighlightPlacementRenderer) Collectors(java.util.stream.Collectors) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) RenderEntry(logisticspipes.renderer.newpipe.RenderEntry) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) ResourceLocation(net.minecraft.util.ResourceLocation) TurnDirection(logisticspipes.pipes.tubes.HSTubeCurve.TurnDirection) LPScale(logisticspipes.proxy.object3d.operation.LPScale) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LPRotation(logisticspipes.proxy.object3d.operation.LPRotation) TurnDirection(logisticspipes.pipes.tubes.HSTubeCurve.TurnDirection) LogisticsPipes(logisticspipes.LogisticsPipes) LPScale(logisticspipes.proxy.object3d.operation.LPScale)

Example 4 with LPTranslation

use of logisticspipes.proxy.object3d.operation.LPTranslation in project LogisticsPipes by RS485.

the class GainTubeRenderer method loadModels.

public static void loadModels() {
    try {
        Map<String, IModel3D> pipePartModels = SimpleServiceLocator.cclProxy.parseObjModels(LogisticsPipes.class.getResourceAsStream("/logisticspipes/models/HSTube-Gain_result.obj"), 7, new LPScale(1 / 100f));
        //tubeTurnMounts
        for (TubeGainRenderOrientation turn : TubeGainRenderOrientation.values()) {
            GainTubeRenderer.tubeTurnBase.put(turn, new ArrayList<>());
        }
        pipePartModels.entrySet().stream().filter(entry -> entry.getKey().startsWith("Lane ") || entry.getKey().contains(" Lane ") || entry.getKey().endsWith(" Lane")).forEach(entry -> {
            GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.EAST).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(0.0, 0.0, 0.0)).apply(new LPRotation(-Math.PI / 2, 0, 1, 0))));
            GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.NORTH).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(0.0, 0.0, 1.0))));
            GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.WEST).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(-1.0, 0.0, 1.0)).apply(new LPRotation(Math.PI / 2, 0, 1, 0))));
            GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.SOUTH).add(LogisticsNewRenderPipe.compute(entry.getValue().twoFacedCopy().apply(new LPTranslation(-1.0, 0.0, 0.0)).apply(new LPRotation(Math.PI, 0, 1, 0))));
        });
        if (GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.NORTH).size() != 4) {
            throw new RuntimeException("Couldn't load Tube Lanes. Only loaded " + GainTubeRenderer.tubeTurnBase.get(TubeGainRenderOrientation.NORTH).size());
        }
        for (TubeGainRenderOrientation turn : TubeGainRenderOrientation.values()) {
            GainTubeRenderer.tubeGain.put(turn, SimpleServiceLocator.cclProxy.combine(GainTubeRenderer.tubeTurnBase.get(turn)));
        }
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
Also used : LogisticsNewRenderPipe(logisticspipes.renderer.newpipe.LogisticsNewRenderPipe) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LogisticsPipes(logisticspipes.LogisticsPipes) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) HashMap(java.util.HashMap) LPUVTranslation(logisticspipes.proxy.object3d.operation.LPUVTranslation) LPUVTransformationList(logisticspipes.proxy.object3d.operation.LPUVTransformationList) ArrayList(java.util.ArrayList) LPRotation(logisticspipes.proxy.object3d.operation.LPRotation) Map(java.util.Map) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) IBounds(logisticspipes.proxy.object3d.interfaces.IBounds) ISpecialPipeRenderer(logisticspipes.renderer.newpipe.ISpecialPipeRenderer) I3DOperation(logisticspipes.proxy.object3d.interfaces.I3DOperation) LPColourMultiplier(logisticspipes.proxy.object3d.operation.LPColourMultiplier) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IHighlightPlacementRenderer(logisticspipes.renderer.newpipe.IHighlightPlacementRenderer) Collectors(java.util.stream.Collectors) TubeGainRenderOrientation(logisticspipes.pipes.tubes.HSTubeGain.TubeGainRenderOrientation) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) HSTubeGain(logisticspipes.pipes.tubes.HSTubeGain) RenderEntry(logisticspipes.renderer.newpipe.RenderEntry) Pair(logisticspipes.utils.tuples.Pair) ResourceLocation(net.minecraft.util.ResourceLocation) LPScale(logisticspipes.proxy.object3d.operation.LPScale) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LPRotation(logisticspipes.proxy.object3d.operation.LPRotation) LogisticsPipes(logisticspipes.LogisticsPipes) LPScale(logisticspipes.proxy.object3d.operation.LPScale) TubeGainRenderOrientation(logisticspipes.pipes.tubes.HSTubeGain.TubeGainRenderOrientation)

Example 5 with LPTranslation

use of logisticspipes.proxy.object3d.operation.LPTranslation in project LogisticsPipes by RS485.

the class LogisticsNewPipeWorldRenderer method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    Tessellator tess = Tessellator.instance;
    TileEntity tile = world.getTileEntity(x, y, z);
    LogisticsTileGenericPipe pipeTile = (LogisticsTileGenericPipe) tile;
    PipeRenderState renderState = pipeTile.renderState;
    if (pipeTile.pipe instanceof PipeBlockRequestTable) {
        if (LogisticsPipeWorldRenderer.renderPass != 0) {
            return false;
        }
        IIconProvider icons = pipeTile.getPipeIcons();
        if (icons == null) {
            return false;
        }
        if (requestBlock == null || true) {
            requestBlock = new HashMap<>();
            for (BlockRotation rot : BlockRotation.values()) {
                requestBlock.put(rot, LogisticsNewSolidBlockWorldRenderer.block.get(rot).copy().apply(new LPScale(0.999)).apply(new LPTranslation(0.0005, 0.0005, 0.0005)));
            }
        }
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
        SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
        BlockRotation rotation = BlockRotation.getRotation(((PipeBlockRequestTable) pipeTile.pipe).getRotation());
        int brightness = new DoubleCoordinates(x, y, z).getBlock(world).getMixedBrightnessForBlock(world, x, y, z);
        tess.setColorOpaque_F(1F, 1F, 1F);
        tess.setBrightness(brightness);
        IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
        requestBlock.get(rotation).render(new LPTranslation(x, y, z), icon);
        for (CoverSides side : CoverSides.values()) {
            if (!pipeTile.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation))) {
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
            }
        }
        return true;
    }
    boolean hasRendered = false;
    tess.addTranslation(0.00002F, 0.00002F, 0.00002F);
    renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (pipeTile.tilePart.hasPipePluggable(dir)) {
            IBCPipePluggable p = pipeTile.tilePart.getBCPipePluggable(dir);
            p.renderPluggable(renderer, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
            hasRendered = true;
        }
    }
    tess.addTranslation(-0.00002F, -0.00002F, -0.00002F);
    boolean[] solidSides = new boolean[6];
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
        Block blockSide = pos.getBlock(pipeTile.getWorldObj());
        if (blockSide != null && blockSide.isSideSolid(pipeTile.getWorldObj(), pos.getXInt(), pos.getYInt(), pos.getZInt(), dir.getOpposite()) && !renderState.pipeConnectionMatrix.isConnected(dir)) {
            solidSides[dir.ordinal()] = true;
        }
    }
    if (!Arrays.equals(solidSides, renderState.solidSidesCache)) {
        renderState.solidSidesCache = solidSides.clone();
        renderState.cachedRenderer = null;
    }
    if (hasRendered) {
        block.setBlockBounds(0, 0, 0, 0, 0, 0);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);
        block.setBlockBounds(0, 0, 0, 1, 1, 1);
    }
    return hasRendered;
}
Also used : PipeRenderState(logisticspipes.renderer.state.PipeRenderState) Tessellator(net.minecraft.client.renderer.Tessellator) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) IIconProvider(logisticspipes.renderer.IIconProvider) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) TileEntity(net.minecraft.tileentity.TileEntity) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) CoverSides(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IBCPipePluggable(logisticspipes.proxy.buildcraft.subproxies.IBCPipePluggable) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) Block(net.minecraft.block.Block) LPScale(logisticspipes.proxy.object3d.operation.LPScale) BlockRotation(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)

Aggregations

LPTranslation (logisticspipes.proxy.object3d.operation.LPTranslation)7 IModel3D (logisticspipes.proxy.object3d.interfaces.IModel3D)5 LPScale (logisticspipes.proxy.object3d.operation.LPScale)5 HashMap (java.util.HashMap)4 LogisticsPipes (logisticspipes.LogisticsPipes)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 ITubeOrientation (logisticspipes.interfaces.ITubeOrientation)3 CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)3 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)3 I3DOperation (logisticspipes.proxy.object3d.interfaces.I3DOperation)3 LPColourMultiplier (logisticspipes.proxy.object3d.operation.LPColourMultiplier)3 LPRotation (logisticspipes.proxy.object3d.operation.LPRotation)3 LPUVTransformationList (logisticspipes.proxy.object3d.operation.LPUVTransformationList)3 LPUVTranslation (logisticspipes.proxy.object3d.operation.LPUVTranslation)3 IHighlightPlacementRenderer (logisticspipes.renderer.newpipe.IHighlightPlacementRenderer)3 ISpecialPipeRenderer (logisticspipes.renderer.newpipe.ISpecialPipeRenderer)3 LogisticsNewRenderPipe (logisticspipes.renderer.newpipe.LogisticsNewRenderPipe)3