Pyrogenesis trunk
TerrainTextureEntry.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_TERRAINTEXTUREENTRY
19#define INCLUDED_TERRAINTEXTUREENTRY
20
21#include "graphics/Material.h"
23#include "graphics/Texture.h"
25#include "maths/Matrix3D.h"
26#include "ps/CStr.h"
27
28#include <vector>
29
30// CTerrainTextureEntry: class wrapping a terrain texture object; contains various other required
31// elements - color of minimap, terrain "group" it belongs to, etc
33{
34public:
35 using GroupVector = std::vector<CTerrainGroup*>;
36
37 // Most of the texture's data is delay-loaded, so after the constructor has
38 // been called, the texture entry is ready to be used.
41
42 const CStr& GetTag() const { return m_Tag; }
43
45
46 // Get texture handle, load texture if not loaded.
48
49 const CMaterial& GetMaterial() const { return m_Material; }
50
51 // Returns a matrix of the form [c 0 -s 0; -s 0 -c 0; 0 0 0 0; 0 0 0 1]
52 // mapping world-space (x,y,z,1) coordinates onto (u,v,0,1) texcoords
53 const CMatrix3D& GetTextureMatrix() const { return m_TextureMatrix; }
54
55 // Used in Atlas to retrieve a texture for previews. Can't use textures
56 // directly because they're required on CPU side. Another solution is to
57 // retrieve path from diffuse texture from material.
59
60 // Get mipmap color in BGRA format
62 {
64 return m_BaseColor;
65 }
66
67 CTerrainTextureManager::TerrainAlphaMap::iterator m_TerrainAlpha;
68
69private:
70 // Tag = file name stripped of path and extension (grass_dark_1)
71 CStr m_Tag;
72
74
75 // The property sheet used by this texture
77
79
81
82 // BGRA color of topmost mipmap level, for coloring minimap, or a color
83 // specified by the terrain properties
85 // ..Valid is true if the base color has been cached
87
88 // All terrain type groups we're a member of
90
91 // calculate the root color of the texture, used for coloring minimap
92 void BuildBaseColor();
93};
94
95#endif
std::shared_ptr< CTerrainProperties > CTerrainPropertiesPtr
Definition: TerrainProperties.h:40
Definition: Material.h:29
const CTexturePtr & GetDiffuseTexture() const
Definition: Material.h:51
Definition: Matrix3D.h:34
Definition: TerrainProperties.h:43
Definition: TerrainTextureEntry.h:33
VfsPath m_DiffuseTexturePath
Definition: TerrainTextureEntry.h:73
CMatrix3D m_TextureMatrix
Definition: TerrainTextureEntry.h:80
std::vector< CTerrainGroup * > GroupVector
Definition: TerrainTextureEntry.h:35
CTerrainTextureManager::TerrainAlphaMap::iterator m_TerrainAlpha
Definition: TerrainTextureEntry.h:67
void BuildBaseColor()
Definition: TerrainTextureEntry.cpp:170
CTerrainPropertiesPtr m_pProperties
Definition: TerrainTextureEntry.h:76
CTerrainTextureEntry(CTerrainPropertiesPtr props, const VfsPath &path)
Definition: TerrainTextureEntry.cpp:37
GroupVector m_Groups
Definition: TerrainTextureEntry.h:89
bool m_BaseColorValid
Definition: TerrainTextureEntry.h:86
u32 GetBaseColor()
Definition: TerrainTextureEntry.h:61
const CMatrix3D & GetTextureMatrix() const
Definition: TerrainTextureEntry.h:53
CMaterial m_Material
Definition: TerrainTextureEntry.h:78
const VfsPath & GetDiffuseTexturePath() const
Definition: TerrainTextureEntry.h:58
const CTerrainProperties & GetProperties() const
Definition: TerrainTextureEntry.h:44
u32 m_BaseColor
Definition: TerrainTextureEntry.h:84
CStr m_Tag
Definition: TerrainTextureEntry.h:71
const CStr & GetTag() const
Definition: TerrainTextureEntry.h:42
~CTerrainTextureEntry()
Definition: TerrainTextureEntry.cpp:162
const CMaterial & GetMaterial() const
Definition: TerrainTextureEntry.h:49
const CTexturePtr & GetTexture() const
Definition: TerrainTextureEntry.h:47
Definition: path.h:80
std::shared_ptr< CTexture > CTexturePtr
Definition: Texture.h:23
uint32_t u32
Definition: types.h:39