From d9a9091a2b5c824160d379931bb6b8cb6dc3a5d9 Mon Sep 17 00:00:00 2001 From: StevenRS11 Date: Tue, 20 Aug 2013 21:43:33 -0400 Subject: [PATCH] changes to RiftRender --- .../mod_pocketDim/TileEntityRift.java | 290 ++++++++++-------- .../mod_pocketDim/blocks/BlockRift.java | 10 +- .../mod_pocketDim/helpers/DungeonHelper.java | 2 +- .../ticking/LimboGatewayGenerator.java | 26 ++ .../mod_pocketDimClient/ClientProxy.java | 2 + .../mod_pocketDimClient/RenderDimDoor.java | 71 +++-- .../mod_pocketDimClient/RenderRift.java | 224 ++++++++++++++ 7 files changed, 453 insertions(+), 172 deletions(-) create mode 100644 StevenDimDoors/mod_pocketDim/ticking/LimboGatewayGenerator.java diff --git a/StevenDimDoors/mod_pocketDim/TileEntityRift.java b/StevenDimDoors/mod_pocketDim/TileEntityRift.java index 0c594b5f..a66ac039 100644 --- a/StevenDimDoors/mod_pocketDim/TileEntityRift.java +++ b/StevenDimDoors/mod_pocketDim/TileEntityRift.java @@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Random; @@ -31,9 +32,13 @@ public class TileEntityRift extends TileEntity public boolean isNearRift=false; private int count=200; private int count2 = 0; - private int soundCount = 0; + + public HashMap renderingCenters = new HashMap(); public LinkData nearestRiftData; - Random rand = new Random(); + Random rand = new Random(); + + + public float age = 0; @@ -41,38 +46,28 @@ public class TileEntityRift extends TileEntity { return true; } - - public void updateEntity() + public void clearBlocksOnRift() { - - if(count>200&&dimHelper.instance.getDimData(this.worldObj.provider.dimensionId)!=null) + for(double[] coord: this.renderingCenters.values()) { - /** - if(rand.nextBoolean()) - { - } - **/ + int x = MathHelper.floor_double(coord[0]+.5); + int y = MathHelper.floor_double(coord[1]+.5); + int z = MathHelper.floor_double(coord[2]+.5); + this.worldObj.setBlockToAir(this.xCoord+x, this.yCoord+y, this.zCoord+z); + + this.worldObj.setBlockToAir(this.xCoord-x, this.yCoord+y, this.zCoord-z); + + } + } + public void spawnEndermen() + { + if(count>200&&dimHelper.instance.getDimData(this.worldObj.provider.dimensionId)!=null) + { + + nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord); if(nearestRiftData!=null) { - this.xOffset=this.xCoord-nearestRiftData.locXCoord; - this.yOffset=this.yCoord-nearestRiftData.locYCoord; - this.zOffset=this.zCoord-nearestRiftData.locZCoord; - this.distance=(int) (MathHelper.abs(xOffset)+MathHelper.abs(yOffset)+MathHelper.abs(zOffset)); - this.isNearRift=true; - - if(!this.worldObj.isRemote&&distance>1) - { - try - { - grow(distance); - } - catch(Exception e) - { - - } - - } if(rand.nextInt(30)==0&&!this.worldObj.isRemote) { @@ -82,29 +77,11 @@ public class TileEntityRift extends TileEntity { - EntityEnderman creeper = new EntityEnderman(worldObj); - creeper.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6); - worldObj.spawnEntityInWorld(creeper); - } - - /** - if(dimHelper.instance.getDimData(this.worldObj.provider.dimensionId)!=null) - { - ArrayList rifts = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findRiftsInRange(worldObj, 6, this.xCoord, this.yCoord, this.zCoord); - if(rifts.size()>15) - { - MobObelisk creeper = new MobObelisk(worldObj); - creeper.setLocationAndAngles(this.xCoord+.5, yCoordHelper.getFirstUncovered(this.worldObj, this.xCoord, this.yCoord, this.zCoord), this.zCoord+.5, 5, 6); - worldObj.spawnEntityInWorld(creeper); - } - - } - **/ + EntityEnderman enderman = new EntityEnderman(worldObj); + enderman.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6); + worldObj.spawnEntityInWorld(enderman); + } } - - - - } else { @@ -112,87 +89,124 @@ public class TileEntityRift extends TileEntity } count=0; } - else if(dimHelper.instance.getLinkDataFromCoords(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId)==null) - { - this.invalidate(); - this.worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + } + public void closeRift() + { + if(count2>20&&count2<22) + { + nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 10, xCoord, yCoord, zCoord); + if(this.nearestRiftData!=null) + { + TileEntityRift rift = (TileEntityRift) this.worldObj.getBlockTileEntity(nearestRiftData.locXCoord, nearestRiftData.locYCoord, nearestRiftData.locZCoord); + if(rift!=null) + { + rift.shouldClose=true; + } + } + } + if(count2>40) + { + this.invalidate(); + this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord,0); + if(dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)!=null) + { + dimHelper.instance.removeLink(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord); + this.worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1,true); + + } + + } + count2++; + } + public void updateEntity() + { + + if(rand.nextInt(10)==0) + { + age = age + 1; + this.calculateNextRenderQuad(age, rand); + + } + this.clearBlocksOnRift(); + this.spawnEndermen(); + + count++; if(this.shouldClose) { - // System.out.println(count2); - if(count2>20&&count2<22) - { - nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 10, xCoord, yCoord, zCoord); - if(this.nearestRiftData!=null) - { - TileEntityRift rift = (TileEntityRift) this.worldObj.getBlockTileEntity(nearestRiftData.locXCoord, nearestRiftData.locYCoord, nearestRiftData.locZCoord); - if(rift!=null) - { - rift.shouldClose=true; - } - } - } - if(count2>40) - { - this.invalidate(); - this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord,0); - if(dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)!=null) - { - dimHelper.instance.removeLink(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord); - this.worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1,true); - - } - - } - count2++; + closeRift(); } - + if(dimHelper.instance.getLinkDataFromCoords(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId)==null) + { + this.invalidate(); + this.worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } } public void grow(int distance) { - int count=0; - if(rand.nextInt(distance*2)==0) - { - - int x=0,y=0,z=0; - while(count<100) - { - count++; - x=this.xCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(6)); - y=this.yCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(4)); - z=this.zCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(6)); - if(this.worldObj.isAirBlock(x, y, z)) - { - break; - } - - } - - - if (count<100) - { - - LinkData link = dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, worldObj); - if(link!=null) - { - if(!this.hasGrownRifts&&rand.nextInt(3)==0) - { - // System.out.println(link.numberofChildren); - link.numberofChildren++; - dimHelper.instance.createLink(this.worldObj.provider.dimensionId, link.destDimID, x, y, z, link.destXCoord, link.destYCoord, link.destZCoord).numberofChildren=link.numberofChildren+1; - this.hasGrownRifts=true; - - } - } - } - - } + } + public void calculateNextRenderQuad(float age, Random rand) + { + int iteration = MathHelper.floor_double((Math.log(Math.pow(age+1,1.5)))); + double fl =Math.log(iteration+1)/(iteration); + double[] coords= new double[4]; + double noise = ((rand.nextGaussian())/(10)*(iteration+1)); + + if(!this.renderingCenters.containsKey(iteration-1)) + { + if(rand.nextBoolean()) + { + coords[0] = fl*1.5; + coords[1] = rand.nextGaussian()/10; + coords[2] = 0; + coords[3] = 1; + } + else + { + coords[0] = 0; + coords[1] = rand.nextGaussian()/10; + coords[2] = fl*1.5; + coords[3] = 0; + + } + this.renderingCenters.put(iteration-1,coords); + + + } + else if(!this.renderingCenters.containsKey(iteration)) + { + if(this.renderingCenters.get(iteration-1)[3]==0) + { + coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0]; + coords[1]=noise+this.renderingCenters.get(iteration-1)[1]; + coords[2]= this.renderingCenters.get(iteration-1)[2]+fl; + coords[3] = 0; + + } + else + { + coords[0]=this.renderingCenters.get(iteration-1)[0]+fl; + coords[1]=noise+this.renderingCenters.get(iteration-1)[1]; + coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2]; + coords[3] = 1; + + } + + + this.renderingCenters.put(iteration,coords); + + } + } + @Override + public boolean shouldRenderInPass(int pass) + { + return pass == 1; + } @Override public void readFromNBT(NBTTagCompound nbt) { @@ -200,15 +214,22 @@ public class TileEntityRift extends TileEntity int i = nbt.getInteger(("Size")); try - { - this.xOffset = nbt.getInteger("xOffset"); - this.yOffset = nbt.getInteger("yOffset"); - this.zOffset = nbt.getInteger("zOffset"); - this.hasGrownRifts =nbt.getBoolean("grownRifts"); + { this.count=nbt.getInteger("count"); this.count2=nbt.getInteger("count2"); this.shouldClose=nbt.getBoolean("shouldClose"); - + this.age=nbt.getFloat("age"); + for(int key=0; key<=nbt.getInteger("hashMapSize");key++) + { + double[] coords = new double[4]; + + coords[0]= nbt.getDouble(key+"+0"); + coords[1]= nbt.getDouble(key+"+1"); + coords[2]= nbt.getDouble(key+"+2"); + coords[3]= nbt.getDouble(key+"+3"); + + this.renderingCenters.put(key, coords); + } @@ -216,7 +237,7 @@ public class TileEntityRift extends TileEntity } catch (Exception e) { - + e.printStackTrace(); } } @@ -225,12 +246,19 @@ public class TileEntityRift extends TileEntity { int i = 0; super.writeToNBT(nbt); - nbt.setInteger("xOffset", this.xOffset); - nbt.setInteger("yOffset", this.yOffset); - nbt.setInteger("zOffset", this.zOffset); - nbt.setBoolean("grownRifts",this.hasGrownRifts); + + for(Integer key:this.renderingCenters.keySet()) + { + nbt.setDouble(key+"+0", this.renderingCenters.get(key)[0]); + nbt.setDouble(key+"+1", this.renderingCenters.get(key)[1]); + nbt.setDouble(key+"+2", this.renderingCenters.get(key)[2]); + nbt.setDouble(key+"+3", this.renderingCenters.get(key)[3]); + } + nbt.setInteger("hashMapSize", this.renderingCenters.size()); nbt.setInteger("count", this.count); nbt.setInteger("count2", this.count2); + nbt.setFloat("age", this.age); + nbt.setBoolean("shouldClose", this.shouldClose); } diff --git a/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java b/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java index 7b10a63e..850acec0 100644 --- a/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java +++ b/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java @@ -37,13 +37,12 @@ public class BlockRift extends BlockContainer private static final int BLOCK_DESTRUCTION_CHANCE = 50; private final DDProperties properties; - private final ArrayList blocksImmuneToRift; + private static ArrayList blocksImmuneToRift; public BlockRift(int i, int j, Material par2Material, DDProperties properties) { super(i, par2Material); this.setTickRandomly(true); - this.setLightOpacity(14); this.properties = properties; this.blocksImmuneToRift = new ArrayList(); this.blocksImmuneToRift.add(properties.FabricBlockID); @@ -223,11 +222,14 @@ public class BlockRift extends BlockContainer } } + /** * regulates the render effect, especially when multiple rifts start to link up. Has 3 main parts- Grows toward and away from nearest rft, bends toward it, and a randomization function */ + /** @Override @SideOnly(Side.CLIENT) + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random rand) { @@ -334,8 +336,8 @@ public class BlockRift extends BlockContainer } } } - - public boolean isBlockImmune(World world, int x, int y, int z) + **/ + public static boolean isBlockImmune(World world, int x, int y, int z) { Block block = Block.blocksList[world.getBlockId(x, y, z)]; if (block != null) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index a99d503b..25b41568 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -309,7 +309,7 @@ public class DungeonHelper InputStream listStream = this.getClass().getResourceAsStream(BUNDLED_DUNGEONS_LIST_PATH); if (listStream == null) { - System.err.println("Unable to open list of bundled dungeon schematics."); + System.err.println("Unable to open list of bundled dungeon schematics."); return; } diff --git a/StevenDimDoors/mod_pocketDim/ticking/LimboGatewayGenerator.java b/StevenDimDoors/mod_pocketDim/ticking/LimboGatewayGenerator.java new file mode 100644 index 00000000..34536d42 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/ticking/LimboGatewayGenerator.java @@ -0,0 +1,26 @@ +package StevenDimDoors.mod_pocketDim.ticking; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.entity.Entity; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.GameRules; +import net.minecraft.world.World; +import StevenDimDoors.mod_pocketDim.DDProperties; +import StevenDimDoors.mod_pocketDim.DimData; +import StevenDimDoors.mod_pocketDim.helpers.dimHelper; +import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper; +import StevenDimDoors.mod_pocketDim.util.ChunkLocation; + +public class LimboGatewayGenerator implements IRegularTickReceiver +{ + + @Override + public void notifyTick() + { + + + } + +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDimClient/ClientProxy.java b/StevenDimDoors/mod_pocketDimClient/ClientProxy.java index e169140f..5c3bc4f3 100644 --- a/StevenDimDoors/mod_pocketDimClient/ClientProxy.java +++ b/StevenDimDoors/mod_pocketDimClient/ClientProxy.java @@ -10,6 +10,7 @@ import net.minecraftforge.client.MinecraftForgeClient; import StevenDimDoors.mod_pocketDim.CommonProxy; import StevenDimDoors.mod_pocketDim.Spells; import StevenDimDoors.mod_pocketDim.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.TileEntityRift; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler; import StevenDimDoors.mod_pocketDim.ticking.MobMonolith; @@ -24,6 +25,7 @@ public class ClientProxy extends CommonProxy //MinecraftForgeClient.preloadTexture(BLOCK_PNG); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRift.class, new RenderRift()); //MinecraftForgeClient.preloadTexture(RIFT2_PNG); diff --git a/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java b/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java index cdc012e8..240f4173 100644 --- a/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java +++ b/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java @@ -164,8 +164,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer GL11.glRotatef((float)(count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); - Tessellator var24 = Tessellator.instance; - var24.startDrawingQuads(); + GL11.glBegin(GL11.GL_QUADS); @@ -180,7 +179,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer var22 = 1.0F; yConverted = 1.0F; } - var24.setColorRGBA_F(var21 * var17, var22 * var17, var23 * var17, 1.0F); + GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F); if(tile.openOrClosed) { @@ -188,60 +187,60 @@ public class RenderDimDoor extends TileEntitySpecialRenderer { case 0: - var24.addVertex(x+.01F, y-1 , z); - var24.addVertex(x+.01, y-1, z+1.0D); - var24.addVertex(x+.01 , y+1 , z + 1.0D); - var24.addVertex(x+.01 , y+1 , z); + GL11.glVertex3d(x+.01F, y-1 , z); + GL11.glVertex3d(x+.01, y-1, z+1.0D); + GL11.glVertex3d(x+.01 , y+1 , z + 1.0D); + GL11.glVertex3d(x+.01 , y+1 , z); break; case 1: - var24.addVertex(x , y+1 , z+.01); - var24.addVertex(x+1 , y+1 , z+.01); - var24.addVertex(x+1, y-1, z+.01); - var24.addVertex(x, y-1, z+.01); + GL11.glVertex3d(x , y+1 , z+.01); + GL11.glVertex3d(x+1 , y+1 , z+.01); + GL11.glVertex3d(x+1, y-1, z+.01); + GL11.glVertex3d(x, y-1, z+.01); break; case 2: // - var24.addVertex(x+.99 , y+1 , z); - var24.addVertex(x+.99 , y+1 , z + 1.0D); - var24.addVertex(x+.99, y-1, z+1.0D); - var24.addVertex(x+.99, y-1, z); + GL11.glVertex3d(x+.99 , y+1 , z); + GL11.glVertex3d(x+.99 , y+1 , z + 1.0D); + GL11.glVertex3d(x+.99, y-1, z+1.0D); + GL11.glVertex3d(x+.99, y-1, z); break; case 3: - var24.addVertex(x, y-1, z+.99); - var24.addVertex(x+1, y-1, z+.99); - var24.addVertex(x+1 , y+1 , z+.99); - var24.addVertex(x , y+1 , z+.99); + GL11.glVertex3d(x, y-1, z+.99); + GL11.glVertex3d(x+1, y-1, z+.99); + GL11.glVertex3d(x+1 , y+1 , z+.99); + GL11.glVertex3d(x , y+1 , z+.99); break; case 4:// // GL11.glTranslatef(); - var24.addVertex(x+.15F, y-1 , z); - var24.addVertex(x+.15, y-1, z+1.0D); - var24.addVertex(x+.15 , y+1 , z + 1.0D); - var24.addVertex(x+.15 , y+1 , z); + GL11.glVertex3d(x+.15F, y-1 , z); + GL11.glVertex3d(x+.15, y-1, z+1.0D); + GL11.glVertex3d(x+.15 , y+1 , z + 1.0D); + GL11.glVertex3d(x+.15 , y+1 , z); break; case 5: - var24.addVertex(x , y+1 , z+.15); - var24.addVertex(x+1 , y+1 , z+.15); - var24.addVertex(x+1, y-1, z+.15); - var24.addVertex(x, y-1, z+.15); + GL11.glVertex3d(x , y+1 , z+.15); + GL11.glVertex3d(x+1 , y+1 , z+.15); + GL11.glVertex3d(x+1, y-1, z+.15); + GL11.glVertex3d(x, y-1, z+.15); break; case 6: // - var24.addVertex(x+.85 , y+1 , z); - var24.addVertex(x+.85 , y+1 , z + 1.0D); - var24.addVertex(x+.85, y-1, z+1.0D); - var24.addVertex(x+.85, y-1, z); + GL11.glVertex3d(x+.85 , y+1 , z); + GL11.glVertex3d(x+.85 , y+1 , z + 1.0D); + GL11.glVertex3d(x+.85, y-1, z+1.0D); + GL11.glVertex3d(x+.85, y-1, z); break; case 7: - var24.addVertex(x, y-1, z+.85); - var24.addVertex(x+1, y-1, z+.85); - var24.addVertex(x+1 , y+1 , z+.85); - var24.addVertex(x , y+1 , z+.85); + GL11.glVertex3d(x, y-1, z+.85); + GL11.glVertex3d(x+1, y-1, z+.85); + GL11.glVertex3d(x+1 , y+1 , z+.85); + GL11.glVertex3d(x , y+1 , z+.85); break; default: break; @@ -253,7 +252,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer - var24.draw(); + GL11.glEnd(); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); diff --git a/StevenDimDoors/mod_pocketDimClient/RenderRift.java b/StevenDimDoors/mod_pocketDimClient/RenderRift.java index e69de29b..d3bc9855 100644 --- a/StevenDimDoors/mod_pocketDimClient/RenderRift.java +++ b/StevenDimDoors/mod_pocketDimClient/RenderRift.java @@ -0,0 +1,224 @@ +package StevenDimDoors.mod_pocketDimClient; + +import java.nio.FloatBuffer; +import java.util.HashMap; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; +import static org.lwjgl.opengl.GL11.*; + +import StevenDimDoors.mod_pocketDim.DDProperties; +import StevenDimDoors.mod_pocketDim.TileEntityDimDoor; +import StevenDimDoors.mod_pocketDim.TileEntityRift; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.blocks.dimDoor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderRift extends TileEntitySpecialRenderer +{ + + @Override + public void renderTileEntityAt(TileEntity te, double xWorld, double yWorld, + double zWorld, float f) + { + yWorld = yWorld+.75; + GL11.glPushMatrix(); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL_TEXTURE_2D); + GL11.glDisable(GL_LIGHTING); + + //GL11.glLogicOp(GL11.GL_INVERT); + // GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); + + GL11.glColor4f(.3F, .3F, .3F, .2F); + + GL11.glEnable(GL_BLEND); + glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + + /** + * just draws the verticies + */ + //testDraw(TileEntityRift.class.cast(te).renderingCenters, xWorld, yWorld, zWorld); + this.drawCrack(TileEntityRift.class.cast(te).renderingCenters, xWorld, yWorld, zWorld); + this.drawCrackRotated(TileEntityRift.class.cast(te).renderingCenters, xWorld, yWorld, zWorld); + + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL_TEXTURE_2D); + + GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); + GL11.glPopMatrix(); + + } + + public void drawCrack(HashMap quads,double xWorld,double yWorld,double zWorld) + { + GL11.glBegin(GL11.GL_QUAD_STRIP); + + drawVertex(xWorld+.5, yWorld-Math.log(quads.size()+1)/8, zWorld+.5); + drawVertex(xWorld+.5, yWorld+Math.log(quads.size()+1)/8, zWorld+.5); + for(int i = 0;;i++) + { + if(!quads.containsKey(i)) + { + break; + } + double[] coords = quads.get(i); + double width=Math.log(quads.size()-i+1)/8; + if(coords[3]==0) + { + + if(quads.containsKey(i+1)) + { + + drawVertex(xWorld+coords[0]+.5, yWorld+coords[1]-width/2 , zWorld+coords[2]); + drawVertex(xWorld+coords[0]+.5 , yWorld+coords[1]+width/2 , zWorld+coords[2]); + + + + } + else + { + drawVertex(xWorld+coords[0]+.5, yWorld+coords[1]-width/200 , zWorld+coords[2]); + drawVertex(xWorld+coords[0]+.5 , yWorld+coords[1]+width/200 , zWorld+coords[2]); + } + } + else + { + + + + if(quads.containsKey(i+1)) + { + drawVertex(xWorld+coords[0], yWorld+coords[1]-width/2 , zWorld+coords[2]+.5); + drawVertex(xWorld+coords[0], yWorld+coords[1]+width/2 , zWorld+coords[2]+.5); + + + } + else + { + drawVertex(xWorld+coords[0], yWorld+coords[1]+width/200 , zWorld+coords[2]+.5); + drawVertex(xWorld+coords[0], yWorld+coords[1]-width/200, zWorld+coords[2]+.5); + } + + + } + + } + + + GL11.glEnd(); + + + } + + public void drawCrackRotated(HashMap quads,double xWorld,double yWorld,double zWorld) + { + GL11.glBegin(GL11.GL_QUAD_STRIP); + + drawVertex(xWorld+.5, yWorld+Math.log(quads.size()+1)/8, zWorld+.5); + drawVertex(xWorld+.5, yWorld-Math.log(quads.size()+1)/8, zWorld+.5); + for(int i = 0;;i++) + { + if(!quads.containsKey(i)) + { + break; + } + double[] coords = quads.get(i); + double width=Math.log(quads.size()-i+1)/8; + if(coords[3]==0) + { + + + if(quads.containsKey(i+1)) + { + drawVertex(xWorld+coords[0]+.5, yWorld-(coords[1]-width/2) , zWorld-coords[2]+1); + drawVertex(xWorld+coords[0]+.5 , yWorld-(coords[1]+width/2) , zWorld-coords[2]+1); + + } + else + { + + drawVertex(xWorld+coords[0]+.5, yWorld-(coords[1]-width/200) , zWorld-coords[2]+1); + drawVertex(xWorld+coords[0]+.5 , yWorld-(coords[1]+width/200) , zWorld-coords[2]+1); + } + + } + else + { + + + if(quads.containsKey(i+1)) + { + + drawVertex(xWorld-coords[0]+1, yWorld-(coords[1]-width/2) , zWorld+coords[2]+.5); + drawVertex(xWorld-coords[0]+1, yWorld-(coords[1]+width/2) , zWorld+coords[2]+.5); + + } + else + { + drawVertex(xWorld-coords[0]+1, yWorld-(coords[1]+width/200) , zWorld+coords[2]+.5); + drawVertex(xWorld-coords[0]+1, yWorld-(coords[1]-width/200), zWorld+coords[2]+.5); + } + + } + } + + GL11.glEnd(); + } + + public void testDraw(HashMap quads,double xWorld,double yWorld,double zWorld) + { + GL11.glBegin(GL11.GL_QUADS); + for(int i = 0;;i++) + { + + if(!quads.containsKey(i)) + { + break; + } + double[] coords = quads.get(i); + drawVertex(xWorld-coords[0], yWorld , zWorld+.1); + drawVertex(xWorld-coords[0], yWorld+.1 , zWorld+.1); + drawVertex(xWorld-coords[0], yWorld +.1, zWorld); + drawVertex(xWorld-coords[0], yWorld , zWorld); + + + } + GL11.glEnd(); + + } + public void drawVertex(double x, double y, double z) + { + GL11.glVertex3f((float)x,(float)y,(float)z); + } + public double[] rotateCoords(int rotation, double[] coords) + { + double[] rotatedCoords = new double[4]; + if(rotation == 180) + { + + + rotatedCoords[0]=-coords[0]; + rotatedCoords[1]=-coords[1]; + + rotatedCoords[2]=-coords[2]; + rotatedCoords[3]=-coords[3]; + //return rotatedCoords; + } + return coords; + + } +} \ No newline at end of file