| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- $#include "Terrain.h"
- /// Heightmap terrain component.
- class Terrain : public Component
- {
- public:
- /// Set patch quads per side. Must be a power of two.
- void SetPatchSize(int size);
- /// Set vertex (XZ) and height (Y) spacing.
- void SetSpacing(const Vector3& spacing);
- /// Set smoothing of heightmap.
- void SetSmoothing(bool enable);
- /// 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.
- bool SetHeightMap(Image* image);
- /// Set material.
- void SetMaterial(Material* material);
- /// Set draw distance for patches.
- void SetDrawDistance(float distance);
- /// Set shadow draw distance for patches.
- void SetShadowDistance(float distance);
- /// Set LOD bias for patches. Affects which terrain LOD to display.
- void SetLodBias(float bias);
- /// Set view mask for patches. Is and'ed with camera's view mask to see if the object should be rendered.
- void SetViewMask(unsigned mask);
- /// Set light mask for patches. Is and'ed with light's and zone's light mask to see if the object should be lit.
- void SetLightMask(unsigned mask);
- /// 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.
- void SetShadowMask(unsigned mask);
- /// Set zone mask for patches. Is and'ed with zone's zone mask to see if the object should belong to the zone.
- void SetZoneMask(unsigned mask);
- /// Set maximum number of per-pixel lights for patches. Default 0 is unlimited.
- void SetMaxLights(unsigned num);
- /// Set shadowcaster flag for patches.
- void SetCastShadows(bool enable);
- /// Set occlusion flag for patches. Occlusion uses the coarsest LOD and may potentially be too aggressive, so use with caution.
- void SetOccluder(bool enable);
- /// Set occludee flag for patches.
- void SetOccludee(bool enable);
- /// Return patch quads per side.
- int GetPatchSize() const { return patchSize_; }
- /// Return vertex and height spacing.
- const Vector3& GetSpacing() const { return spacing_; }
- /// Return heightmap size in vertices.
- const IntVector2& GetNumVertices() const { return numVertices_; }
- /// Return heightmap size in patches.
- const IntVector2& GetNumPatches() const { return numPatches_; }
- /// Return whether smoothing is in use.
- bool GetSmoothing() const { return smoothing_; }
- /// Return heightmap image.
- Image* GetHeightMap() const;
- /// Return material.
- Material* GetMaterial() const;
- /// Return patch by index.
- TerrainPatch* GetPatch(unsigned index) const;
- /// Return patch by patch coordinates.
- TerrainPatch* GetPatch(int x, int z) const;
- /// Return height at world coordinates.
- float GetHeight(const Vector3& worldPosition) const;
- /// Return normal at world coordinates.
- Vector3 GetNormal(const Vector3& worldPosition) const;
- /// Return draw distance.
- float GetDrawDistance() const { return drawDistance_; }
- /// Return shadow draw distance.
- float GetShadowDistance() const { return shadowDistance_; }
- /// Return LOD bias.
- float GetLodBias() const { return lodBias_; }
- /// Return view mask.
- unsigned GetViewMask() const { return viewMask_; }
- /// Return light mask.
- unsigned GetLightMask() const { return lightMask_; }
- /// Return shadow mask.
- unsigned GetShadowMask() const { return shadowMask_; }
- /// Return zone mask.
- unsigned GetZoneMask() const { return zoneMask_; }
- /// Return maximum number of per-pixel lights.
- unsigned GetMaxLights() const { return maxLights_; }
- /// Return visible flag.
- bool IsVisible() const { return visible_; }
- /// Return shadowcaster flag.
- bool GetCastShadows() const { return castShadows_; }
- /// Return occluder flag.
- bool IsOccluder() const { return occluder_; }
- /// Return occludee flag.
- bool IsOccludee() const { return occludee_; }
- };
|