Zone.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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
  36. static void RegisterObject(Context* context);
  37. /// Handle attribute write access
  38. virtual void OnSetAttribute(const AttributeInfo& attr, const Variant& value);
  39. /// Set bounding box. Will be used as an oriented bounding box to test whether the camera is inside
  40. void SetBoundingBox(const BoundingBox& box);
  41. /// Set ambient color
  42. void SetAmbientColor(const Color& color);
  43. /// Set fog color
  44. void SetFogColor(const Color& color);
  45. /// Set fog start distance
  46. void SetFogStart(float start);
  47. /// Set fog end distance
  48. void SetFogEnd(float end);
  49. /// Set zone priority. If camera is inside several zones, the one with highest priority is used
  50. void SetPriority(int priority);
  51. /// Return bounding box
  52. const BoundingBox& GetBoundingBox() const { return boundingBox_; }
  53. /// Return ambient color
  54. const Color& GetAmbientColor() const { return ambientColor_; }
  55. /// Return fog color
  56. const Color& GetFogColor() const { return fogColor_; }
  57. /// Return fog start distance
  58. float GetFogStart() const { return fogStart_; }
  59. /// Return fog end distance
  60. float GetFogEnd() const { return fogEnd_; }
  61. /// Return zone priority
  62. int GetPriority() const { return priority_; }
  63. /// Check whether a point is inside
  64. virtual bool IsInside(const Vector3& point);
  65. protected:
  66. /// Update world-space bounding box
  67. virtual void OnWorldBoundingBoxUpdate();
  68. /// Bounding box
  69. BoundingBox boundingBox_;
  70. /// Ambient color
  71. Color ambientColor_;
  72. /// Fog color
  73. Color fogColor_;
  74. /// Fog start distance
  75. float fogStart_;
  76. /// Fog end distance
  77. float fogEnd_;
  78. /// Zone priority
  79. int priority_;
  80. };