Parameterize the chaos of a pattern
This commit is contained in:
parent
6b7be0a8cf
commit
82cafe098e
7 changed files with 11 additions and 10 deletions
|
@ -135,9 +135,10 @@ object RenderLib {
|
|||
drawLast: Boolean,
|
||||
tail: Int,
|
||||
head: Int,
|
||||
flowIrregular: Float,
|
||||
animTime: Float? = null
|
||||
) {
|
||||
val zappyPts = makeZappy(points, 10f, 2.5f, 0.1f)
|
||||
val zappyPts = makeZappy(points, 10f, 2.5f, 0.1f, flowIrregular)
|
||||
val nodes = if (drawLast) {
|
||||
points
|
||||
} else {
|
||||
|
@ -164,7 +165,7 @@ object RenderLib {
|
|||
* @param speed: rate at which the lightning effect should move/shake/etc
|
||||
*/
|
||||
@JvmStatic
|
||||
fun makeZappy(points: List<Vec2>, hops: Float, variance: Float, speed: Float): List<Vec2> {
|
||||
fun makeZappy(points: List<Vec2>, hops: Float, variance: Float, speed: Float, flowIrregular: Float): List<Vec2> {
|
||||
// Nothing in, nothing out
|
||||
if (points.isEmpty()) {
|
||||
return emptyList()
|
||||
|
@ -190,7 +191,7 @@ object RenderLib {
|
|||
// as well as some random variance...
|
||||
// (We use i, j (segment #, subsegment #) as seeds for the Perlin noise,
|
||||
// and zSeed (i.e. time elapsed) to perturb the shape gradually over time)
|
||||
val minorPerturb = NOISE.getValue(i.toDouble(), j.toDouble(), Math.sin(zSeed)) * 0.5
|
||||
val minorPerturb = NOISE.getValue(i.toDouble(), j.toDouble(), Math.sin(zSeed)) * flowIrregular
|
||||
val theta = (3 * NOISE.getValue(i.toDouble() + j.toDouble() / (hops + 1) + minorPerturb - zSeed, 1337.0, 0.0) * HexUtils.TAU).toFloat()
|
||||
val r = (NOISE.getValue(i.toDouble() + j.toDouble() / (hops + 1) - zSeed, 69420.0, 0.0) * maxVariance * scaleVariance(progress)).toFloat()
|
||||
val randomHop = Vec2(r * Mth.cos(theta), r * Mth.sin(theta))
|
||||
|
|
|
@ -73,7 +73,7 @@ public class BlockEntityAkashicBookshelfRenderer implements BlockEntityRenderer<
|
|||
lines2.set(j, new Vec2(-v.x, v.y));
|
||||
}
|
||||
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, 0.5f, 0f);
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, 0.5f, 0f, 0f);
|
||||
|
||||
int outer = 0xff_d2c8c8;
|
||||
int inner = 0xc8_322b33;
|
||||
|
|
|
@ -84,7 +84,7 @@ public class BlockEntitySlateRenderer implements BlockEntityRenderer<BlockEntity
|
|||
}
|
||||
|
||||
var isLit = bs.getValue(BlockSlate.ENERGIZED);
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, isLit ? 2.5f : 0.5f, isLit ? 0.1f : 0f);
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, isLit ? 2.5f : 0.5f, isLit ? 0.1f : 0f, 0.2f);
|
||||
|
||||
int outer = isLit ? 0xff_64c8ff : 0xff_d2c8c8;
|
||||
int inner = isLit ? RenderLib.screenCol(outer) : 0xc8_322b33;
|
||||
|
|
|
@ -296,7 +296,7 @@ class GuiSpellcasting(
|
|||
RenderLib.drawPatternFromPoints(mat, pat.toLines(
|
||||
this.hexSize(),
|
||||
this.coordToPx(origin)
|
||||
), true, valid.color or (0xC8 shl 24), valid.fadeColor or (0xC8 shl 24))
|
||||
), true, valid.color or (0xC8 shl 24), valid.fadeColor or (0xC8 shl 24), if (valid.success) 0.2f else 0.5f)
|
||||
}
|
||||
|
||||
// Now draw the currently WIP pattern
|
||||
|
@ -315,7 +315,7 @@ class GuiSpellcasting(
|
|||
}
|
||||
|
||||
points.add(mousePos)
|
||||
RenderLib.drawPatternFromPoints(mat, points, false, 0xff_64c8ff_u.toInt(), 0xff_fecbe6_u.toInt())
|
||||
RenderLib.drawPatternFromPoints(mat, points, false, 0xff_64c8ff_u.toInt(), 0xff_fecbe6_u.toInt(), 0.2f)
|
||||
}
|
||||
|
||||
RenderSystem.setShader { prevShader }
|
||||
|
|
|
@ -43,7 +43,7 @@ public class PatternTooltipGreeble implements ClientTooltipComponent, TooltipCom
|
|||
var pair = RenderLib.getCenteredPattern(pattern, SIZE, SIZE, 8f);
|
||||
this.scale = pair.getFirst();
|
||||
var dots = pair.getSecond();
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f, 0f);
|
||||
this.pathfinderDots = dots.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class EntityWallScroll extends HangingEntity {
|
|||
if (this.level.isClientSide) {
|
||||
var pair = RenderLib.getCenteredPattern(pattern, 128, 128, 16f);
|
||||
var dots = pair.getSecond();
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
|
||||
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f, 0f);
|
||||
}
|
||||
|
||||
this.isAncient = NBTHelper.hasString(scroll, ItemScroll.TAG_OP_ID);
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class PatternDrawingUtil {
|
|||
for (var pat : patternEntries) {
|
||||
var localOrigin = HexUtils.coordToPx(pat.origin(), hexSize, realCom.negated());
|
||||
var points = pat.pattern().toLines(hexSize, localOrigin);
|
||||
pat.zappyPoints().addAll(RenderLib.makeZappy(points, 10f, 0.8f, 0f));
|
||||
pat.zappyPoints().addAll(RenderLib.makeZappy(points, 10f, 0.8f, 0f, 0f));
|
||||
}
|
||||
|
||||
var pathfinderDots = seenCoords.stream()
|
||||
|
|
Loading…
Reference in a new issue