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
36namespace hpl {
37
38class iMaterial;
39class iVertexBuffer;
40
41class cBoundingVolume;
42class cFrustum;
43
44class iLight3D;
45class cCamera3D;
46
47class cRenderList;
48
49class iRenderable;
50
51enum eRenderableType {
52 eRenderableType_Normal,
53 eRenderableType_ParticleSystem,
54 eRenderableType_Mesh,
55 eRenderableType_Light,
56 eRenderableType_Dummy,
57 eRenderableType_LastEnum
58};
59
60//------------------------------------------
61
62kSaveData_ChildClass(iEntity3D, iRenderable) {
63 kSerializableClassInit(cSaveData_iRenderable) public : bool mbStatic;
64 bool mbRendered;
65 float mfZ;
66};
67
68//------------------------------------------
69
70class iRenderable : public iEntity3D {
71 typedef iEntity3D super;
72
73public:
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
125 virtual void SaveToSaveData(iSaveData *apSaveData);
126 virtual void LoadFromSaveData(iSaveData *apSaveData);
127 virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
128
129protected:
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: str.h:59
Definition: BoundingVolume.h:71
Definition: Camera3D.h:53
Definition: Frustum.h:57
Definition: Game.h:91
Definition: RenderList.h:145
Definition: SaveGame.h:183
Definition: Entity3D.h:81
Definition: Material.h:203
Definition: Renderable.h:70
virtual int GetMatrixUpdateCount()=0
virtual void LoadFromSaveData(iSaveData *apSaveData)
virtual void SaveToSaveData(iSaveData *apSaveData)
virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame)
virtual iSaveData * CreateSaveData()
Definition: SaveGame.h:111
Definition: VertexBuffer.h:90