Terrain.pkg 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. $#include "Terrain.h"
  2. /// Heightmap terrain component.
  3. class Terrain : public Component
  4. {
  5. public:
  6. /// Set patch quads per side. Must be a power of two.
  7. void SetPatchSize(int size);
  8. /// Set vertex (XZ) and height (Y) spacing.
  9. void SetSpacing(const Vector3& spacing);
  10. /// Set smoothing of heightmap.
  11. void SetSmoothing(bool enable);
  12. /// Set heightmap image. Dimensions should be a power of two + 1. Uses 8-bit grayscale, or optionally red as MSB and green as LSB for 16-bit accuracy. Return true if successful.
  13. bool SetHeightMap(Image* image);
  14. /// Set material.
  15. void SetMaterial(Material* material);
  16. /// Set draw distance for patches.
  17. void SetDrawDistance(float distance);
  18. /// Set shadow draw distance for patches.
  19. void SetShadowDistance(float distance);
  20. /// Set LOD bias for patches. Affects which terrain LOD to display.
  21. void SetLodBias(float bias);
  22. /// Set view mask for patches. Is and'ed with camera's view mask to see if the object should be rendered.
  23. void SetViewMask(unsigned mask);
  24. /// Set light mask for patches. Is and'ed with light's and zone's light mask to see if the object should be lit.
  25. void SetLightMask(unsigned mask);
  26. /// Set shadow mask for patches. 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.
  27. void SetShadowMask(unsigned mask);
  28. /// Set zone mask for patches. Is and'ed with zone's zone mask to see if the object should belong to the zone.
  29. void SetZoneMask(unsigned mask);
  30. /// Set maximum number of per-pixel lights for patches. Default 0 is unlimited.
  31. void SetMaxLights(unsigned num);
  32. /// Set shadowcaster flag for patches.
  33. void SetCastShadows(bool enable);
  34. /// Set occlusion flag for patches. Occlusion uses the coarsest LOD and may potentially be too aggressive, so use with caution.
  35. void SetOccluder(bool enable);
  36. /// Set occludee flag for patches.
  37. void SetOccludee(bool enable);
  38. /// Return patch quads per side.
  39. int GetPatchSize() const { return patchSize_; }
  40. /// Return vertex and height spacing.
  41. const Vector3& GetSpacing() const { return spacing_; }
  42. /// Return heightmap size in vertices.
  43. const IntVector2& GetNumVertices() const { return numVertices_; }
  44. /// Return heightmap size in patches.
  45. const IntVector2& GetNumPatches() const { return numPatches_; }
  46. /// Return whether smoothing is in use.
  47. bool GetSmoothing() const { return smoothing_; }
  48. /// Return heightmap image.
  49. Image* GetHeightMap() const;
  50. /// Return material.
  51. Material* GetMaterial() const;
  52. /// Return patch by index.
  53. TerrainPatch* GetPatch(unsigned index) const;
  54. /// Return patch by patch coordinates.
  55. TerrainPatch* GetPatch(int x, int z) const;
  56. /// Return height at world coordinates.
  57. float GetHeight(const Vector3& worldPosition) const;
  58. /// Return normal at world coordinates.
  59. Vector3 GetNormal(const Vector3& worldPosition) const;
  60. /// Return draw distance.
  61. float GetDrawDistance() const { return drawDistance_; }
  62. /// Return shadow draw distance.
  63. float GetShadowDistance() const { return shadowDistance_; }
  64. /// Return LOD bias.
  65. float GetLodBias() const { return lodBias_; }
  66. /// Return view mask.
  67. unsigned GetViewMask() const { return viewMask_; }
  68. /// Return light mask.
  69. unsigned GetLightMask() const { return lightMask_; }
  70. /// Return shadow mask.
  71. unsigned GetShadowMask() const { return shadowMask_; }
  72. /// Return zone mask.
  73. unsigned GetZoneMask() const { return zoneMask_; }
  74. /// Return maximum number of per-pixel lights.
  75. unsigned GetMaxLights() const { return maxLights_; }
  76. /// Return visible flag.
  77. bool IsVisible() const { return visible_; }
  78. /// Return shadowcaster flag.
  79. bool GetCastShadows() const { return castShadows_; }
  80. /// Return occluder flag.
  81. bool IsOccluder() const { return occluder_; }
  82. /// Return occludee flag.
  83. bool IsOccludee() const { return occludee_; }
  84. };