Glow panels.

This commit is contained in:
Ben Spiers 2014-04-13 03:05:50 +01:00
parent b3939c0b52
commit 3dd06cca78
11 changed files with 495 additions and 2 deletions

View file

@ -44,6 +44,7 @@ import mekanism.client.gui.GuiSeismicReader;
import mekanism.client.gui.GuiSeismicVibrator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.RenderGlowPanel;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.client.render.RenderTickHandler;
import mekanism.client.render.block.BasicRenderingHandler;
@ -324,6 +325,7 @@ public class ClientProxy extends CommonProxy
public void registerRenderInformation()
{
RenderPartTransmitter.init();
RenderGlowPanel.init();
//Register entity rendering handlers
RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNTPrimed());

View file

@ -0,0 +1,136 @@
package mekanism.client.render;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.client.model.ModelTransporterBox;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.multipart.PartDiversionTransporter;
import mekanism.common.multipart.PartGlowPanel;
import mekanism.common.multipart.PartLogisticalTransporter;
import mekanism.common.multipart.PartMechanicalPipe;
import mekanism.common.multipart.PartPressurizedTube;
import mekanism.common.multipart.PartSidedPipe;
import mekanism.common.multipart.PartSidedPipe.ConnectionType;
import mekanism.common.multipart.PartTransmitter;
import mekanism.common.multipart.PartUniversalCable;
import mekanism.common.multipart.TransmitterType;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import org.lwjgl.opengl.GL11;
import codechicken.lib.colour.Colour;
import codechicken.lib.colour.ColourRGBA;
import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.lighting.LightMatrix;
import codechicken.lib.lighting.LightModel;
import codechicken.lib.lighting.LightModel.Light;
import codechicken.lib.render.CCModel;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.ColourMultiplier;
import codechicken.lib.render.IVertexModifier;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.TextureUtils;
import codechicken.lib.render.TextureUtils.IIconRegister;
import codechicken.lib.render.UV;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Transformation;
import codechicken.lib.vec.Translation;
import codechicken.lib.vec.Vector3;
public class RenderGlowPanel implements IIconRegister
{
public static RenderGlowPanel INSTANCE;
public static CCModel[] frameModels;
public static CCModel[] lightModels;
public static Icon icon;
public static RenderGlowPanel getInstance()
{
return INSTANCE;
}
public static void init()
{
INSTANCE = new RenderGlowPanel();
TextureUtils.addIconRegistrar(INSTANCE);
Map<String, CCModel> models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "glow_panel.obj"), 7, null);
frameModels = new CCModel[6];
frameModels[0] = models.get("frame");
CCModel.generateSidedModels(frameModels, 0, new Vector3(0, 0, 0));
lightModels = new CCModel[6];
lightModels[0] = models.get("light");
CCModel.generateSidedModels(lightModels, 0, new Vector3(0, 0, 0));
for(CCModel c : frameModels)
{
c.apply(new Translation(.5, .5, .5));
c.computeLighting(LightModel.standardLightModel);
c.shrinkUVs(0.0005);
}
for(CCModel c : lightModels)
{
c.apply(new Translation(.5, .5, .5));
c.computeLighting(LightModel.standardLightModel);
c.shrinkUVs(0.0005);
}
}
public void renderStatic(PartGlowPanel panel, LazyLightMatrix olm)
{
TextureUtils.bindAtlas(0);
CCRenderState.reset();
CCRenderState.useModelColours(true);
CCRenderState.setBrightness(panel.world(), panel.x(), panel.y(), panel.z());
Colour colour = new ColourRGBA(panel.colour.getColor(0), panel.colour.getColor(1), panel.colour.getColor(2), 1);
int side = panel.side.ordinal();
frameModels[side].render(0, frameModels[side].verts.length, new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon), null);
lightModels[side].render(0, lightModels[side].verts.length, new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon), new ColourMultiplier(colour));
}
@Override
public void registerIcons(IconRegister register)
{
icon = register.registerIcon("mekanism:models/GlowPanel");
}
@Override
public int atlasIndex()
{
return 0;
}
}

View file

@ -88,6 +88,7 @@ import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemSeismicReader;
import mekanism.common.item.ItemShard;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemGlowPanel;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.multipart.MultipartMekanism;
import mekanism.common.network.PacketBoxBlacklist;
@ -268,6 +269,7 @@ public class Mekanism
public static Item WalkieTalkie;
public static Item ItemProxy;
public static Item PartTransmitter;
public static Item GlowPanel;
public static ItemJetpack Jetpack;
public static ItemScubaTank ScubaTank;
public static ItemGasMask GasMask;
@ -917,6 +919,7 @@ public class Mekanism
Substrate = new ItemMekanism(configuration.getItem("Substrate", ITEM_ID++).getInt()).setUnlocalizedName("Substrate");
Polyethene = new ItemHDPE(configuration.getItem("HDPE", ITEM_ID++).getInt()).setUnlocalizedName("HDPE");
BioFuel = new ItemMekanism(Mekanism.configuration.getItem("BioFuel", ITEM_ID++).getInt()).setUnlocalizedName("BioFuel");
GlowPanel = new ItemGlowPanel(configuration.getItem("GlowPanel", ITEM_ID++).getInt()).setUnlocalizedName("GlowPanel");
configuration.save();

