ScummVM API documentation
Renderable.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_RENDERABLE_H
29 #define HPL_RENDERABLE_H
30 
31 #include "hpl1/engine/graphics/GraphicsTypes.h"
32 #include "hpl1/engine/math/MathTypes.h"
33 #include "hpl1/engine/scene/Entity3D.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 
36 namespace hpl {
37 
38 class iMaterial;
39 class iVertexBuffer;
40 
41 class cBoundingVolume;
42 class cFrustum;
43 
44 class iLight3D;
45 class cCamera3D;
46 
47 class cRenderList;
48 
49 class iRenderable;
50 
51 enum eRenderableType {
52  eRenderableType_Normal,
53  eRenderableType_ParticleSystem,
54  eRenderableType_Mesh,
55  eRenderableType_Light,
56  eRenderableType_Dummy,
57  eRenderableType_LastEnum
58 };
59 
60 //------------------------------------------
61 
62 kSaveData_ChildClass(iEntity3D, iRenderable) {
63  kSerializableClassInit(cSaveData_iRenderable) public : bool mbStatic;
64  bool mbRendered;
65  float mfZ;
66 };
67 
68 //------------------------------------------
69 
70 class iRenderable : public iEntity3D {
71  typedef iEntity3D super;
72 
73 public:
74  iRenderable(const tString &asName);
75 
76  bool IsRendered() { return mbRendered; }
77  virtual void SetRendered(bool abX) { mbRendered = abX; }
78 
79  virtual iMaterial *GetMaterial() = 0;
80  virtual iVertexBuffer *GetVertexBuffer() = 0;
81 
82  virtual bool IsShadowCaster() = 0;
83 
84  virtual bool CollidesWithBV(cBoundingVolume *apBV);
85  virtual bool CollidesWithFrustum(cFrustum *apFrustum);
86 
87  virtual cMatrixf *GetModelMatrix(cCamera3D *apCamera) = 0;
88 
89  virtual eRenderableType GetRenderType() = 0;
90 
91  virtual void UpdateGraphics(cCamera3D *apCamera, float afFrameTime, cRenderList *apRenderList) {}
92 
97  virtual int GetMatrixUpdateCount() = 0;
98 
99  float GetZ() { return mfZ; }
100  void SetZ(float afZ) { mfZ = afZ; }
101 
102  cMatrixf *GetInvModelMatrix();
103 
104  inline void SetPrevMatrix(const cMatrixf &a_mtxPrev) { m_mtxPrevious = a_mtxPrev; }
105  inline cMatrixf &GetPrevMatrix() { return m_mtxPrevious; }
106 
107  const cVector3f &GetCalcScale();
108 
109  void SetStatic(bool abX) { mbStatic = abX; }
110  bool IsStatic() const { return mbStatic; }
111 
112  inline int GetRenderCount() const { return mlRenderCount; }
113  inline void SetRenderCount(const int alCount) { mlRenderCount = alCount; }
114  inline int GetPrevRenderCount() const { return mlPrevRenderCount; }
115  inline void SetPrevRenderCount(const int alCount) { mlPrevRenderCount = alCount; }
116 
117  void SetForceShadow(bool abX) { mbForceShadow = abX; }
118  bool GetForceShadow() { return mbForceShadow; }
119 
120  bool GetIsOneSided() { return mbIsOneSided; }
121  const cVector3f &GetOneSidedNormal() { return mvOneSidedNormal; }
122 
123  // SaveObject implementation
124  virtual iSaveData *CreateSaveData();
125  virtual void SaveToSaveData(iSaveData *apSaveData);
126  virtual void LoadFromSaveData(iSaveData *apSaveData);
127  virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
128 
129 protected:
130  cMatrixf m_mtxInvModel;
131  cMatrixf m_mtxPrevious;
132 
133  bool mbIsOneSided;
134  cVector3f mvOneSidedNormal;
135 
136  int mlLastMatrixCount;
137 
138  bool mbStatic;
139 
140  bool mbForceShadow;
141 
142  int mlRenderCount;
143  int mlPrevRenderCount;
144 
145  int mlCalcScaleMatrixCount;
146  cVector3f mvCalcScale;
147 
148  bool mbRendered;
149  float mfZ;
150 };
151 
152 } // namespace hpl
153 
154 #endif // HPL_RENDERABLE_H
Definition: AI.h:36
Definition: Game.h:91
Definition: str.h:59
Definition: VertexBuffer.h:90
virtual void SaveToSaveData(iSaveData *apSaveData)
Definition: BoundingVolume.h:71
Definition: Renderable.h:70
virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame)
virtual void LoadFromSaveData(iSaveData *apSaveData)
Definition: SaveGame.h:111
Definition: RenderList.h:145
Definition: Entity3D.h:81
virtual iSaveData * CreateSaveData()
Definition: Material.h:203
Definition: SaveGame.h:183
Definition: Camera3D.h:53
virtual int GetMatrixUpdateCount()=0
Definition: Frustum.h:57