Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
model_material.hpp
Go to the documentation of this file.
1// This file is part of the Rendering Engine project.
2// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3// Copyright (c) 2025 Alexander Obzherin
4// Distributed under the terms of the zlib License. See LICENSE.md for details.
5#pragma once
6
7#include <map>
8#include <vector>
9#include <string>
10#include <cstdint>
11
12struct aiMaterial;
13
14namespace rendering_engine
15{
16/**
17 * @enum TextureType
18 * @brief Enumerates supported texture map types for imported materials.
19 *
20 * These correspond to common texture slots used in 3D rendering pipelines
21 * and align with Assimp's material texture types. The range [Begin, End]
22 * allows easy iteration through all supported types.
23 */
39
40class Model;
41/**
42 * @class ModelMaterial
43 * @brief Represents a single material imported from a 3D model file.
44 *
45 * A `ModelMaterial` acts as a lightweight wrapper around Assimp's `aiMaterial`,
46 * extracting and storing references to texture file paths per texture type.
47 *
48 * @note Multiple meshes within a model may reference the same `ModelMaterial`.
49 * @see Model, TextureType
50 */
52{
53 friend class Model;
54
55public:
56 /**
57 * @brief Constructs an empty material associated with a model.
58 * @param model Reference to the owning Model instance.
59 */
60 explicit ModelMaterial(Model& model);
61
62 ModelMaterial(const ModelMaterial&) = default;
66 ~ModelMaterial() = default;
67 /**
68 * @brief Returns a reference to the owning Model.
69 * @return Reference to the parent Model instance.
70 */
71 Model& GetModel();
72 /**
73 * @brief Gets the material name as defined in the source file.
74 * @return Material name string.
75 */
76 const std::string& Name() const;
77 /**
78 * @brief Retrieves the list of textures associated with each texture type.
79 *
80 * Each entry in the map corresponds to one TextureType key (e.g., Diffuse, NormalMap)
81 * and a list of texture file paths associated with that type.
82 *
83 * @return A map of texture types to vectors of texture file paths.
84 */
85 const std::map<TextureType, std::vector<std::string>> Textures() const;
86
87private:
88 static const std::map<TextureType, std::uint32_t> sTextureTypeMappings;
89
90 ModelMaterial(Model& model, aiMaterial& material);
91
92 Model* mModel;
93 std::string mName;
94 std::map<TextureType, std::vector<std::string>> mTextures;
95};
96}// namespace rendering_engine
const std::string & Name() const
Gets the material name as defined in the source file.
const std::map< TextureType, std::vector< std::string > > Textures() const
Retrieves the list of textures associated with each texture type.
ModelMaterial(Model &model)
Constructs an empty material associated with a model.
ModelMaterial(ModelMaterial &&)=default
ModelMaterial(const ModelMaterial &)=default
Model & GetModel()
Returns a reference to the owning Model.
ModelMaterial & operator=(const ModelMaterial &)=default
ModelMaterial & operator=(ModelMaterial &&)=default
TextureType
Enumerates supported texture map types for imported materials.