62 lines
1.1 KiB
C#
62 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("Modifiers/Crumple")]
|
|
public class MegaCrumple : MegaModifier
|
|
{
|
|
public float scale = 1f;
|
|
|
|
public float speed = 1f;
|
|
|
|
public float phase;
|
|
|
|
public bool animate;
|
|
|
|
private Matrix4x4 mat = default(Matrix4x4);
|
|
|
|
private MegaPerlin iperlin = MegaPerlin.Instance;
|
|
|
|
private float timex;
|
|
|
|
private float timey;
|
|
|
|
private float timez;
|
|
|
|
public override string ModName()
|
|
{
|
|
return "Crumple";
|
|
}
|
|
|
|
public override string GetHelpURL()
|
|
{
|
|
return "?page_id=653";
|
|
}
|
|
|
|
public override Vector3 Map(int i, Vector3 p)
|
|
{
|
|
p = tm.MultiplyPoint3x4(p);
|
|
p.x += iperlin.Noise(timex + p.x, timex + p.y, timex + p.z) * scale;
|
|
p.y += iperlin.Noise(timey + p.x, timey + p.y, timey + p.z) * scale;
|
|
p.z += iperlin.Noise(timez + p.x, timez + p.y, timez + p.z) * scale;
|
|
return invtm.MultiplyPoint3x4(p);
|
|
}
|
|
|
|
public override bool ModLateUpdate(MegaModContext mc)
|
|
{
|
|
if (animate)
|
|
{
|
|
phase += Time.deltaTime * speed;
|
|
}
|
|
timex = 0.1365143f + phase;
|
|
timey = 1.21688f + phase;
|
|
timez = 2.5564f + phase;
|
|
return Prepare(mc);
|
|
}
|
|
|
|
public override bool Prepare(MegaModContext mc)
|
|
{
|
|
mat = Matrix4x4.identity;
|
|
SetAxis(mat);
|
|
return true;
|
|
}
|
|
}
|