MegaSinusCurve.cs 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. [AddComponentMenu("Modifiers/Sinus Curve")]
  3. public class MegaSinusCurve : MegaModifier
  4. {
  5. public float scale = 1.0f;
  6. public float wave = 1.0f;
  7. public float speed = 1.0f;
  8. public float phase = 0.0f;
  9. public bool animate = false;
  10. Matrix4x4 mat = new Matrix4x4();
  11. public override string ModName() { return "Sinus Curve"; }
  12. public override string GetHelpURL() { return "Bubble.htm"; }
  13. public override Vector3 Map(int i, Vector3 p)
  14. {
  15. p = tm.MultiplyPoint3x4(p);
  16. p.y += Mathf.Sin(phase + (p.x * wave) + p.y + p.z) * scale;
  17. return invtm.MultiplyPoint3x4(p);
  18. }
  19. public override bool ModLateUpdate(MegaModContext mc)
  20. {
  21. if ( animate )
  22. {
  23. if ( Application.isPlaying )
  24. phase += Time.deltaTime * speed;
  25. }
  26. return Prepare(mc);
  27. }
  28. public override bool Prepare(MegaModContext mc)
  29. {
  30. mat = Matrix4x4.identity;
  31. SetAxis(mat);
  32. return true;
  33. }
  34. }