From 7b77b268bf525d619aed7dbc67829ce9ac21a3bd Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Thu, 21 Aug 2014 18:42:24 -0500 Subject: [PATCH] rift render growth and removal --- .../tileentities/TileEntityRift.java | 21 ++++++----- .../mod_pocketDimClient/RenderRift.java | 35 +++++++++---------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java index c0d538c..b5ee488 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java @@ -48,17 +48,15 @@ public class TileEntityRift extends DDTileEntityBase public Point4D nearestRiftLocation = null; public int spawnedEndermenID = 0; - public int riftRotation; - public int renderKey; - public int growth; + public int riftRotation = random.nextInt(360); + public int renderKey = random.nextInt(LSystem.curves.size()); + public float growth = 0; public TileEntityRift() { // Vary the update times of rifts to prevent all the rifts in a cluster // from updating at the same time. updateTimer = random.nextInt(UPDATE_PERIOD); - this.riftRotation = random.nextInt(360); - this.renderKey = random.nextInt(LSystem.curves.size()); } @@ -103,7 +101,7 @@ public class TileEntityRift extends DDTileEntityBase updateNearestRift(); spread(mod_pocketDim.properties); } - growth++; + growth += 1F/(growth+1); updateTimer++; } @@ -151,7 +149,7 @@ public class TileEntityRift extends DDTileEntityBase private void closeRift() { NewDimData dimension = PocketManager.createDimensionData(worldObj); - if (closeTimer == CLOSING_PERIOD / 2) + if (growth < CLOSING_PERIOD / 2) { for (DimLink riftLink : dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord)) { @@ -164,7 +162,7 @@ public class TileEntityRift extends DDTileEntityBase } } } - if (closeTimer >= CLOSING_PERIOD && !worldObj.isRemote) + if (growth == 0 && !worldObj.isRemote) { DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj); if (link != null) @@ -174,7 +172,8 @@ public class TileEntityRift extends DDTileEntityBase worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mods.DimDoors.sfx.riftClose", 0.7f, 1, false); } - closeTimer++; + + growth --; } public boolean updateNearestRift() @@ -265,7 +264,7 @@ public class TileEntityRift extends DDTileEntityBase this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID"); this.riftRotation = nbt.getInteger("riftRotation"); this.renderKey = nbt.getInteger("renderKey"); - this.growth = nbt.getInteger("growth"); + this.growth = nbt.getFloat("growth"); } @@ -281,7 +280,7 @@ public class TileEntityRift extends DDTileEntityBase nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID); nbt.setInteger("renderKey", this.renderKey); nbt.setInteger("riftRotation", this.riftRotation); - nbt.setInteger("growth", this.growth); + nbt.setFloat("growth", this.growth); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderRift.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderRift.java index 457c878..762bca4 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderRift.java @@ -35,7 +35,7 @@ public class RenderRift extends TileEntitySpecialRenderer */ TileEntityRift rift = (TileEntityRift) te; // draws the verticies corresponding to the passed it - this.drawCrack(rift.riftRotation, rift.getCurve(), Math.log(2+rift.growth)/5D, xWorld, yWorld, zWorld); + this.drawCrack(rift.riftRotation, rift.getCurve(), rift.growth/15, xWorld, yWorld, zWorld); GL11.glDisable(GL_BLEND); // reenable all the stuff we disabled @@ -83,11 +83,10 @@ public class RenderRift extends TileEntitySpecialRenderer double[] jitters = new double[jCount]; // generate a series of waveforms - for (int i = 0; i < jCount-1; i += 1) + for (int i = 0; i < jCount - 1; i += 1) { jitters[i] = Math.sin((1F + i / 10F) * time) * Math.cos(1F - (i / 10F) * time) / motionMagnitude; jitters[i + 1] = Math.cos((1F + i / 10F) * time) * Math.sin(1F - (i / 10F) * time) / motionMagnitude; - } @@ -97,24 +96,22 @@ public class RenderRift extends TileEntitySpecialRenderer // set the color for the render GL11.glColor4f(.1F, .1F, .1F, 1F); - //set the blending mode - GL11.glEnable(GL_BLEND); - glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE); + // set the blending mode + GL11.glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE); GL11.glBegin(GL11.GL_TRIANGLES); for (Point p : poly.points) { - jIndex = Math.abs(((p.x + p.y)*(p.x + p.y + 1)/2) + p.y); - //jIndex++; + jIndex = Math.abs(((p.x + p.y) * (p.x + p.y + 1) / 2) + p.y); + // jIndex++; // calculate the rotation for the fractal, apply offset, and apply // jitter double x = (((p.x + jitters[(jIndex + 1) % jCount]) - offsetX) * Math.cos(Math.toRadians(riftRotation)) - (jitters[(jIndex + 2) % jCount]) * Math.sin(Math.toRadians(riftRotation))); double y = p.y + (jitters[jIndex % jCount]) - offsetY; - double z = (((p.x + jitters[(jIndex + 2) % jCount]) - offsetX) * Math.sin(Math.toRadians(riftRotation)) + (jitters[(jIndex + 2) % jCount]) * Math - .cos(Math.toRadians(riftRotation))); + double z = (((p.x + jitters[(jIndex + 2) % jCount]) - offsetX) * Math.sin(Math.toRadians(riftRotation)) + (jitters[(jIndex + 2) % jCount]) + * Math.cos(Math.toRadians(riftRotation))); - - // apply scaling x *= scale; y *= scale; @@ -134,10 +131,8 @@ public class RenderRift extends TileEntitySpecialRenderer GL11.glColor4f(.3F, .3F, .3F, .2F); - glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO ); - - - + glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + // draw the next set of triangles to form a background and change their // color slightly over time GL11.glBegin(GL11.GL_TRIANGLES); @@ -156,16 +151,18 @@ public class RenderRift extends TileEntitySpecialRenderer x += .5; y += .5; z += .5; - + if (jIndex % 3 == 0) { - //GL11.glColor4d(1-jitters[(jIndex + 5) % jCount] / 11,1- jitters[(jIndex + 4) % jCount] / 8, 1-jitters[(jIndex+3) % jCount] / 8, 1); + // GL11.glColor4d(1-jitters[(jIndex + 5) % jCount] / 11,1- + // jitters[(jIndex + 4) % jCount] / 8, 1-jitters[(jIndex+3) % + // jCount] / 8, 1); } GL11.glVertex3d(xWorld + x, yWorld + y, zWorld + z); } // stop drawing triangles GL11.glEnd(); - + } } \ No newline at end of file