View file

@ -0,0 +1,90 @@
package mekanism.common.multipart;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.common.Mekanism;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.TMultiPart;
public class ItemGlowPanel extends JItemMultiPart
{
public ItemGlowPanel(int id)
{
super(id);
setHasSubtypes(true);
setCreativeTab(Mekanism.tabMekanism);
}
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vHit)
{
EnumColor col = EnumColor.DYES[item.getItemDamage()];
ForgeDirection orientation = getSideFromVector3(vHit.subtract(Vector3.center));
return new PartGlowPanel(col, orientation);
}
public ForgeDirection getSideFromVector3(Vector3 vector)
{
if(Math.abs(vector.x) > Math.abs(vector.y) && Math.abs(vector.x) > Math.abs(vector.z))
{
if((vector.x < 0.5 &&vector.x > 0) || vector.x == -0.5)
{
return ForgeDirection.EAST;
}
return ForgeDirection.WEST;
}
else if(Math.abs(vector.y) > Math.abs(vector.x) && Math.abs(vector.y) > Math.abs(vector.z))
{
if((vector.y < 0.5 &&vector.y > 0) || vector.y == -0.5)
{
return ForgeDirection.UP;
}
return ForgeDirection.DOWN;
}
else if(Math.abs(vector.z) > Math.abs(vector.x) && Math.abs(vector.z) > Math.abs(vector.y))
{
if((vector.z < 0.5 &&vector.z > 0) || vector.z == -0.5)
{
return ForgeDirection.SOUTH;
}
return ForgeDirection.NORTH;
}
return null;
}
@Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
{
for(EnumColor color : EnumColor.DYES)
{
listToAddTo.add(new ItemStack(itemID, 1, color.getMetaValue()));
}
}
@Override
public String getItemDisplayName(ItemStack stack)
{
EnumColor colour = EnumColor.DYES[stack.getItemDamage()];
String colourName;
if(colour == EnumColor.BLACK)
{
colourName = EnumColor.DARK_GREY + colour.getDyeName();
}
else {
colourName = colour.getDyedName();
}
return colourName + " " + super.getItemDisplayName(stack);
}
}

View file

@ -22,7 +22,8 @@ public class MultipartMekanism implements IPartFactory
"mekanism:mechanical_pipe_basic", "mekanism:mechanical_pipe_advanced",
"mekanism:mechanical_pipe_elite", "mekanism:mechanical_pipe_ultimate",
"mekanism:pressurized_tube", "mekanism:logistical_transporter",
"mekanism:restrictive_transporter", "mekanism:diversion_transporter"});
"mekanism:restrictive_transporter", "mekanism:diversion_transporter",
"mekanism:glow_panel"});
MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitter");
MultipartGenerator.registerPassThroughInterface("mekanism.api.energy.IStrictEnergyAcceptor");
@ -95,6 +96,10 @@ public class MultipartMekanism implements IPartFactory
{
return new PartDiversionTransporter();
}
else if(name.equals("mekanism:glow_panel"))
{
return new PartGlowPanel();
}
return null;
}

View file

@ -0,0 +1,185 @@
package mekanism.common.multipart;
import java.util.Collections;
import mekanism.api.EnumColor;
import mekanism.client.render.RenderGlowPanel;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.Mekanism;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Translation;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.ISidedHollowConnect;
import codechicken.multipart.IconHitEffects;
import codechicken.multipart.JCuboidPart;
import codechicken.multipart.JIconHitEffects;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.NormalOcclusionTest;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
public class PartGlowPanel extends JCuboidPart implements JNormalOcclusion, JIconHitEffects
{
public EnumColor colour = EnumColor.WHITE;
public ForgeDirection side = ForgeDirection.DOWN;
public static Cuboid6[] bounds = new Cuboid6[6];
static
{
Cuboid6 cuboid = new Cuboid6(0.25, 0, 0.25, 0.75, 0.125, 0.75);
Translation fromOrigin = new Translation(Vector3.center);
Translation toOrigin = (Translation) fromOrigin.inverse();
for(int i=0; i < 6; i++)
{
bounds[i] = cuboid.copy().apply(toOrigin).apply(Rotation.sideRotations[i]).apply(fromOrigin);
}
}
public PartGlowPanel()
{
super();
}
public PartGlowPanel(EnumColor colour, ForgeDirection side)
{
super();
setColour(colour);
setOrientation(side);
}
@Override
public Cuboid6 getBounds()
{
return bounds[side.ordinal()];
}
@Override
public String getType()
{
return "mekanism:glow_panel";
}
public void setColour(EnumColor newColour)
{
colour = newColour;
}
public void setOrientation(ForgeDirection newSide)
{
side = newSide;
}
@Override
public void writeDesc(MCDataOutput data)
{
data.writeInt(side.ordinal());
data.writeInt(colour.getMetaValue());
}
@Override
public void readDesc(MCDataInput data)
{
side = ForgeDirection.getOrientation(data.readInt());
colour = EnumColor.DYES[data.readInt()];
}
@Override
public void save(NBTTagCompound nbt)
{
nbt.setInteger("side", side.ordinal());
nbt.setInteger("colour", colour.getMetaValue());
}
@Override
public void load(NBTTagCompound nbt)
{
side = ForgeDirection.getOrientation(nbt.getInteger("side"));
colour = EnumColor.DYES[nbt.getInteger("colour")];
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(Vector3 pos, LazyLightMatrix olm, int pass)
{
if(pass == 1)
{
RenderGlowPanel.getInstance().renderStatic(this, olm);
}
}
@Override
public int getLightValue()
{
return 15;
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes()
{
return getCollisionBoxes();
}
@Override
public boolean occlusionTest(TMultiPart other)
{
return NormalOcclusionTest.apply(this, other);
}
@Override
public Icon getBreakingIcon(Object subPart, int side)
{
return RenderGlowPanel.icon;
}
@Override
public Icon getBrokenIcon(int side)
{
return RenderGlowPanel.icon;
}
@Override
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer)
{
IconHitEffects.addHitEffects(this, hit, effectRenderer);
}
@Override
public void addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer)
{
IconHitEffects.addDestroyEffects(this, effectRenderer, false);
}
@Override
public Iterable<ItemStack> getDrops()
{
return Collections.singletonList(pickItem(null));
}
@Override
public ItemStack pickItem(MovingObjectPosition hit)
{
return new ItemStack(Mekanism.GlowPanel, 1, colour.getMetaValue());
}
@Override
public boolean doesTick()
{
return false;
}
}

