render effect iteration
This commit is contained in:
parent
04ec4b3d2d
commit
dc7a19c2f3
5 changed files with 150 additions and 132 deletions
|
@ -307,99 +307,16 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random rand)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
|
||||
{
|
||||
|
||||
int count;
|
||||
//growth in the direction towards the nearby rift
|
||||
float xGrowth=0;
|
||||
float yGrowth=0;
|
||||
float zGrowth=0;
|
||||
//growth away from the nearby rift
|
||||
float xGrowthn=0;
|
||||
float yGrowthn=0;
|
||||
float zGrowthn=0;
|
||||
//how far the particles are away from original rift. Used to decrease noise the farther they are away.
|
||||
float xChange = 0;
|
||||
float yChange = 0;
|
||||
float zChange = 0;
|
||||
|
||||
TileEntityRift tile = (TileEntityRift)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
float Xoffset=0;
|
||||
float Yoffset=0;
|
||||
float Zoffset=0;
|
||||
for (count = 0; count < 12 && tile!=null; ++count)
|
||||
{
|
||||
//TODO change to a switch statement for clarity
|
||||
if(tile.xOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.xOffset)==0)
|
||||
{
|
||||
xGrowth =xGrowth+.15F*tile.xOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.xOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.xOffset)==0)
|
||||
{
|
||||
xGrowthn =xGrowthn-.15F*-tile.xOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.yOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.yOffset)==0)
|
||||
{
|
||||
yGrowth =yGrowth+.15F*tile.yOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.yOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.yOffset)==0)
|
||||
{
|
||||
yGrowthn =yGrowthn-.15F*-tile.yOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.zOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.zOffset)==0)
|
||||
{
|
||||
zGrowth =zGrowth+.15F*tile.zOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.zOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.zOffset)==0)
|
||||
{
|
||||
zGrowthn =zGrowthn-.15F*-tile.zOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xChange=(float) ((xGrowth+xGrowthn)+rand.nextGaussian()*.05F);
|
||||
yChange=(float) ((yGrowth+yGrowthn)+rand.nextGaussian()*.05F);
|
||||
zChange=(float) ((zGrowth+zGrowthn)+rand.nextGaussian()*.05F);
|
||||
|
||||
Xoffset= ((0.25F/(1+Math.abs(xChange))));
|
||||
|
||||
Yoffset= ((0.25F/(1+Math.abs(yChange))));
|
||||
Zoffset= ((0.25F/(1+Math.abs(zChange))));
|
||||
|
||||
|
||||
|
||||
|
||||
//FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftFX(par1World,par2+.5+xChange+Xoffset*rand.nextGaussian(), par3+.5+yChange+Yoffset*rand.nextGaussian() , par4+.5+zChange+Zoffset*rand.nextGaussian(), rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
// FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftFX(par1World,par2+.5-xChange-Xoffset*rand.nextGaussian(), par3+.5-yChange-Yoffset*rand.nextGaussian() , par4+.5-zChange-Zoffset*rand.nextGaussian(), rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
|
||||
|
||||
|
||||
ArrayList<Point3D> targets=findReachableBlocks(world, x, y, z, 2, false);
|
||||
|
||||
|
||||
TileEntityRift tile = (TileEntityRift)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
|
||||
if(rand.nextBoolean())
|
||||
{
|
||||
//renders an extra little blob on top of the actual rift location so its easier to find. Eventually will only render if the player has the goggles.
|
||||
|
@ -408,10 +325,10 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||
if(tile.shouldClose)
|
||||
{
|
||||
//renders an opposite color effect if it is being closed by the rift remover
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(par1World,par2+.5, par3+.5, par4+.5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(world,x+.5, y+.5, z+.5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean tryPlacingRift(World world, int x, int y, int z)
|
||||
|
|
|
@ -327,15 +327,33 @@ public class mod_pocketDim
|
|||
proxy.loadTextures();
|
||||
proxy.registerRenderers();
|
||||
|
||||
|
||||
LSystem.generateLSystem("terdragon 9", LSystem.TERDRAGON, 9);
|
||||
LSystem.generateLSystem("terdragon 8", LSystem.TERDRAGON, 8);
|
||||
LSystem.generateLSystem("terdragon 7", LSystem.TERDRAGON, 7);
|
||||
LSystem.generateLSystem("terdragon 6", LSystem.TERDRAGON, 6);
|
||||
LSystem.generateLSystem("terdragon 5", LSystem.TERDRAGON, 5);
|
||||
LSystem.generateLSystem("terdragon 4", LSystem.TERDRAGON, 4);
|
||||
LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 4);
|
||||
LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 5);
|
||||
// LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 6); //degenerate
|
||||
LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 7);
|
||||
// LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 8);
|
||||
// LSystem.generateLSystem("terdragon", LSystem.TERDRAGON, 9);
|
||||
|
||||
LSystem.generateLSystem("dragon 15", LSystem.DRAGON, 15);
|
||||
|
||||
// LSystem.generateLSystem("vortex", LSystem.VORTEX, 8);
|
||||
LSystem.generateLSystem("vortex", LSystem.VORTEX, 9);
|
||||
LSystem.generateLSystem("vortex", LSystem.VORTEX, 10);
|
||||
LSystem.generateLSystem("vortex", LSystem.VORTEX, 11);
|
||||
// LSystem.generateLSystem("vortex", LSystem.VORTEX, 12);
|
||||
|
||||
LSystem.generateLSystem("twindragon", LSystem.TWINDRAGON, 7);
|
||||
LSystem.generateLSystem("twindragon", LSystem.TWINDRAGON, 8);
|
||||
LSystem.generateLSystem("twindragon", LSystem.TWINDRAGON, 9);
|
||||
LSystem.generateLSystem("twindragon", LSystem.TWINDRAGON, 10);
|
||||
// LSystem.generateLSystem("twindragon", LSystem.TWINDRAGON, 11);
|
||||
|
||||
|
||||
LSystem.generateLSystem("dragon", LSystem.DRAGON, 8);
|
||||
LSystem.generateLSystem("dragon", LSystem.DRAGON, 9);
|
||||
LSystem.generateLSystem("dragon", LSystem.DRAGON, 10);
|
||||
LSystem.generateLSystem("dragon", LSystem.DRAGON, 11);
|
||||
// LSystem.generateLSystem("dragon", LSystem.DRAGON, 12);
|
||||
// LSystem.generateLSystem("dragon", LSystem.DRAGON, 13);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.network.INetworkManager;
|
|||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||
|
@ -18,6 +19,8 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
|
|||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.util.l_systems.LSystem;
|
||||
import StevenDimDoors.mod_pocketDim.util.l_systems.LSystem.PolygonStorage;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||
|
||||
public class TileEntityRift extends DDTileEntityBase
|
||||
|
@ -44,7 +47,10 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
public boolean shouldClose = false;
|
||||
public Point4D nearestRiftLocation = null;
|
||||
public int spawnedEndermenID = 0;
|
||||
|
||||
public int riftRotation;
|
||||
public int renderKey;
|
||||
public int growth;
|
||||
|
||||
public TileEntityRift()
|
||||
{
|
||||
|
@ -52,6 +58,7 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
// from updating at the same time.
|
||||
updateTimer = random.nextInt(UPDATE_PERIOD);
|
||||
this.riftRotation = random.nextInt(360);
|
||||
this.renderKey = random.nextInt(LSystem.curves.size());
|
||||
|
||||
}
|
||||
|
||||
|
@ -96,6 +103,7 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
updateNearestRift();
|
||||
spread(mod_pocketDim.properties);
|
||||
}
|
||||
growth++;
|
||||
updateTimer++;
|
||||
}
|
||||
|
||||
|
@ -256,6 +264,8 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
this.shouldClose = nbt.getBoolean("shouldClose");
|
||||
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
||||
this.riftRotation = nbt.getInteger("riftRotation");
|
||||
this.renderKey = nbt.getInteger("renderKey");
|
||||
this.growth = nbt.getInteger("growth");
|
||||
|
||||
}
|
||||
|
||||
|
@ -269,8 +279,10 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
nbt.setInteger("zOffset", this.zOffset);
|
||||
nbt.setBoolean("shouldClose", this.shouldClose);
|
||||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||
|
||||
nbt.setInteger("renderKey", this.renderKey);
|
||||
nbt.setInteger("riftRotation", this.riftRotation);
|
||||
nbt.setInteger("growth", this.growth);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -294,4 +306,11 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public PolygonStorage getCurve()
|
||||
{
|
||||
|
||||
|
||||
return (LSystem.curves.get(renderKey));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.poly2tri.triangulation.delaunay.DelaunayTriangle;
|
|||
|
||||
public class LSystem
|
||||
{
|
||||
public static HashMap<String, PolygonStorage> curves = new HashMap<String, PolygonStorage>();
|
||||
public static ArrayList<PolygonStorage> curves = new ArrayList<PolygonStorage>();
|
||||
|
||||
/**
|
||||
* An array containing the args to generate a curve.
|
||||
|
@ -26,6 +26,8 @@ public class LSystem
|
|||
*/
|
||||
public static final String[] TERDRAGON = {"F>+F----F++++F-","60","F"};
|
||||
public static final String[] DRAGON = {"X>X+YF:Y>FX-Y","90","FX"};
|
||||
public static final String[] TWINDRAGON = {"X>X+YF:Y>FX-Y","90","FX--FX"};
|
||||
public static final String[] VORTEX = {"X>X+YF:Y>FX-Y","90","FX---FX"};
|
||||
|
||||
|
||||
|
||||
|
@ -64,7 +66,61 @@ public class LSystem
|
|||
//replace the boundary of the polygon with a series of points representing triangles for rendering
|
||||
polygon.points = tesselate(polygon);
|
||||
|
||||
curves.put(key, polygon);
|
||||
curves.add(polygon);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Naively returns all of the points comprising the fractal
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static PolygonStorage getSpaceFillingCurve(ArrayList<double[]> input)
|
||||
{
|
||||
// store max x and y values to create bounding box
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int minX = Integer.MAX_VALUE;
|
||||
|
||||
// store confirmed duplicates here
|
||||
HashSet<Point> duplicates = new HashSet<Point>();
|
||||
|
||||
// store possible singles here
|
||||
HashSet<Point> singles = new HashSet<Point>();
|
||||
|
||||
// list to store confirmed singles and output in the correct order
|
||||
ArrayList<Point> output = new ArrayList<Point>();
|
||||
|
||||
// sort into Hashmaps and hashsets to make contains operations possible,
|
||||
// while testing for duplicates
|
||||
for (double[] point : input)
|
||||
{
|
||||
// convert doubles to ints and record min/max values
|
||||
|
||||
int xCoord = (int) Math.round(point[0]);
|
||||
int yCoord = (int) Math.round(point[1]);
|
||||
|
||||
if (xCoord > maxX)
|
||||
{
|
||||
maxX = xCoord;
|
||||
}
|
||||
if (xCoord < minX)
|
||||
{
|
||||
minX = xCoord;
|
||||
}
|
||||
|
||||
if (yCoord > maxY)
|
||||
{
|
||||
maxY = yCoord;
|
||||
}
|
||||
if (yCoord < minY)
|
||||
{
|
||||
minY = yCoord;
|
||||
}
|
||||
output.add(new Point(xCoord, yCoord));
|
||||
}
|
||||
return new PolygonStorage(output, maxX, maxY, minX, minY);
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,7 +161,7 @@ public class LSystem
|
|||
{
|
||||
maxX = xCoord;
|
||||
}
|
||||
else if (xCoord < minX)
|
||||
if (xCoord < minX)
|
||||
{
|
||||
minX = xCoord;
|
||||
}
|
||||
|
@ -114,7 +170,7 @@ public class LSystem
|
|||
{
|
||||
maxY = yCoord;
|
||||
}
|
||||
else if (yCoord < minY)
|
||||
if (yCoord < minY)
|
||||
{
|
||||
minY = yCoord;
|
||||
}
|
||||
|
|
|
@ -28,15 +28,16 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL_LIGHTING);
|
||||
|
||||
GL11.glEnable(GL_BLEND);
|
||||
/**
|
||||
* GL11.glLogicOp(GL11.GL_INVERT);
|
||||
* GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
|
||||
*/
|
||||
|
||||
TileEntityRift rift = (TileEntityRift) te;
|
||||
// draws the verticies corresponding to the passed it
|
||||
this.drawCrack(((TileEntityRift) te).riftRotation, LSystem.curves.get("terdragon 7"), 3, xWorld, yWorld, zWorld);
|
||||
this.drawCrack(rift.riftRotation, rift.getCurve(), Math.log(2+rift.growth)/5D, xWorld, yWorld, zWorld);
|
||||
|
||||
GL11.glDisable(GL_BLEND);
|
||||
// reenable all the stuff we disabled
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
@ -68,24 +69,26 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||
double offsetZ = 0;
|
||||
|
||||
// changes how far the triangles move
|
||||
float motionMagnitude = 2.0F;
|
||||
float motionMagnitude = 3.0F;
|
||||
|
||||
// changes how quickly the triangles move
|
||||
float motionSpeed = 800.0F;
|
||||
float motionSpeed = 2000.0F;
|
||||
|
||||
// number of individual jitter waveforms to generate
|
||||
// changes how "together" the overall motions are
|
||||
int jCount = 10;
|
||||
int jCount = 5;
|
||||
|
||||
// Calculate jitter like for monoliths
|
||||
float time = (float) (((Minecraft.getSystemTime() + 0xF1234568 * this.hashCode()) % 2000000) / motionSpeed);
|
||||
double[] jitters = new double[jCount];
|
||||
|
||||
// generate a series of waveforms
|
||||
for (int i = 0; i < jCount; i += 2)
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// determines which jitter waveform we select. Modulo so the same point
|
||||
|
@ -95,25 +98,25 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||
// set the color for the render
|
||||
GL11.glColor4f(.3F, .3F, .3F, 1F);
|
||||
|
||||
//set the blending mode
|
||||
GL11.glEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
|
||||
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||
|
||||
// start rendering triangles for the moving shards
|
||||
/**best ones so far
|
||||
* glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
* glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
*/
|
||||
glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
GL11.glBegin(GL11.GL_TRIANGLES);
|
||||
for (Point p : poly.points)
|
||||
{
|
||||
jIndex = Math.abs(p.x+p.y);
|
||||
|
||||
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]
|
||||
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]);
|
||||
double z = (((p.x + jitters[(jIndex + 2) % jCount]) - offsetX) * Math.sin(Math.toRadians(riftRotation)) + 0 * Math
|
||||
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;
|
||||
|
@ -131,15 +134,19 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||
}
|
||||
GL11.glEnd();
|
||||
|
||||
//GL11.glDisable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
|
||||
//glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||
|
||||
/**
|
||||
GL11.glBegin(GL11.GL_TRIANGLES);
|
||||
|
||||
/**best one so far
|
||||
* glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
|
||||
* 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);
|
||||
for (Point p : poly.points)
|
||||
{
|
||||
jIndex++;
|
||||
|
@ -160,13 +167,14 @@ public class RenderRift extends TileEntitySpecialRenderer
|
|||
// stationary shards
|
||||
if (jIndex % 3 == 0)
|
||||
{
|
||||
GL11.glColor4d(jitters[(jIndex + 1) % jCount] / 11, jitters[(jIndex + 2) % jCount] / 8, jitters[(jIndex) % jCount] / 8, 1);
|
||||
// GL11.glColor4d(jitters[(jIndex + 1) % jCount]/8F , jitters[(jIndex + 2) % jCount] /8F, jitters[(jIndex) % jCount]/8F , 1);
|
||||
}
|
||||
|
||||
GL11.glVertex3d(xWorld + x, yWorld + y, zWorld + z);
|
||||
}
|
||||
|
||||
// stop drawing triangles
|
||||
GL11.glEnd();
|
||||
**/
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue