demofilter.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using libTerrain;
  3. using OpenSim.Terrain;
  4. /// <summary>
  5. /// A Demonstration Filter
  6. /// </summary>
  7. public class DemoFilter : ITerrainFilter
  8. {
  9. public void Filter(Channel heightmap, string[] args)
  10. {
  11. Console.WriteLine("Hello world");
  12. }
  13. public string Register()
  14. {
  15. return "demofilter";
  16. }
  17. public string Help()
  18. {
  19. return "demofilter - Does nothing\n";
  20. }
  21. }
  22. public class SineFilter : ITerrainFilter
  23. {
  24. public void Filter(Channel heightmap, string[] args)
  25. {
  26. double max = heightmap.findMax();
  27. for (int x = 0; x < heightmap.w; x++)
  28. {
  29. for (int y = 0; y < heightmap.h; y++)
  30. {
  31. heightmap.set(x,y,((Math.Sin(heightmap.get(x,y) * Convert.ToDouble(args[1])) + 1) / 2) * max);
  32. }
  33. }
  34. }
  35. public string Register()
  36. {
  37. return "sinefilter";
  38. }
  39. public string Help()
  40. {
  41. return "sinefilter <theta> - Converts the heightmap to the functional output of a sine wave";
  42. }
  43. }