libdonut 2.3.6
Application framework for cross-platform game development in C++20
Loading...
Searching...
No Matches
Model.hpp
Go to the documentation of this file.
1#ifndef DONUT_GRAPHICS_MODEL_HPP
2#define DONUT_GRAPHICS_MODEL_HPP
3
7#include <donut/math.hpp>
8
9#include <cstddef> // std::size_t
10#include <vector> // std::vector
11
12namespace donut::graphics {
13
14class Renderer; // Forward declaration, to avoid a circular include of Renderer.hpp.
15
20struct Model {
118
126 static const Model* const QUAD;
127
135 static const Model* const CUBE;
136
142 explicit Model(std::vector<Object> objects) noexcept
143 : objects(std::move(objects)) {}
144
164 Model(const Filesystem& filesystem, const char* filepath);
165
169 std::vector<Object> objects;
170
171private:
172 friend Renderer;
173
174 static void createSharedModels();
175 static void destroySharedModels() noexcept;
176};
177
178} // namespace donut::graphics
179
180#endif
Persistent system for managing the virtual filesystem.
Definition Filesystem.hpp:185
Generic abstraction of a GPU vertex array object and its associated buffers.
Definition Mesh.hpp:226
Persistent system for rendering the batched draw commands of a RenderPass onto a Framebuffer,...
Definition Renderer.hpp:38
Storage for multidimensional data, such as 2D images, on the GPU, combined with a sampler configurati...
Definition Texture.hpp:75
Definition Buffer.hpp:7
MeshBufferUsage
Hint to the graphics driver implementation regarding the intended access pattern of a particular GPU ...
Definition Mesh.hpp:44
MeshPrimitiveType
Specification of which kind of graphical primitive is defined by an associated sequence of vertices i...
Definition Mesh.hpp:60
@ TRIANGLES
Each consecutive triple of points forms an individual filled triangle.
MeshIndexType
Specification of which type of indices is used in the index buffer of a particular Mesh.
Definition Mesh.hpp:73
@ U32
Unsigned 32-bit integer.
Data layout for the attributes of a single instance of the mesh.
Definition Model.hpp:56
vec3 specularFactor
Specular factor to use when rendering.
Definition Model.hpp:61
vec4 tintColor
Tint color to use when rendering.
Definition Model.hpp:60
vec3 emissiveFactor
Emissive factor to use when rendering.
Definition Model.hpp:62
mat4 transformation
Model transformation matrix.
Definition Model.hpp:57
mat3 normalMatrix
Transposed 3x3 basis of the model transformation matrix.
Definition Model.hpp:58
vec4 textureOffsetAndScale
Texture offset (xy) and texture scale (zw) to apply to the texture coordinates before sampling the te...
Definition Model.hpp:59
Material attributes of the mesh.
Definition Model.hpp:68
float dissolveFactor
Dissolve factor for transparency.
Definition Model.hpp:78
Texture specularMap
Texture used for specular highlights.
Definition Model.hpp:70
vec3 specularColor
Specular color.
Definition Model.hpp:74
float specularExponent
Specular exponent for specular highlights.
Definition Model.hpp:77
Texture normalMap
Texture used for normal mapping.
Definition Model.hpp:71
vec3 normalScale
Normal map scale.
Definition Model.hpp:75
Texture diffuseMap
Texture used for the base color.
Definition Model.hpp:69
vec3 emissiveColor
Emissive color.
Definition Model.hpp:76
vec3 diffuseColor
Base color.
Definition Model.hpp:73
float occlusionFactor
Occlusion factor.
Definition Model.hpp:79
Texture emissiveMap
Texture used for emissive mapping.
Definition Model.hpp:72
Data layout for the attributes of a single vertex of the mesh.
Definition Model.hpp:34
vec3 tangent
Unit vector pointing in some direction along the vertex surface.
Definition Model.hpp:37
vec3 position
Position relative to the model origin.
Definition Model.hpp:35
vec3 bitangent
Unit vector that is the cross product of the normal and the tangent.
Definition Model.hpp:38
vec2 textureCoordinates
Texture UV coordinates that map to this vertex.
Definition Model.hpp:39
vec3 normal
Unit vector pointing away from the vertex surface.
Definition Model.hpp:36
A single 3D mesh with an associated material.
Definition Model.hpp:27
static constexpr MeshBufferUsage INDICES_USAGE
Hint regarding the intended memory access pattern of the index buffer.
Definition Model.hpp:86
static constexpr std::int32_t TEXTURE_UNIT_SPECULAR
Texture unit index to use for the Material::specularMap.
Definition Model.hpp:98
std::size_t indexCount
Number of indices stored in the index buffer of the mesh.
Definition Model.hpp:116
static constexpr std::int32_t TEXTURE_UNIT_EMISSIVE
Texture unit index to use for the Material::emissiveMap.
Definition Model.hpp:100
static constexpr std::int32_t TEXTURE_UNIT_COUNT
Total number of texture units required to render an object.
Definition Model.hpp:101
static constexpr MeshBufferUsage VERTICES_USAGE
Hint regarding the intended memory access pattern of the vertex buffer.
Definition Model.hpp:83
static constexpr std::int32_t TEXTURE_UNIT_NORMAL
Texture unit index to use for the Material::normalMap.
Definition Model.hpp:99
Mesh< Vertex, Index, Instance > mesh
Mesh data stored on the GPU.
Definition Model.hpp:106
static constexpr MeshIndexType INDEX_TYPE
Index type of the mesh indices.
Definition Model.hpp:95
Material material
Material attributes.
Definition Model.hpp:111
static constexpr MeshPrimitiveType PRIMITIVE_TYPE
The type of 3D primitives represented by the mesh vertices.
Definition Model.hpp:92
u32 Index
Data type used in the index buffer of the mesh.
Definition Model.hpp:48
static constexpr MeshBufferUsage INSTANCES_USAGE
Hint regarding the intended memory access pattern of the instance buffer.
Definition Model.hpp:89
static constexpr std::int32_t TEXTURE_UNIT_DIFFUSE
Texture unit index to use for the Material::diffuseMap.
Definition Model.hpp:97
Container for a set of 3D triangle meshes stored on the GPU, combined with associated materials.
Definition Model.hpp:20
Model(const Filesystem &filesystem, const char *filepath)
Load a model from a virtual file.
static const Model *const QUAD
Pointer to the statically allocated storage for the built-in quad model.
Definition Model.hpp:126
std::vector< Object > objects
List of objects defined by the loaded model.
Definition Model.hpp:169
static const Model *const CUBE
Pointer to the statically allocated storage for the built-in cube model.
Definition Model.hpp:135
Model(std::vector< Object > objects) noexcept
Construct a model from a list of meshes.
Definition Model.hpp:142