Laser Rendering Improvements (#462)

* Improved laser rendering.

* Removed unused import.
This commit is contained in:
elucent 2016-12-07 07:56:17 -05:00 committed by Ellpeck
parent f937673483
commit c3ef81ff5f
5 changed files with 37 additions and 23 deletions

View file

@ -44,7 +44,7 @@ public class ClientProxy implements IProxy{
private static final List<Item> COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList<Item>(); private static final List<Item> COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList<Item>();
private static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<ItemStack, ModelResourceLocation>(); private static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<ItemStack, ModelResourceLocation>();
@Override @Override
public void preInit(FMLPreInitializationEvent event){ public void preInit(FMLPreInitializationEvent event){
ModUtil.LOGGER.info("PreInitializing ClientProxy..."); ModUtil.LOGGER.info("PreInitializing ClientProxy...");

View file

@ -21,9 +21,12 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -35,6 +38,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public final class AssetUtil{ public final class AssetUtil{
public static int maxLightX = 0xF000F0;
public static int maxLightY = 0xF000F0;
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory"); public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory");
@ -233,7 +239,10 @@ public final class AssetUtil{
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE);
int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0);
GlStateManager.translate(firstX-TileEntityRendererDispatcher.staticPlayerX, firstY-TileEntityRendererDispatcher.staticPlayerY, firstZ-TileEntityRendererDispatcher.staticPlayerZ); GlStateManager.translate(firstX-TileEntityRendererDispatcher.staticPlayerX, firstY-TileEntityRendererDispatcher.staticPlayerY, firstZ-TileEntityRendererDispatcher.staticPlayerZ);
GlStateManager.rotate((float)(180*yaw/Math.PI), 0, 1, 0); GlStateManager.rotate((float)(180*yaw/Math.PI), 0, 1, 0);
GlStateManager.rotate((float)(180*pitch/Math.PI), 0, 0, 1); GlStateManager.rotate((float)(180*pitch/Math.PI), 0, 0, 1);
@ -286,31 +295,36 @@ public final class AssetUtil{
} }
else{*/ else{*/
GlStateManager.disableTexture2D(); GlStateManager.disableTexture2D();
render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
render.pos(length, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); for (double i = 0; i < 4; i ++){
render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); double width = beamWidth * (i/4.0);
render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex();
render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex();
}
tessy.draw(); tessy.draw();
GlStateManager.enableTexture2D(); GlStateManager.enableTexture2D();
//} //}
GlStateManager.alphaFunc(func, ref);
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.disableBlend(); GlStateManager.disableBlend();
GlStateManager.enableLighting(); GlStateManager.enableLighting();
GlStateManager.popMatrix(); GlStateManager.popMatrix();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 264 B