mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-16 06:35:35 +00:00
conduit rendering helper crap
This commit is contained in:
parent
a1008db304
commit
fc714dd6c8
@ -2394,9 +2394,9 @@ public class ModBlocks {
|
||||
|
||||
logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block");
|
||||
|
||||
conduit_straight = new BlockConduitStraight().setBlockName("conduit_straight").setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
conduit_bend = new BlockConduitBend().setBlockName("conduit_bend").setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
conduit_switch = new BlockConduitSwitch().setBlockName("conduit_switch").setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
conduit_straight = new BlockConduitStraight().setBlockName("conduit_straight").setBlockTextureName(RefStrings.MODID + ":rail_standard");
|
||||
conduit_bend = new BlockConduitBend().setBlockName("conduit_bend").setBlockTextureName(RefStrings.MODID + ":rail_standard");
|
||||
conduit_switch = new BlockConduitSwitch().setBlockName("conduit_switch").setBlockTextureName(RefStrings.MODID + ":rail_standard");
|
||||
}
|
||||
|
||||
private static void registerBlock() {
|
||||
|
||||
57
src/main/java/com/hbm/hrist/BlockConduitBase.java
Normal file
57
src/main/java/com/hbm/hrist/BlockConduitBase.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.render.block.ISBRHUniversal;
|
||||
import com.hbm.render.util.RenderBlocksNT;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
//you can think of it like a pipeline
|
||||
public abstract class BlockConduitBase extends BlockDummyable implements ISBRHUniversal {
|
||||
|
||||
public BlockConduitBase() {
|
||||
super(Material.ground);
|
||||
}
|
||||
|
||||
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
|
||||
@Override public int getRenderType() { return ISBRHUniversal.renderID; }
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
|
||||
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
|
||||
super.breakBlock(world, x, y, z, b, meta);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract ConduitPiece getPiece(World world, int x, int y, int z, int meta);
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
RenderBlocks renderer = (RenderBlocks) renderBlocks;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, 1); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@ -1,51 +1,19 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
// you can think of it like a pipeline
|
||||
public class BlockConduitBend extends BlockDummyable {
|
||||
public class BlockConduitBend extends BlockConduitBase {
|
||||
|
||||
public BlockConduitBend() {
|
||||
super(Material.ground);
|
||||
}
|
||||
|
||||
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
|
||||
@Override public int[] getDimensions() { return new int[] {0, 0, 4, 0, 4, 0}; }
|
||||
@Override public int getOffset() { return 0; }
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
|
||||
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
|
||||
super.breakBlock(world, x, y, z, b, meta);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
@ -59,8 +27,7 @@ public class BlockConduitBend extends BlockDummyable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,51 +1,20 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
// you can think of it like a pipeline
|
||||
public class BlockConduitStraight extends BlockDummyable {
|
||||
|
||||
public BlockConduitStraight() {
|
||||
super(Material.ground);
|
||||
}
|
||||
|
||||
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
|
||||
public class BlockConduitStraight extends BlockConduitBase {
|
||||
|
||||
@Override public int[] getDimensions() { return new int[] {0, 0, 2, 2, 1, 0}; }
|
||||
@Override public int getOffset() { return 2; }
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
|
||||
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
|
||||
super.breakBlock(world, x, y, z, b, meta);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
@ -56,11 +25,30 @@ public class BlockConduitStraight extends BlockDummyable {
|
||||
x + 0.5 + rot.offsetX * 0.5 - dir.offsetX * 2.5, y,
|
||||
z + 0.5 + rot.offsetZ * 0.5 - dir.offsetZ * 2.5, dir.getOpposite());
|
||||
return new ConduitPiece(new ConnectionDefinition(d0, d1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 12) {
|
||||
double angle = 0;
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
if(dir == ForgeDirection.NORTH) angle += 0;
|
||||
if(dir == ForgeDirection.WEST) angle += 90;
|
||||
if(dir == ForgeDirection.SOUTH) angle += 180;
|
||||
if(dir == ForgeDirection.EAST) angle += 270;
|
||||
|
||||
for(int i = -2; i <= 2; i++)
|
||||
ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, x + 0.5 + dir.offsetX * i + rot.offsetX * 0.5, y, z + 0.5 + dir.offsetZ * i + rot.offsetZ * 0.5, angle);
|
||||
|
||||
ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon,
|
||||
x + 0.5 - dir.offsetX * 2.5 - rot.offsetX * 0.28125, y, z + 0.5 - dir.offsetZ * 2.5 - rot.offsetZ * 0.28125, angle,
|
||||
x + 0.5 + dir.offsetX * 2.5 - rot.offsetX * 0.28125, y, z + 0.5 + dir.offsetZ * 2.5 - rot.offsetZ * 0.28125, angle);
|
||||
ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon,
|
||||
x + 0.5 - dir.offsetX * 2.5 - rot.offsetX * -1.21875, y, z + 0.5 - dir.offsetZ * 2.5 - rot.offsetZ * -1.21875, angle,
|
||||
x + 0.5 + dir.offsetX * 2.5 - rot.offsetX * -1.21875, y, z + 0.5 + dir.offsetZ * 2.5 - rot.offsetZ * -1.21875, angle);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,50 +1,19 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockConduitSwitch extends BlockDummyable {
|
||||
public class BlockConduitSwitch extends BlockConduitBase {
|
||||
|
||||
public BlockConduitSwitch() {
|
||||
super(Material.ground);
|
||||
}
|
||||
|
||||
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
|
||||
@Override public int[] getDimensions() { return new int[] {0, 0, 4, 0, 4, 3}; }
|
||||
@Override public int getOffset() { return 0; }
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
|
||||
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
|
||||
super.breakBlock(world, x, y, z, b, meta);
|
||||
|
||||
if(meta >= 12) {
|
||||
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
@ -64,8 +33,7 @@ public class BlockConduitSwitch extends BlockDummyable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
172
src/main/java/com/hbm/hrist/ConduitRenderUtil.java
Normal file
172
src/main/java/com/hbm/hrist/ConduitRenderUtil.java
Normal file
@ -0,0 +1,172 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.util.Vec3NT;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
@NotableComments
|
||||
public class ConduitRenderUtil {
|
||||
|
||||
// public cum rags
|
||||
private static Vec3NT vec = new Vec3NT(0, 0, 0);
|
||||
private static double[][] v = new double[4][3];
|
||||
|
||||
public static void renderSupport(Tessellator tess, IIcon icon, double x, double y, double z, double rotation) {
|
||||
double minU = icon.getMinU();
|
||||
double minV = icon.getMinV();
|
||||
double pu = (icon.getMaxU() - icon.getMinU()) / 32D;
|
||||
double pv = (icon.getMaxV() - icon.getMinV()) / 32D;
|
||||
|
||||
// work smort, not hort
|
||||
vec.setTurn(01, 0, 00.1875, rotation).add(x, y, z).copyToArray(v[0]);
|
||||
vec.setTurn(01, 0, -0.1875, rotation).add(x, y, z).copyToArray(v[1]);
|
||||
vec.setTurn(-1, 0, -0.1875, rotation).add(x, y, z).copyToArray(v[2]);
|
||||
vec.setTurn(-1, 0, 00.1875, rotation).add(x, y, z).copyToArray(v[3]);
|
||||
|
||||
setBrightnessFromNormals(tess, 0F, 1F, 0F);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 0, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 6, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 00);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 0, minV + pv * 00);
|
||||
|
||||
setBrightnessFromNormals(tess, 0F, -1F, 0F);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1], v[1][2], minU + pu * 0, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1], v[0][2], minU + pu * 6, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1], v[3][2], minU + pu * 6, minV + pv * 00);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1], v[2][2], minU + pu * 0, minV + pv * 00);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 0, minV + pv * 0);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 6, minV + pv * 0);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 000000, v[0][2], minU + pu * 6, minV + pv * 1);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 000000, v[1][2], minU + pu * 0, minV + pv * 1);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 180).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 0, minV + pv * 0);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 0);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 000000, v[2][2], minU + pu * 6, minV + pv * 1);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 000000, v[3][2], minU + pu * 0, minV + pv * 1);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 90).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 00);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 6, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 000000, v[1][2], minU + pu * 7, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 000000, v[2][2], minU + pu * 7, minV + pv * 00);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 270).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 6, minV + pv * 00);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 6, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 000000, v[3][2], minU + pu * 7, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 000000, v[0][2], minU + pu * 7, minV + pv * 00);
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
vec.setTurn(0.9375 - i * 1.5625, 0, 00.0625, rotation).add(x, y, z).copyToArray(v[0]);
|
||||
vec.setTurn(0.9375 - i * 1.5625, 0, -0.0625, rotation).add(x, y, z).copyToArray(v[1]);
|
||||
vec.setTurn(0.6250 - i * 1.5625, 0, -0.0625, rotation).add(x, y, z).copyToArray(v[2]);
|
||||
vec.setTurn(0.6250 - i * 1.5625, 0, 00.0625, rotation).add(x, y, z).copyToArray(v[3]);
|
||||
|
||||
setBrightnessFromNormals(tess, 0F, 1F, 0F);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.125, v[0][2], minU + pu * 19, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.125, v[1][2], minU + pu * 19, minV + pv * 29);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.125, v[2][2], minU + pu * 14, minV + pv * 29);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.125, v[3][2], minU + pu * 14, minV + pv * 31);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1250, v[1][2], minU + pu * 14, minV + pv * 29);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1250, v[0][2], minU + pu * 14, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 13, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 13, minV + pv * 29);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 180).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1250, v[3][2], minU + pu * 14, minV + pv * 29);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1250, v[2][2], minU + pu * 14, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 13, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 13, minV + pv * 29);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 90).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1250, v[2][2], minU + pu * 14, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1250, v[1][2], minU + pu * 19, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 19, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 14, minV + pv * 32);
|
||||
|
||||
vec.setTurn(1, 0, 0, rotation + 270).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1250, v[0][2], minU + pu * 14, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1250, v[3][2], minU + pu * 19, minV + pv * 31);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 19, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 14, minV + pv * 32);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderSteel(Tessellator tess, IIcon icon, double x0, double y0, double z0, double r0, double x1, double y1, double z1, double r1) {
|
||||
double minU = icon.getMinU();
|
||||
double minV = icon.getMinV();
|
||||
double pu = (icon.getMaxU() - icon.getMinU()) / 32D;
|
||||
double pv = (icon.getMaxV() - icon.getMinV()) / 32D;
|
||||
|
||||
double avg = (r0 + r1) / 2;
|
||||
|
||||
vec.setTurn(-0.03125, 0, 0, r0).add(x0, y0, z0).copyToArray(v[0]);
|
||||
vec.setTurn(00.03125, 0, 0, r0).add(x0, y0, z0).copyToArray(v[1]);
|
||||
vec.setTurn(00.03125, 0, 0, r1).add(x1, y1, z1).copyToArray(v[2]);
|
||||
vec.setTurn(-0.03125, 0, 0, r1).add(x1, y1, z1).copyToArray(v[3]);
|
||||
|
||||
setBrightnessFromNormals(tess, 0F, 1F, 0F);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 10, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 11, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 11, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 10, minV + pv * 16);
|
||||
|
||||
setBrightnessFromNormals(tess, 0F, -1F, 0F);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 7, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 8, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 8, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 7, minV + pv * 16);
|
||||
|
||||
vec.setTurn(1, 0, 0, avg).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 10, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 11, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 11, minV + pv * 14);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 10, minV + pv * 14);
|
||||
|
||||
vec.setTurn(1, 0, 0, avg + 180).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 10, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 11, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 11, minV + pv * 14);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 10, minV + pv * 14);
|
||||
|
||||
vec.setTurn(1, 0, 0, avg + 90).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 10, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 10, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 8, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 8, minV + pv * 16);
|
||||
|
||||
vec.setTurn(1, 0, 0, avg + 270).normalizeSelf();
|
||||
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 11, minV + pv * 16);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 11, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 13, minV + pv * 32);
|
||||
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 13, minV + pv * 16);
|
||||
}
|
||||
|
||||
public static void setBrightnessFromNormals(Tessellator tess, double x, double y, double z) {
|
||||
|
||||
float brightness = ((float) y + 0.7F) * 0.9F - (float) Math.abs(x) * 0.1F + (float) Math.abs(z) * 0.1F;
|
||||
if(brightness < 0.45F) brightness = 0.45F;
|
||||
|
||||
tess.setNormal((float) x, (float) y, (float) z);
|
||||
tess.setColorOpaque_F(brightness, brightness, brightness);
|
||||
}
|
||||
}
|
||||
@ -64,6 +64,18 @@ public class Vec3NT extends Vec3 {
|
||||
this.zCoord = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets components, then rotates around the Y axis (in degrees) */
|
||||
public Vec3NT setTurn(double x, double y, double z, double rot) {
|
||||
return this.setComponents(x, y, z).rotateAroundYDeg(rot);
|
||||
}
|
||||
|
||||
/** Does what it says, i.e. requires a double array with a length of at least 3 and copies the components into the first three fields */
|
||||
public void copyToArray(double[] array) {
|
||||
array[0] = this.xCoord;
|
||||
array[1] = this.yCoord;
|
||||
array[2] = this.zCoord;
|
||||
}
|
||||
|
||||
public Vec3NT rotateAroundXRad(double alpha) {
|
||||
double cos = Math.cos(alpha);
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/rail_standard.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/rail_standard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
Loading…
x
Reference in New Issue
Block a user