View file

@ -327,7 +327,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
}
@Override
public void addDestroyEffects(EffectRenderer effectRenderer)
public void addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer)
{
IconHitEffects.addDestroyEffects(this, effectRenderer, false);
}

View file

@ -107,6 +107,8 @@ tile.PlasticBlock.SlickPlasticBlock.name=Slick Plastic Block
tile.PlasticBlock.GlowPlasticBlock.name=Plastic Glow Block
tile.PlasticBlock.ReinforcedPlasticBlock.name=Reinforced Plastic Block
tile.PlasticFence.name=Plastic Barrier
//Infuse types
infuse.carbon=Carbon
infuse.tin=Tin

Binary file not shown.

View file

@ -0,0 +1,70 @@
# Blender v2.69 (sub 0) OBJ File: 'glow_panel.blend'
# www.blender.org
g light
v 0.187500 -0.510000 -0.187500
v 0.187500 -0.510000 0.187500
v -0.187500 -0.510000 0.187500
v -0.187500 -0.510000 -0.187500
v 0.187500 -0.350000 -0.187500
v 0.187500 -0.350000 0.187500
v -0.187500 -0.350000 0.187500
v -0.187500 -0.350000 -0.187500
vt 0.312500 0.312500
vt 0.687500 0.312500
vt 0.687500 0.687500
vt 0.312500 0.687500
vt 0.687500 0.593750
vt 0.312500 0.593750
vt 0.593750 0.687500
vt 0.593750 0.312500
vt 0.687500 0.406250
vt 0.312500 0.406250
vt 0.406250 0.312500
vt 0.406250 0.687500
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 -0.000000
vn 1.000000 0.000000 0.000001
vn -0.000001 -0.000001 1.000000
vn -1.000000 -0.000001 -0.000001
vn 0.000001 0.000001 -1.000000
s off
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/1/2 8/2/2 7/3/2 6/4/2
f 1/5/3 5/3/3 6/4/3 2/6/3
f 2/3/4 6/7/4 7/8/4 3/2/4
f 3/2/5 7/9/5 8/10/5 4/1/5
f 5/1/6 1/11/6 4/12/6 8/4/6
g frame
v 0.250000 -0.500000 -0.250000
v 0.250000 -0.500000 0.250000
v -0.250000 -0.500000 0.250000
v -0.250000 -0.500000 -0.250000
v 0.250000 -0.375000 -0.250000
v 0.250000 -0.375000 0.250000
v -0.250000 -0.375000 0.250000
v -0.250000 -0.375000 -0.250000
vt 0.250000 0.250000
vt 0.750000 0.250000
vt 0.750000 0.750000
vt 0.250000 0.750000
vt 0.750000 0.687500
vt 0.250000 0.687500
vt 0.687500 0.250000
vt 0.687500 0.750000
vt 0.250000 0.312500
vt 0.750000 0.312500
vt 0.312500 0.250000
vt 0.312500 0.750000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 1.000000 0.000001 0.000001
vn -0.000001 -0.000001 1.000000
vn -1.000000 -0.000001 -0.000001
vn 0.000000 0.000001 -1.000000
s off
f 9/13/7 10/14/7 11/15/7 12/16/7
f 13/13/8 16/14/8 15/15/8 14/16/8
f 9/17/9 13/15/9 14/16/9 10/18/9
f 10/19/10 14/14/10 15/15/10 11/20/10
f 11/21/11 15/13/11 16/14/11 12/22/11
f 13/13/12 9/23/12 12/24/12 16/16/12

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB