From 18a7cbb7b2280f2634db4ea264dad4dfbd97162a Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 2 Aug 2013 00:31:06 -0400 Subject: [PATCH] Rendering for previous and next segments --- src/resonantinduction/CommonProxy.java | 2 +- src/resonantinduction/ResonantInduction.java | 2 +- src/resonantinduction/base/Vector3.java | 3 +- src/resonantinduction/fx/FXElectricBolt.java | 35 ++++++++++++++++--- .../model/ModelTeslaBottom.java | 4 +-- .../model/ModelTeslaMiddle.java | 4 +-- src/resonantinduction/render/RenderTesla.java | 4 +-- src/resonantinduction/tesla/TeslaGrid.java | 2 +- 8 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/resonantinduction/CommonProxy.java b/src/resonantinduction/CommonProxy.java index d1f81579..80024d3e 100644 --- a/src/resonantinduction/CommonProxy.java +++ b/src/resonantinduction/CommonProxy.java @@ -3,9 +3,9 @@ */ package resonantinduction; -import resonantinduction.base.Vector3; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import resonantinduction.base.Vector3; import cpw.mods.fml.common.network.IGuiHandler; /** diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index 0551bfc8..03f40c9f 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -114,7 +114,7 @@ public class ResonantInduction GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName()); - this.proxy.registerRenderers(); + ResonantInduction.proxy.registerRenderers(); TabRI.ITEMSTACK = new ItemStack(blockTesla); } diff --git a/src/resonantinduction/base/Vector3.java b/src/resonantinduction/base/Vector3.java index f80979d7..148eb862 100644 --- a/src/resonantinduction/base/Vector3.java +++ b/src/resonantinduction/base/Vector3.java @@ -128,7 +128,6 @@ public class Vector3 return new Vector3(this.x + offset.x, this.y + offset.y, this.z + offset.z); } - public Vector3 normalize() { double d = getMagnitude(); @@ -139,7 +138,7 @@ public class Vector3 } return this; } - + /** * Rotate by a this vector around an axis. * diff --git a/src/resonantinduction/fx/FXElectricBolt.java b/src/resonantinduction/fx/FXElectricBolt.java index 9638cc76..b2cbe838 100644 --- a/src/resonantinduction/fx/FXElectricBolt.java +++ b/src/resonantinduction/fx/FXElectricBolt.java @@ -77,7 +77,6 @@ public class FXElectricBolt extends EntityFX this.recalculate(); double offsetRatio = this.boltLength * this.complexity; this.split(offsetRatio / 8, 0.1f, 45); - System.out.println(this.segments.size()); this.split(offsetRatio / 12, 0.1f, 90); this.split(offsetRatio / 18, 0.1f, 90); @@ -189,7 +188,7 @@ public class FXElectricBolt extends EntityFX { lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = segment.splitID; - lastActiveSeg = ((Integer) lastActiveSegment.get(this.parentIDMap.get(segment.splitID))).intValue(); + lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue(); } lastActiveSeg = segment.id; @@ -197,7 +196,7 @@ public class FXElectricBolt extends EntityFX lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = 0; - lastActiveSeg = ((Integer) lastActiveSegment.get(0)).intValue(); + lastActiveSeg = lastActiveSegment.get(0).intValue(); BoltSegment segment; for (Iterator iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate()) @@ -244,14 +243,15 @@ public class FXElectricBolt extends EntityFX */ GL11.glDepthMask(true); GL11.glEnable(3042); + tessellator.startDrawingQuads(); + tessellator.setBrightness(15728880); Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch); int renderLength = (int) ((this.particleAge + partialFrame + this.boltLength * 3) / (this.boltLength * 3 * this.segmentCount)); for (BoltSegment segment : this.segments) { - // TODO: Weight? Scale - double width = this.width * (new Vector3(player).distance(segment.start) / 5 + 1); + double width = this.width * ((new Vector3(player).distance(segment.start) / 5 + 1) * (1.0F + segment.weight) * 0.5f); Vector3 prevDiff = playerVector.crossProduct(segment.prevDiff).scale(this.width); Vector3 nextDiff = playerVector.crossProduct(segment.nextDiff).scale(this.width); @@ -270,8 +270,33 @@ public class FXElectricBolt extends EntityFX tessellator.addVertexWithUV(rx1 - prevDiff.x, ry1 - prevDiff.y, rz1 - prevDiff.z, 0.5D, 0.0D); tessellator.addVertexWithUV(rx1 + prevDiff.x, ry1 + prevDiff.y, rz1 + prevDiff.z, 0.5D, 1.0D); tessellator.addVertexWithUV(rx2 + nextDiff.x, ry2 + nextDiff.y, rz2 + nextDiff.z, 0.5D, 1.0D); + + if (segment.next == null) + { + Vector3 roundend = segment.end.clone().translate(segment.difference.clone().normalize().scale(width)); + float rx3 = (float) (roundend.x - interpPosX); + float ry3 = (float) (roundend.y - interpPosY); + float rz3 = (float) (roundend.z - interpPosZ); + tessellator.addVertexWithUV(rx3 - nextDiff.x, ry3 - nextDiff.y, rz3 - nextDiff.z, 0.0D, 0.0D); + tessellator.addVertexWithUV(rx2 - nextDiff.x, ry2 - nextDiff.y, rz2 - nextDiff.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx2 + nextDiff.x, ry2 + nextDiff.y, rz2 + nextDiff.z, 0.5D, 1.0D); + tessellator.addVertexWithUV(rx3 + nextDiff.x, ry3 + nextDiff.y, rz3 + nextDiff.z, 0.0D, 1.0D); + } + + if (segment.prev == null) + { + Vector3 roundend = segment.start.clone().difference(segment.difference.clone().normalize().scale(width)); + float rx3 = (float) (roundend.x - interpPosX); + float ry3 = (float) (roundend.y - interpPosY); + float rz3 = (float) (roundend.z - interpPosZ); + tessellator.addVertexWithUV(rx1 - prevDiff.x, ry1 - prevDiff.y, rz1 - prevDiff.z, 0.5D, 0.0D); + tessellator.addVertexWithUV(rx3 - prevDiff.x, ry3 - prevDiff.y, rz3 - prevDiff.z, 0.0D, 0.0D); + tessellator.addVertexWithUV(rx3 + prevDiff.x, ry3 + prevDiff.y, rz3 + prevDiff.z, 0.0D, 1.0D); + tessellator.addVertexWithUV(rx1 + prevDiff.x, ry1 + prevDiff.y, rz1 + prevDiff.z, 0.5D, 1.0D); + } } + tessellator.draw(); GL11.glDisable(3042); GL11.glDepthMask(false); diff --git a/src/resonantinduction/model/ModelTeslaBottom.java b/src/resonantinduction/model/ModelTeslaBottom.java index e977a215..18d2e141 100644 --- a/src/resonantinduction/model/ModelTeslaBottom.java +++ b/src/resonantinduction/model/ModelTeslaBottom.java @@ -1,9 +1,9 @@ package resonantinduction.model; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelTeslaBottom extends ModelBase diff --git a/src/resonantinduction/model/ModelTeslaMiddle.java b/src/resonantinduction/model/ModelTeslaMiddle.java index 590a99cc..ec70238b 100644 --- a/src/resonantinduction/model/ModelTeslaMiddle.java +++ b/src/resonantinduction/model/ModelTeslaMiddle.java @@ -1,9 +1,9 @@ package resonantinduction.model; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelTeslaMiddle extends ModelBase diff --git a/src/resonantinduction/render/RenderTesla.java b/src/resonantinduction/render/RenderTesla.java index a7e81449..9753c2a3 100644 --- a/src/resonantinduction/render/RenderTesla.java +++ b/src/resonantinduction/render/RenderTesla.java @@ -9,11 +9,11 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import resonantinduction.ResonantInduction; import resonantinduction.model.ModelTeslaBottom; import resonantinduction.model.ModelTeslaMiddle; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * @author Calclavia diff --git a/src/resonantinduction/tesla/TeslaGrid.java b/src/resonantinduction/tesla/TeslaGrid.java index dba55869..64e8a3dc 100644 --- a/src/resonantinduction/tesla/TeslaGrid.java +++ b/src/resonantinduction/tesla/TeslaGrid.java @@ -7,8 +7,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import resonantinduction.ITesla; import net.minecraft.tileentity.TileEntity; +import resonantinduction.ITesla; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side;