Nebula
Loading...
Searching...
No Matches
vegetationcontext.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
11#include "resources/resource.h"
12#include "ids/idallocator.h"
13
14namespace Vegetation
15{
16
24
26{
27 Resources::ResourceName mask; // expects a 1 channel texture
31 float slopeThreshold; // slope threshold in percentage
32 float heightThreshold; // height threshold in percentage
33};
34
36{
37 Resources::ResourceName mask; // expects a 1 channel texture
42 float slopeThreshold; // slope threshold in percentage
43 float heightThreshold; // height threshold in percentage
44};
45
47{
49public:
50
55
57 static void Create(const VegetationSetupSettings& settings);
59 static void Discard();
60
62 static void Setup(Resources::ResourceName heightMap, SizeT numGrassPlanesPerTuft, float grassPatchRadius);
63
65 static void SetupGrass(const Graphics::GraphicsEntityId id, const VegetationGrassSetup& setup);
67 static void SetupMesh(const Graphics::GraphicsEntityId id, const VegetationMeshSetup& setup);
68
70 static void UpdateViewResources(const Ptr<Graphics::View>& view, const Graphics::FrameContext& ctx);
71private:
72
76 static void Dealloc(Graphics::ContextEntityId id);
77
78 enum class VegetationType : uint8
79 {
80 GrassType, // use for grass and undergrowth
81 MeshType // use for rocks or other objects which might need meshes
82 };
83
84 enum
85 {
96 };
97
98 typedef Ids::IdAllocator<
104 uint,
105 IndexT,
106 float, float,
110};
111
112} // namespace Vegetation
Definition graphicscontext.h:165
An ID allocator associates an id with a slice in an N number of arrays.
Definition idallocator.h:39
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
A StringAtom.
Definition stringatom.h:22
Definition vegetationcontext.h:47
static void UpdateViewResources(const Ptr< Graphics::View > &view, const Graphics::FrameContext &ctx)
update resources
Definition vegetationcontext.cc:908
static void Setup(Resources::ResourceName heightMap, SizeT numGrassPlanesPerTuft, float grassPatchRadius)
Setup vegetation context.
Definition vegetationcontext.cc:610
VegetationContext()
constructor
Definition vegetationcontext.cc:124
@ Vegetation_Materials
Definition vegetationcontext.h:89
@ Vegetation_TextureIndex
Definition vegetationcontext.h:92
@ Vegetation_HeightThreshold
Definition vegetationcontext.h:94
@ Vegetation_Albedos
Definition vegetationcontext.h:87
@ Vegetation_SlopeThreshold
Definition vegetationcontext.h:93
@ Vegetation_Meshes
Definition vegetationcontext.h:90
@ Vegetation_Mask
Definition vegetationcontext.h:86
@ Vegetation_Normals
Definition vegetationcontext.h:88
@ Vegetation_GPUInfo
Definition vegetationcontext.h:91
@ Vegetation_Type
Definition vegetationcontext.h:95
static Graphics::ContextEntityId Alloc()
allocate a new slice for this context
Definition vegetationcontext.cc:981
static void SetupGrass(const Graphics::GraphicsEntityId id, const VegetationGrassSetup &setup)
setup as grass
Definition vegetationcontext.cc:731
static void Create(const VegetationSetupSettings &settings)
create vegetation context
Definition vegetationcontext.cc:139
VegetationType
Definition vegetationcontext.h:79
~VegetationContext()
destructor
Definition vegetationcontext.cc:131
static void SetupMesh(const Graphics::GraphicsEntityId id, const VegetationMeshSetup &setup)
setup as mesh
Definition vegetationcontext.cc:778
static void Dealloc(Graphics::ContextEntityId id)
deallocate a slice
Definition vegetationcontext.cc:990
Ids::IdAllocator< CoreGraphics::TextureId, CoreGraphics::TextureId, CoreGraphics::TextureId, CoreGraphics::TextureId, CoreGraphics::MeshId, uint, IndexT, float, float, VegetationType > VegetationAllocator
Definition vegetationcontext.h:108
static void Discard()
discard vegetation context
Definition vegetationcontext.cc:602
static VegetationAllocator vegetationAllocator
Definition vegetationcontext.h:109
#define ID_32_TYPE(x)
Definition id.h:16
The vegetation context handles rendering of grass, trees and other types of vegetation.
Definition vegetationcontext.cc:24
CoreGraphics::TextureId heightMap
Definition vegetationcontext.cc:31
Definition mesh.h:29
texture type
Definition texture.h:25
Definition graphicscontext.h:133
Definition graphicsserver.h:31
The graphics entity is only an Id, to which we can attach GraphicsContexts.
Definition graphicsentity.h:16
A 2-component float vector class.
Definition vec2.h:21
Definition vegetationcontext.h:17
Definition vegetationcontext.h:26
Resources::ResourceName albedo
Definition vegetationcontext.h:28
Resources::ResourceName normals
Definition vegetationcontext.h:29
float heightThreshold
Definition vegetationcontext.h:32
Resources::ResourceName mask
Definition vegetationcontext.h:27
float slopeThreshold
Definition vegetationcontext.h:31
Resources::ResourceName material
Definition vegetationcontext.h:30
Definition vegetationcontext.h:36
float heightThreshold
Definition vegetationcontext.h:43
Resources::ResourceName albedo
Definition vegetationcontext.h:38
Resources::ResourceName normals
Definition vegetationcontext.h:39
Resources::ResourceName mesh
Definition vegetationcontext.h:41
Resources::ResourceName mask
Definition vegetationcontext.h:37
float slopeThreshold
Definition vegetationcontext.h:42
Resources::ResourceName material
Definition vegetationcontext.h:40
Definition vegetationcontext.h:19
float maxHeight
Definition vegetationcontext.h:20
float minHeight
Definition vegetationcontext.h:20
Math::vec2 worldSize
Definition vegetationcontext.h:22
uint8_t uint8
Definition types.h:42
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48