Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Decal.h
Go to the documentation of this file.
1 /* Copyright (C) 2013 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_DECAL
19 #define INCLUDED_DECAL
20 
21 #include "graphics/Material.h"
22 #include "graphics/ModelAbstract.h"
23 #include "graphics/Texture.h"
24 
25 class CTerrain;
26 
27 /**
28  * Terrain decal definition.
29  * Decals are rectangular textures that are projected vertically downwards
30  * onto the terrain.
31  */
32 struct SDecal
33 {
34  SDecal(const CMaterial& material, float sizeX, float sizeZ, float angle,
35  float offsetX, float offsetZ, bool floating)
36  : m_Material(material), m_SizeX(sizeX), m_SizeZ(sizeZ), m_Angle(angle),
37  m_OffsetX(offsetX), m_OffsetZ(offsetZ), m_Floating(floating)
38  {
39  }
40 
42  float m_SizeX;
43  float m_SizeZ;
44  float m_Angle;
45  float m_OffsetX;
46  float m_OffsetZ;
47  bool m_Floating;
48 };
49 
51 {
52 public:
53  CModelDecal(CTerrain* terrain, const SDecal& decal)
54  : m_Terrain(terrain), m_Decal(decal)
55  {
56  }
57 
58  /// Dynamic cast
60  {
61  return this;
62  }
63 
64  virtual CModelAbstract* Clone() const;
65 
66  virtual void SetDirtyRec(int dirtyflags)
67  {
68  SetDirty(dirtyflags);
69  }
70 
71  virtual void SetTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1);
72 
73  virtual void CalcBounds();
74  virtual void ValidatePosition();
75  virtual void InvalidatePosition();
76  virtual void SetTransform(const CMatrix3D& transform);
77 
78  // remove shadow receiving
79  void RemoveShadows();
80 
81  /**
82  * Compute the terrain vertex indexes that bound the decal's
83  * projection onto the terrain.
84  * The returned indexes are clamped to the terrain size.
85  */
86  void CalcVertexExtents(ssize_t& i0, ssize_t& j0, ssize_t& i1, ssize_t& j1);
87 
90 };
91 
92 #endif // INCLUDED_DECAL
virtual void InvalidatePosition()
Mark this model&#39;s position and bone matrices, and all props&#39; positions as invalid.
Definition: Decal.cpp:72
bool m_Floating
Definition: Decal.h:47
CMaterial m_Material
Definition: Decal.h:41
virtual void SetTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1)
Called when terrain has changed in the given inclusive bounds.
Definition: Decal.cpp:61
virtual CModelAbstract * Clone() const
Definition: Decal.cpp:25
virtual CModelDecal * ToCModelDecal()
Dynamic cast.
Definition: Decal.h:59
float m_SizeZ
Definition: Decal.h:43
float m_OffsetX
Definition: Decal.h:45
SDecal m_Decal
Definition: Decal.h:89
CModelDecal(CTerrain *terrain, const SDecal &decal)
Definition: Decal.h:53
void SetDirty(u32 dirtyflags)
void CalcVertexExtents(ssize_t &i0, ssize_t &j0, ssize_t &i1, ssize_t &j1)
Compute the terrain vertex indexes that bound the decal&#39;s projection onto the terrain.
Definition: Decal.cpp:31
Terrain decal definition.
Definition: Decal.h:32
SDecal(const CMaterial &material, float sizeX, float sizeZ, float angle, float offsetX, float offsetZ, bool floating)
Definition: Decal.h:34
float m_Angle
Definition: Decal.h:44
intptr_t ssize_t
Definition: wposix_types.h:82
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
Definition: ModelAbstract.h:36
float m_SizeX
Definition: Decal.h:42
virtual void SetTransform(const CMatrix3D &transform)
Definition: Decal.cpp:99
CTerrain * m_Terrain
Definition: Decal.h:88
virtual void CalcBounds()
(Re)calculates and stores any bounds or bound-dependent data for this object.
Definition: Decal.cpp:54
void RemoveShadows()
Definition: Decal.cpp:111
float m_OffsetZ
Definition: Decal.h:46
virtual void ValidatePosition()
Ensure that both the transformation and the bone matrices are correct for this model and all its prop...
Definition: Decal.cpp:77
virtual void SetDirtyRec(int dirtyflags)
Calls SetDirty on this model and all child objects.
Definition: Decal.h:66