42 lines
779 B
C#
42 lines
779 B
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("Modifiers/Bubble")]
|
|
public class MegaBubble : MegaModifier
|
|
{
|
|
public float radius;
|
|
|
|
public float falloff = 20f;
|
|
|
|
private Matrix4x4 mat = default(Matrix4x4);
|
|
|
|
public override string ModName()
|
|
{
|
|
return "Bubble";
|
|
}
|
|
|
|
public override string GetHelpURL()
|
|
{
|
|
return "?page_id=111";
|
|
}
|
|
|
|
public override Vector3 Map(int i, Vector3 p)
|
|
{
|
|
p = tm.MultiplyPoint3x4(p);
|
|
float num = Vector3.Magnitude(p - bbox.center) / falloff;
|
|
p += radius * Vector3.Normalize(p - bbox.center) / (num * num + 1f);
|
|
return invtm.MultiplyPoint3x4(p);
|
|
}
|
|
|
|
public override bool ModLateUpdate(MegaModContext mc)
|
|
{
|
|
return Prepare(mc);
|
|
}
|
|
|
|
public override bool Prepare(MegaModContext mc)
|
|
{
|
|
mat = Matrix4x4.identity;
|
|
SetAxis(mat);
|
|
return true;
|
|
}
|
|
}
|