ParticleGraphCameraController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. function ParticleGraphCameraController::onAdd(%this)
  2. {
  3. if(strstr(%this.fieldName, "Scale") > 0)
  4. {
  5. %this.asset.selectField(%this.fieldName);
  6. if(%this.isTime)
  7. {
  8. %this.min = %this.asset.getMinTime();
  9. %this.max = %this.asset.getMaxTime();
  10. }
  11. else
  12. {
  13. %this.min = %this.asset.getMinValue();
  14. %this.max = %this.asset.getMaxValue();
  15. }
  16. }
  17. else
  18. {
  19. %emitter = %this.asset.getEmitter(0);
  20. %emitter.selectField(%this.fieldName);
  21. if(%this.isTime)
  22. {
  23. %this.min = %emitter.getMinTime();
  24. %this.max = %emitter.getMaxTime();
  25. }
  26. else
  27. {
  28. %this.min = %emitter.getMinValue();
  29. %this.max = %emitter.getMaxValue();
  30. }
  31. }
  32. %this.currentPosition = 0;
  33. %this.zoomLevel[1] = 1;
  34. %this.zoomCount = 1;
  35. %this.currentZoomLevel = 1;
  36. if(%this.max > 1)
  37. {
  38. %this.zoomLevel[2] = 10;
  39. %this.zoomCount = 2;
  40. %this.currentZoomLevel = 2;
  41. }
  42. if(%this.max > 10)
  43. {
  44. %this.zoomLevel[3] = 100;
  45. %this.zoomCount = 3;
  46. }
  47. if(%this.max > 100)
  48. {
  49. %this.zoomLevel[4] = 1000;
  50. %this.zoomCount = 4;
  51. }
  52. if(%this.max == 180 || %this.max == 360 || %this.max == 720)
  53. {
  54. %this.setupDegreeValue();
  55. }
  56. }
  57. function ParticleGraphCameraController::setupDegreeValue(%this)
  58. {
  59. %this.currentPosition = %this.min;
  60. %this.zoomLevel[1] = 5;
  61. %this.zoomLevel[2] = 30;
  62. %this.zoomLevel[3] = 90;
  63. %this.zoomLevel[4] = 360;
  64. %this.zoomCount = 4;
  65. %this.currentZoomLevel = 4;
  66. }
  67. function ParticleGraphCameraController::getCameraMin(%this)
  68. {
  69. return %this.currentPosition;
  70. }
  71. function ParticleGraphCameraController::getCameraMax(%this)
  72. {
  73. return %this.currentPosition + %this.zoomLevel[%this.currentZoomLevel];
  74. }
  75. function ParticleGraphCameraController::zoomIn(%this)
  76. {
  77. %this.currentZoomLevel = mGetMax(%this.currentZoomLevel - 1, 1);
  78. }
  79. function ParticleGraphCameraController::zoomOut(%this)
  80. {
  81. %this.currentZoomLevel = mGetMin(%this.currentZoomLevel + 1, %this.zoomCount);
  82. %zoom = %this.zoomLevel[%this.currentZoomLevel];
  83. %this.currentPosition = mFloor(%this.currentPosition / %zoom) * %zoom;
  84. if((%this.currentPosition + %zoom) > %this.max)
  85. {
  86. %this.currentPosition = %this.max - %zoom;
  87. }
  88. if(%this.currentPosition < %this.min)
  89. {
  90. %this.currentPosition = %this.min;
  91. }
  92. }
  93. function ParticleGraphCameraController::moveUp(%this)
  94. {
  95. %zoom = %this.zoomLevel[%this.currentZoomLevel];
  96. %this.currentPosition = mGetMin(%this.currentPosition + %zoom, %this.max - %zoom);
  97. }
  98. function ParticleGraphCameraController::moveDown(%this)
  99. {
  100. %this.currentPosition = mGetMax(%this.currentPosition - %this.zoomLevel[%this.currentZoomLevel], %this.min);
  101. }
  102. function ParticleGraphCameraController::getMoveUpEnabled(%this)
  103. {
  104. %zoom = %this.zoomLevel[%this.currentZoomLevel];
  105. return (%this.currentPosition + %zoom) < %this.max;
  106. }
  107. function ParticleGraphCameraController::getMoveDownEnabled(%this)
  108. {
  109. return %this.currentPosition > %this.min;
  110. }
  111. function ParticleGraphCameraController::getZoomInEnabled(%this)
  112. {
  113. return %this.currentZoomLevel > 1;
  114. }
  115. function ParticleGraphCameraController::getZoomOutEnabled(%this)
  116. {
  117. return %this.currentZoomLevel < %this.zoomCount;
  118. }