Rendering for previous and next segments
This commit is contained in:
parent
c1c6c781d0
commit
18a7cbb7b2
8 changed files with 40 additions and 16 deletions
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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<BoltSegment> 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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue