Drawable.pkg 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. $#include "Drawable.h"
  2. /// Base class for visible components.
  3. class Drawable : public Component
  4. {
  5. public:
  6. /// Set draw distance.
  7. void SetDrawDistance(float distance);
  8. /// Set shadow draw distance.
  9. void SetShadowDistance(float distance);
  10. /// Set LOD bias.
  11. void SetLodBias(float bias);
  12. /// Set view mask. Is and'ed with camera's view mask to see if the object should be rendered.
  13. void SetViewMask(unsigned mask);
  14. /// Set light mask. Is and'ed with light's and zone's light mask to see if the object should be lit.
  15. void SetLightMask(unsigned mask);
  16. /// Set shadow mask. Is and'ed with light's light mask and zone's shadow mask to see if the object should be rendered to a shadow map.
  17. void SetShadowMask(unsigned mask);
  18. /// Set zone mask. Is and'ed with zone's zone mask to see if the object should belong to the zone.
  19. void SetZoneMask(unsigned mask);
  20. /// Set maximum number of per-pixel lights. Default 0 is unlimited.
  21. void SetMaxLights(unsigned num);
  22. /// Set shadowcaster flag.
  23. void SetCastShadows(bool enable);
  24. /// Set occlusion flag.
  25. void SetOccluder(bool enable);
  26. /// Set occludee flag.
  27. void SetOccludee(bool enable);
  28. /// Mark for update before octree reinsertion.
  29. void MarkForUpdate();
  30. /// Return world-space bounding box.
  31. const BoundingBox& GetWorldBoundingBox();
  32. /// Return drawable flags.
  33. unsigned char GetDrawableFlags() const { return drawableFlags_; }
  34. /// Return draw distance.
  35. float GetDrawDistance() const { return drawDistance_; }
  36. /// Return shadow draw distance.
  37. float GetShadowDistance() const { return shadowDistance_; }
  38. /// Return LOD bias.
  39. float GetLodBias() const { return lodBias_; }
  40. /// Return view mask.
  41. unsigned GetViewMask() const { return viewMask_; }
  42. /// Return light mask.
  43. unsigned GetLightMask() const { return lightMask_; }
  44. /// Return shadow mask.
  45. unsigned GetShadowMask() const { return shadowMask_; }
  46. /// Return zone mask.
  47. unsigned GetZoneMask() const { return zoneMask_; }
  48. /// Return maximum number of per-pixel lights.
  49. unsigned GetMaxLights() const { return maxLights_; }
  50. /// Return shadowcaster flag.
  51. bool GetCastShadows() const { return castShadows_; }
  52. /// Return occluder flag.
  53. bool IsOccluder() const { return occluder_; }
  54. /// Return occludee flag.
  55. bool IsOccludee() const { return occludee_; }
  56. /// Set new zone.
  57. void SetZone(Zone* zone, bool temporary = false);
  58. /// Set sorting value.
  59. void SetSortValue(float value);
  60. /// Set view-space depth bounds.
  61. void SetMinMaxZ(float minZ, float maxZ);
  62. /// Mark in view (either the main camera, or a shadow camera view) this frame.
  63. void MarkInView(const FrameInfo& frame, bool mainView = true);
  64. /// Clear lights and base pass flags for a new frame.
  65. void ClearLights();
  66. /// Add a per-pixel light.
  67. void AddLight(Light* light);
  68. /// Add a per-vertex light.
  69. void AddVertexLight(Light* light);
  70. /// Sort and limit per-pixel lights to maximum allowed. Convert extra lights into vertex lights.
  71. void LimitLights();
  72. /// Sort and limit per-vertex lights to maximum allowed.
  73. void LimitVertexLights();
  74. /// Set base pass flag for a batch.
  75. void SetBasePass(unsigned batchIndex) { basePassFlags_ |= (1 << batchIndex); }
  76. /// Return octree octant.
  77. Octant* GetOctant() const { return octant_; }
  78. /// Return current zone.
  79. Zone* GetZone() const;
  80. /// Return previous zone.
  81. Zone* GetLastZone() const;
  82. /// Return if zone assignment needs re-evaluation.
  83. bool IsZoneDirty() const { return zoneDirty_; }
  84. /// Return distance from camera.
  85. float GetDistance() const { return distance_; }
  86. /// Return LOD scaled distance from camera.
  87. float GetLodDistance() const { return lodDistance_; }
  88. /// Return sorting value.
  89. float GetSortValue() const { return sortValue_; }
  90. /// Return whether is in view this frame.
  91. bool IsInView(unsigned frameNumber) const { return viewFrameNumber_ == frameNumber; }
  92. /// Return whether is visible in a specific view this frame.
  93. bool IsInView(const FrameInfo& frame, bool mainView = true) const { return viewFrameNumber_ == frame.frameNumber_ && viewFrame_ == &frame && (!mainView || viewCamera_ == frame.camera_); }
  94. /// Return whether has a base pass.
  95. bool HasBasePass(unsigned batchIndex) const { return (basePassFlags_ & (1 << batchIndex)) != 0; }
  96. /// Return the first added per-pixel light.
  97. Light* GetFirstLight() const { return firstLight_; }
  98. /// Return the minimum view-space depth.
  99. float GetMinZ() const { return minZ_; }
  100. /// Return the maximum view-space depth.
  101. float GetMaxZ() const { return maxZ_; }
  102. };