Search in sources :

Example 16 with Vector3

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);
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Example 17 with Vector3

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();
    }
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Example 18 with Vector3

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);
    }
}
Also used : EffectLightning(hellfirepvp.fracture.client.effect.fx.EffectLightning) Vector3(hellfirepvp.fracture.common.util.Vector3) EntityFXFacingParticle(hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)

Example 19 with Vector3

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);
}
Also used : Random(java.util.Random) Vector3(hellfirepvp.fracture.common.util.Vector3) LinkedList(java.util.LinkedList)

Example 20 with Vector3

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();
    }
}
Also used : Vector3(hellfirepvp.fracture.common.util.Vector3)

Aggregations

Vector3 (hellfirepvp.fracture.common.util.Vector3)23 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)4 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)4 EntityFXFloatingCube (hellfirepvp.fracture.client.effect.fx.EntityFXFloatingCube)4 Entity (net.minecraft.entity.Entity)4 FissureData (hellfirepvp.fracture.common.fissure.FissureData)3 LinkedList (java.util.LinkedList)3 Random (java.util.Random)2 Vec3i (net.minecraft.util.math.Vec3i)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1