rift render growth and removal

This commit is contained in:
StevenRS11 2014-08-21 18:42:24 -05:00
parent 910f991734
commit 7b77b268bf
2 changed files with 26 additions and 30 deletions

View file

@ -48,17 +48,15 @@ public class TileEntityRift extends DDTileEntityBase
public Point4D nearestRiftLocation = null; public Point4D nearestRiftLocation = null;
public int spawnedEndermenID = 0; public int spawnedEndermenID = 0;
public int riftRotation; public int riftRotation = random.nextInt(360);
public int renderKey; public int renderKey = random.nextInt(LSystem.curves.size());
public int growth; public float growth = 0;
public TileEntityRift() public TileEntityRift()
{ {
// Vary the update times of rifts to prevent all the rifts in a cluster // Vary the update times of rifts to prevent all the rifts in a cluster
// from updating at the same time. // from updating at the same time.
updateTimer = random.nextInt(UPDATE_PERIOD); 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(); updateNearestRift();
spread(mod_pocketDim.properties); spread(mod_pocketDim.properties);
} }
growth++; growth += 1F/(growth+1);
updateTimer++; updateTimer++;
} }
@ -151,7 +149,7 @@ public class TileEntityRift extends DDTileEntityBase
private void closeRift() private void closeRift()
{ {
NewDimData dimension = PocketManager.createDimensionData(worldObj); 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)) 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); DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj);
if (link != null) if (link != null)
@ -174,7 +172,8 @@ public class TileEntityRift extends DDTileEntityBase
worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord);
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mods.DimDoors.sfx.riftClose", 0.7f, 1, false); worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mods.DimDoors.sfx.riftClose", 0.7f, 1, false);
} }
closeTimer++;
growth --;
} }
public boolean updateNearestRift() public boolean updateNearestRift()
@ -265,7 +264,7 @@ public class TileEntityRift extends DDTileEntityBase
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID"); this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
this.riftRotation = nbt.getInteger("riftRotation"); this.riftRotation = nbt.getInteger("riftRotation");
this.renderKey = nbt.getInteger("renderKey"); 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("spawnedEndermenID", this.spawnedEndermenID);
nbt.setInteger("renderKey", this.renderKey); nbt.setInteger("renderKey", this.renderKey);
nbt.setInteger("riftRotation", this.riftRotation); nbt.setInteger("riftRotation", this.riftRotation);
nbt.setInteger("growth", this.growth); nbt.setFloat("growth", this.growth);
} }

View file

@ -35,7 +35,7 @@ public class RenderRift extends TileEntitySpecialRenderer
*/ */
TileEntityRift rift = (TileEntityRift) te; TileEntityRift rift = (TileEntityRift) te;
// draws the verticies corresponding to the passed it // 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); GL11.glDisable(GL_BLEND);
// reenable all the stuff we disabled // reenable all the stuff we disabled
@ -83,12 +83,11 @@ public class RenderRift extends TileEntitySpecialRenderer
double[] jitters = new double[jCount]; double[] jitters = new double[jCount];
// generate a series of waveforms // 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] = 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; jitters[i + 1] = Math.cos((1F + i / 10F) * time) * Math.sin(1F - (i / 10F) * time) / motionMagnitude;
} }
// determines which jitter waveform we select. Modulo so the same point // determines which jitter waveform we select. Modulo so the same point
@ -97,23 +96,21 @@ public class RenderRift extends TileEntitySpecialRenderer
// set the color for the render // set the color for the render
GL11.glColor4f(.1F, .1F, .1F, 1F); GL11.glColor4f(.1F, .1F, .1F, 1F);
//set the blending mode // set the blending mode
GL11.glEnable(GL_BLEND); GL11.glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE); glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE);
GL11.glBegin(GL11.GL_TRIANGLES); GL11.glBegin(GL11.GL_TRIANGLES);
for (Point p : poly.points) for (Point p : poly.points)
{ {
jIndex = Math.abs(((p.x + p.y)*(p.x + p.y + 1)/2) + p.y); jIndex = Math.abs(((p.x + p.y) * (p.x + p.y + 1) / 2) + p.y);
//jIndex++; // jIndex++;
// calculate the rotation for the fractal, apply offset, and apply // calculate the rotation for the fractal, apply offset, and apply
// jitter // jitter
double x = (((p.x + jitters[(jIndex + 1) % jCount]) - offsetX) * Math.cos(Math.toRadians(riftRotation)) - (jitters[(jIndex + 2) % jCount]) double x = (((p.x + jitters[(jIndex + 1) % jCount]) - offsetX) * Math.cos(Math.toRadians(riftRotation)) - (jitters[(jIndex + 2) % jCount])
* Math.sin(Math.toRadians(riftRotation))); * Math.sin(Math.toRadians(riftRotation)));
double y = p.y + (jitters[jIndex % jCount]) - offsetY; 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 double z = (((p.x + jitters[(jIndex + 2) % jCount]) - offsetX) * Math.sin(Math.toRadians(riftRotation)) + (jitters[(jIndex + 2) % jCount])
.cos(Math.toRadians(riftRotation))); * Math.cos(Math.toRadians(riftRotation)));
// apply scaling // apply scaling
x *= scale; x *= scale;
@ -134,9 +131,7 @@ public class RenderRift extends TileEntitySpecialRenderer
GL11.glColor4f(.3F, .3F, .3F, .2F); 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 // draw the next set of triangles to form a background and change their
// color slightly over time // color slightly over time
@ -159,7 +154,9 @@ public class RenderRift extends TileEntitySpecialRenderer
if (jIndex % 3 == 0) 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); GL11.glVertex3d(xWorld + x, yWorld + y, zWorld + z);
} }