use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.
the class RenderingUtils method renderFacingQuadVB.
public static void renderFacingQuadVB(BufferBuilder vb, double px, double py, double pz, float partialTicks, float scale, float angle, double u, double v, double uLength, double vLength, float colorRed, float colorGreen, float colorBlue, float alpha) {
float arX = ActiveRenderInfo.getRotationX();
float arZ = ActiveRenderInfo.getRotationZ();
float arYZ = ActiveRenderInfo.getRotationYZ();
float arXY = ActiveRenderInfo.getRotationXY();
float arXZ = ActiveRenderInfo.getRotationXZ();
Entity e = Minecraft.getMinecraft().getRenderViewEntity();
if (e == null) {
e = Minecraft.getMinecraft().player;
}
double iPX = e.prevPosX + (e.posX - e.prevPosX) * partialTicks;
double iPY = e.prevPosY + (e.posY - e.prevPosY) * partialTicks;
double iPZ = e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks;
Vector3 v1 = new Vector3(-arX * scale - arYZ * scale, -arXZ * scale, -arZ * scale - arXY * scale);
Vector3 v2 = new Vector3(-arX * scale + arYZ * scale, arXZ * scale, -arZ * scale + arXY * scale);
Vector3 v3 = new Vector3(arX * scale + arYZ * scale, arXZ * scale, arZ * scale + arXY * scale);
Vector3 v4 = new Vector3(arX * scale - arYZ * scale, -arXZ * scale, arZ * scale - arXY * scale);
if (angle != 0.0F) {
Vector3 pvec = new Vector3(iPX, iPY, iPZ);
Vector3 tvec = new Vector3(px, py, pz);
Vector3 qvec = pvec.subtract(tvec).normalize();
Vector3.Quat q = Vector3.Quat.buildQuatFrom3DVector(qvec, angle);
q.rotateWithMagnitude(v1);
q.rotateWithMagnitude(v2);
q.rotateWithMagnitude(v3);
q.rotateWithMagnitude(v4);
}
vb.pos(px + v1.getX() - iPX, py + v1.getY() - iPY, pz + v1.getZ() - iPZ).tex(u + uLength, v + vLength).color(colorRed, colorGreen, colorBlue, alpha).endVertex();
vb.pos(px + v2.getX() - iPX, py + v2.getY() - iPY, pz + v2.getZ() - iPZ).tex(u + uLength, v).color(colorRed, colorGreen, colorBlue, alpha).endVertex();
vb.pos(px + v3.getX() - iPX, py + v3.getY() - iPY, pz + v3.getZ() - iPZ).tex(u, v).color(colorRed, colorGreen, colorBlue, alpha).endVertex();
vb.pos(px + v4.getX() - iPX, py + v4.getY() - iPY, pz + v4.getZ() - iPZ).tex(u, v + vLength).color(colorRed, colorGreen, colorBlue, alpha).endVertex();
}
use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.
the class RenderingUtils method getStandartTranslationRemovalVector.
public static Vector3 getStandartTranslationRemovalVector(float partialTicks) {
Entity rView = Minecraft.getMinecraft().getRenderViewEntity();
if (rView == null)
rView = Minecraft.getMinecraft().player;
Entity entity = rView;
double tx = entity.lastTickPosX + ((entity.posX - entity.lastTickPosX) * partialTicks);
double ty = entity.lastTickPosY + ((entity.posY - entity.lastTickPosY) * partialTicks);
double tz = entity.lastTickPosZ + ((entity.posZ - entity.lastTickPosZ) * partialTicks);
return new Vector3(-tx, -ty, -tz);
}
use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class EffectLightning method buildLightning.
public static EffectLightning buildLightning(long seed, Vector3 source, Vector3 destination, float minJitterDistance, float maxJitterDistance, float forkChance, float minForkAngle, float maxForkAngle) {
Vector3 directionVector = destination.clone().subtract(source);
Random lightningSeed = new Random(seed);
java.util.List<LightningVertex> rootVertices = Lists.newLinkedList();
LightningVertex root = new LightningVertex(source);
root.next.add(new LightningVertex(destination));
rootVertices.add(root);
double l = directionVector.length();
int iterations = MathHelper.floor(Math.round(Math.sqrt(l)));
for (int i = 0; i < iterations; i++) {
LinkedList<LightningVertex> newRootVertices = new LinkedList<>();
for (LightningVertex sourceVertex : rootVertices) {
LinkedList<LightningVertex> newNext = new LinkedList<>();
for (LightningVertex nextVertex : Lists.newArrayList(sourceVertex.next)) {
Vector3 direction = nextVertex.offset.clone().subtract(sourceVertex.offset);
Vector3 split = direction.clone().multiply(0.5F).add(sourceVertex.offset);
float jitDst = (minJitterDistance + (maxJitterDistance - minJitterDistance) * lightningSeed.nextFloat()) * ((float) (iterations - i) / ((float) iterations));
Vector3 axPerp = direction.clone().perpendicular().rotate(lightningSeed.nextFloat() * 2 * Math.PI, direction).normalize().multiply(jitDst);
split.add(axPerp);
LightningVertex newVertex = new LightningVertex(split);
newVertex.next.add(nextVertex);
newNext.add(newVertex);
if (lightningSeed.nextFloat() < forkChance) {
Vector3 dirFork = split.clone().subtract(sourceVertex.offset);
float forkAngle = minForkAngle + (maxForkAngle - minForkAngle) * lightningSeed.nextFloat();
forkAngle = (float) Math.toRadians(forkAngle);
Vector3 perpAxis = dirFork.clone().perpendicular().rotate(lightningSeed.nextFloat() * 2 * Math.PI, dirFork);
Vector3 dirPos = dirFork.clone().rotate(forkAngle, perpAxis).normalize().multiply(dirFork.length() * 3D / 4D).add(split);
LightningVertex forkVertex = new LightningVertex(dirPos);
newVertex.next.add(forkVertex);
}
newRootVertices.add(newVertex);
}
sourceVertex.next = newNext;
newRootVertices.add(sourceVertex);
}
rootVertices = newRootVertices;
}
return new EffectLightning(root);
}
use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class EntityFXFloatingCube method render.
@Override
public void render(float partialTicks) {
TextureHelper.refreshTextureBindState();
texture.bind();
GlStateManager.pushMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.enableBlend();
Blending.DEFAULT.apply();
Blending.DEFAULT.applyStateManager();
GlStateManager.disableCull();
GlStateManager.depthMask(false);
GlStateManager.disableAlpha();
RenderingUtils.removeStandartTranslationFromTESRMatrix(partialTicks);
Vector3 translateTo = getInterpolatedPosition(partialTicks);
GL11.glTranslated(translateTo.getX(), translateTo.getY(), translateTo.getZ());
float alpha = alphaFunction.getAlpha(age, maxAge);
alpha *= alphaMultiplier;
GlStateManager.color(colorRed, colorGreen, colorBlue, alpha);
float scaleF = this.scale;
scaleF = scaleFunction.getScale(this, partialTicks, scaleF);
GlStateManager.scale(scaleF, scaleF, scaleF);
Vector3 rotation = getInterpolatedRotation(partialTicks);
GlStateManager.rotate((float) rotation.getX(), 1, 0, 0);
GlStateManager.rotate((float) rotation.getY(), 0, 1, 0);
GlStateManager.rotate((float) rotation.getZ(), 0, 0, 1);
RenderingUtils.renderTexturedCubeCentral(new Vector3(), 1, 0, 0, 1, 1);
GlStateManager.enableAlpha();
GlStateManager.depthMask(true);
GlStateManager.enableCull();
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.popMatrix();
TextureHelper.refreshTextureBindState();
}
use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class TileFissureDevice method playEffects.
@SideOnly(Side.CLIENT)
private void playEffects() {
int depth = getStructureDepth();
if (depth > 0) {
if (headFloatingCube1 == null || ((EntityFXFloatingCube) headFloatingCube1).isRemoved()) {
headFloatingCube1 = setupCube(0.35F, 0.3F);
}
if (headFloatingCube2 == null || ((EntityFXFloatingCube) headFloatingCube2).isRemoved()) {
headFloatingCube2 = setupCube(0.3F, 0.2F);
}
if (headFloatingCube3 == null || ((EntityFXFloatingCube) headFloatingCube3).isRemoved()) {
headFloatingCube3 = setupCube(0.25F, 0.04F);
}
handleAnimations(headFloatingCube1);
handleAnimations(headFloatingCube2);
handleAnimations(headFloatingCube3);
if (this.percActive >= 1F && rand.nextFloat() >= 0.8F) {
EffectLightning lightning = EffectHandler.getInstance().lightning(new Vector3(0.4 + rand.nextFloat() * 0.2, 0.1 - depth, 0.4 + rand.nextFloat() * 0.2).add(getPos()), new Vector3(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).add(getPos()));
lightning.setOverlayColor(new Color(0x2DE400));
}
if (this.percActive > 0) {
for (int i = 0; i < depth * 6; i++) {
if (rand.nextFloat() <= this.percActive) {
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).addY(-rand.nextFloat() * (0.3 + depth)));
p.setScale(0.05F + rand.nextFloat() * 0.05F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.006F));
EffectHandler.getInstance().registerFX(p);
}
}
}
FissureData otherData = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
playOuterCube(otherData);
if (this.percDrawFissure > 0 && otherData != null) {
if (percDrawFissure < 1F) {
float chance = 1F - Math.abs((percDrawFissure - 0.5F) * 1.6F);
for (int i = 0; i < 19; i++) {
if (rand.nextFloat() < chance) {
Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(Vector3.random().multiply(2.5)).addY(1.3);
Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-15);
EntityFXFacingParticle p = new EntityFXFacingParticle(30);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(particlePos);
p.setScale(0.03F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.85F);
p.setMotion(dir);
EffectHandler.getInstance().registerFX(p);
}
}
} else {
Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
Vector3 randPos = new Vector3(otherData.getMin());
randPos.addX(vecSub.getX() * rand.nextFloat());
randPos.addY(vecSub.getY() * rand.nextFloat());
randPos.addZ(vecSub.getZ() * rand.nextFloat());
randPos.add(getPos());
EntityFXFacingParticle p = new EntityFXFacingParticle(60);
p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
p.setColor(new Color(0x2DE400));
p.setPosition(randPos);
p.setScale(0.02F + rand.nextFloat() * 0.03F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.01F));
EffectHandler.getInstance().registerFX(p);
for (int i = 0; i < 4; i++) {
p = new EntityFXFacingParticle(40);
p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
p.setColor(new Color(0x2DE400));
p.setPosition(new Vector3(getPos()).add(0.5, 1.3, 0.5));
p.setScale(0.015F + rand.nextFloat() * 0.02F);
p.setAlphaMultiplier(0.75F);
p.setMotion(Vector3.random().multiply(0.015F));
EffectHandler.getInstance().registerFX(p);
}
if (rand.nextInt(6) == 0) {
Vector3 randFrom = new Vector3(otherData.getMin());
randFrom.addX(vecSub.getX() * rand.nextFloat());
randFrom.addY(vecSub.getY() * rand.nextFloat());
randFrom.addZ(vecSub.getZ() * rand.nextFloat());
randFrom.add(getPos());
Vector3 randTo = new Vector3(otherData.getMin());
randTo.addX(vecSub.getX() * rand.nextFloat());
randTo.addY(vecSub.getY() * rand.nextFloat());
randTo.addZ(vecSub.getZ() * rand.nextFloat());
randTo.add(getPos());
Vector3 dst = randTo.clone().subtract(randFrom);
if (dst.length() > 6) {
dst.normalize().multiply(6);
}
EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
eff.setOverlayColor(new Color(0x2DE400));
}
}
}
}
}
Aggregations