MegaBubble.cs 799 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. using System.IO;
  3. [AddComponentMenu("Modifiers/Bubble")]
  4. public class MegaBubble : MegaModifier
  5. {
  6. public float radius = 0.0f;
  7. public float falloff = 20.0f;
  8. Matrix4x4 mat = new Matrix4x4();
  9. public override string ModName() { return "Bubble"; }
  10. public override string GetHelpURL() { return "?page_id=111"; }
  11. public override Vector3 Map(int i, Vector3 p)
  12. {
  13. p = tm.MultiplyPoint3x4(p);
  14. float val = ((Vector3.Magnitude(p - bbox.center)) / falloff);
  15. p += radius * (Vector3.Normalize(p - bbox.center)) / (val * val + 1.0f);
  16. return invtm.MultiplyPoint3x4(p);
  17. }
  18. public override bool ModLateUpdate(MegaModContext mc)
  19. {
  20. return Prepare(mc);
  21. }
  22. public override bool Prepare(MegaModContext mc)
  23. {
  24. mat = Matrix4x4.identity;
  25. SetAxis(mat);
  26. return true;
  27. }
  28. }