2
0

Zone.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "Color.h"
  25. #include "Drawable.h"
  26. /// %Component that describes global rendering properties
  27. class Zone : public Drawable
  28. {
  29. OBJECT(Zone);
  30. public:
  31. /// Construct.
  32. Zone(Context* context);
  33. /// Destruct.
  34. virtual ~Zone();
  35. /// Register object factory. Drawable must be registered first.
  36. static void RegisterObject(Context* context);
  37. /// Handle attribute write access.
  38. virtual void OnSetAttribute(const AttributeInfo& attr, const Variant& src);
  39. /// Add debug geometry to the debug renderer.
  40. virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
  41. /// %Set bounding box. Will be used as an oriented bounding box to test whether the camera is inside.
  42. void SetBoundingBox(const BoundingBox& box);
  43. /// %Set ambient color, both start and end.
  44. void SetAmbientColor(const Color& color);
  45. /// %Set ambient start color at bounding box Z minimum.
  46. void SetAmbientStartColor(const Color& color);
  47. /// %Set ambient end color at bounding box Z maximum.
  48. void SetAmbientEndColor(const Color& color);
  49. /// %Set fog color.
  50. void SetFogColor(const Color& color);
  51. /// %Set fog start distance.
  52. void SetFogStart(float start);
  53. /// %Set fog end distance.
  54. void SetFogEnd(float end);
  55. /// %Set zone priority. If camera is inside several zones, the one with highest priority is used.
  56. void SetPriority(int priority);
  57. /// %Set override mode. If camera is inside an override zone, it will also be used for all drawables.
  58. void SetOverride(bool enable);
  59. /// Return bounding box.
  60. const BoundingBox& GetBoundingBox() const { return boundingBox_; }
  61. /// Return ambient start color.
  62. const Color& GetAmbientStartColor() const { return ambientStartColor_; }
  63. /// Return ambient end color.
  64. const Color& GetAmbientEndColor() const { return ambientEndColor_; }
  65. /// Return fog color.
  66. const Color& GetFogColor() const { return fogColor_; }
  67. /// Return fog start distance.
  68. float GetFogStart() const { return fogStart_; }
  69. /// Return fog end distance.
  70. float GetFogEnd() const { return fogEnd_; }
  71. /// Return zone priority.
  72. int GetPriority() const { return priority_; }
  73. /// Return override mode.
  74. bool GetOverride() const { return override_; }
  75. /// Check whether a point is inside.
  76. virtual bool IsInside(const Vector3& point);
  77. protected:
  78. /// Transform has changed. Clear cached zone of any contained drawables.
  79. virtual void OnMarkedDirty(Node* node);
  80. /// Recalculate the world-space bounding box.
  81. virtual void OnWorldBoundingBoxUpdate();
  82. /// Bounding box.
  83. BoundingBox boundingBox_;
  84. /// Last bounding box.
  85. BoundingBox lastBoundingBox_;
  86. /// Ambient start color.
  87. Color ambientStartColor_;
  88. /// Ambient end color.
  89. Color ambientEndColor_;
  90. /// Fog color.
  91. Color fogColor_;
  92. /// Fog start distance.
  93. float fogStart_;
  94. /// Fog end distance.
  95. float fogEnd_;
  96. /// Zone priority.
  97. int priority_;
  98. /// Override mode.
  99. bool override_;
  100. };