use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class EntityFXFacingParticle method renderBatched.
private void renderBatched(float partial, BufferBuilder vb) {
float alpha = alphaFunction.getAlpha(age, maxAge);
alpha *= alphaMultiplier;
Vector3 iPos = RenderingUtils.interpolateVec(this.prevPos, this.pos, partial);
RenderingUtils.renderFacingFullQuadVB(vb, iPos.getX(), iPos.getY(), iPos.getZ(), partial, scale, 0, colorRed, colorGreen, colorBlue, alpha);
}
use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class EntityFXFloatingCube method tick.
@Override
public void tick() {
super.tick();
if (tumbleIntensityMultiplier > 0 && this.rotationChange.lengthSquared() > 0) {
Vector3 degAxis = rotationDegreeAxis.clone();
Vector3 modify = this.rotationChange.clone().multiply(tumbleIntensityMultiplier);
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone();
this.rotationDegreeAxis.add(modify);
Vector3 newDegAxis = rotationDegreeAxis;
newDegAxis.setX(newDegAxis.getX() % 360D).setY(newDegAxis.getY() % 360D).setZ(newDegAxis.getZ() % 360D);
if (!degAxis.add(modify).equals(newDegAxis)) {
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone().subtract(modify);
}
} else {
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone();
}
}
use of hellfirepvp.fracture.common.util.Vector3 in project SomeModjam5Mod by HellFirePvP.
the class EffectHandler method tick.
public void tick() {
if (cleanRequested) {
for (Integer layer : complexEffects.keySet()) {
List<EntityFX> effects = complexEffects.get(layer);
effects.forEach(EntityFX::flagAsRemoved);
effects.clear();
}
fastRenderParticles.clear();
fastRenderLightnings.clear();
toAddBuffer.clear();
cleanRequested = false;
}
if (Minecraft.getMinecraft().player == null) {
return;
}
acceptsNewParticles = false;
for (Integer layer : complexEffects.keySet()) {
Iterator<EntityFX> iterator = complexEffects.get(layer).iterator();
while (iterator.hasNext()) {
EntityFX effect = iterator.next();
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
iterator.remove();
}
}
}
Vector3 playerPos = Vector3.atEntityCenter(Minecraft.getMinecraft().player);
for (EntityFXFacingParticle effect : new ArrayList<>(fastRenderParticles)) {
if (effect == null) {
fastRenderParticles.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval() || effect.getPosition().distanceSquared(playerPos) >= Config.maxEffectRenderDistanceSq) {
effect.flagAsRemoved();
fastRenderParticles.remove(effect);
}
}
for (EffectLightning effect : new ArrayList<>(fastRenderLightnings)) {
if (effect == null) {
fastRenderLightnings.remove(null);
continue;
}
effect.tick();
if (effect.needsRemoval()) {
effect.flagAsRemoved();
fastRenderLightnings.remove(effect);
}
}
acceptsNewParticles = true;
List<EntityFX> effects = new LinkedList<>(toAddBuffer);
toAddBuffer.clear();
for (EntityFX eff : effects) {
registerUnsafe(eff);
}
}
use of hellfirepvp.fracture.common.util.Vector3 in project Fracture 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 Fracture by HellFirePvP.
the class EntityFXFloatingCube method tick.
@Override
public void tick() {
super.tick();
if (tumbleIntensityMultiplier > 0 && this.rotationChange.lengthSquared() > 0) {
Vector3 degAxis = rotationDegreeAxis.clone();
Vector3 modify = this.rotationChange.clone().multiply(tumbleIntensityMultiplier);
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone();
this.rotationDegreeAxis.add(modify);
Vector3 newDegAxis = rotationDegreeAxis;
newDegAxis.setX(newDegAxis.getX() % 360D).setY(newDegAxis.getY() % 360D).setZ(newDegAxis.getZ() % 360D);
if (!degAxis.add(modify).equals(newDegAxis)) {
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone().subtract(modify);
}
} else {
this.prevRotationDegreeAxis = this.rotationDegreeAxis.clone();
}
}
Aggregations