ScummVM API documentation
BillBoard.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_BILLBOARD_H
29 #define HPL_BILLBOARD_H
30 
31 #include "RenderList.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/graphics/Renderable.h"
34 #include "hpl1/engine/math/MathTypes.h"
35 #include "hpl1/engine/scene/Entity3D.h"
36 #include "hpl1/engine/system/SystemTypes.h"
37 
38 namespace hpl {
39 
40 enum eBillboardType {
41  eBillboardType_Point,
42  eBillboardType_Axis,
43  eBillboardType_LastEnum
44 };
45 
46 class cMaterialManager;
47 class cResources;
48 class cGraphics;
49 class cMeshCreator;
50 class cFileSearcher;
51 class iLowLevelGraphics;
52 class iMaterial;
53 class iVertexBuffer;
54 class iOcclusionQuery;
55 
56 //------------------------------------------
57 
58 kSaveData_ChildClass(iRenderable, cBillboard) {
59  kSaveData_ClassInit(cBillboard) public : tString msMaterial;
60 
61  int mType;
62  cVector2f mvSize;
63  cVector3f mvAxis;
64  float mfForwardOffset;
65  cColor mColor;
66  float mfHaloAlpha;
67 
68  bool mbIsHalo;
69  cVector3f mvHaloSourceSize;
70  bool mbHaloSourceIsParent;
71 
72  virtual iSaveObject *CreateSaveObject(cSaveObjectHandler * apSaveObjectHandler, cGame * apGame);
73  virtual int GetSaveCreatePrio();
74 };
75 
76 //------------------------------------------
77 
78 class cBillboard : public iRenderable {
79  typedef iRenderable super;
80 
81 public:
82  cBillboard(const tString asName, const cVector2f &avSize, cResources *apResources,
83  cGraphics *apGraphics);
84  ~cBillboard();
85 
86  void SetMaterial(iMaterial *apMaterial);
87 
88  void SetSize(const cVector2f &avSize);
89  cVector2f GetSize() { return mvSize; }
90 
91  void SetType(eBillboardType aType);
92  eBillboardType GetType() { return mType; }
93 
94  void SetAxis(const cVector3f &avAxis);
95  cVector3f GetAxis() { return mvAxis; }
96 
97  void SetForwardOffset(float afOffset);
98  float GetForwardOffset() { return mfForwardOffset; }
99 
100  void SetColor(const cColor &aColor);
101  const cColor &GetColor() { return mColor; }
102 
103  void SetHaloAlpha(float afX);
104  float GetHaloAlpha() { return mfHaloAlpha; }
105 
106  void LoadXMLProperties(const tString asFile);
107 
109  // Halo stuff
110  void SetIsHalo(bool abX);
111  bool IsHalo() { return mbIsHalo; }
112 
113  void SetHaloSourceSize(const cVector3f &avSize);
114  cVector3f GetHaloSourceSize() { return mvHaloSourceSize; }
115 
116  void SetHaloSourceIsParent(bool abX);
117  bool GetHaloSourceIsParent() { return mbHaloSourceIsParent; }
118 
119  iOcclusionQuery *GetQuery() { return mQueryObject.mpQuery; }
120  iOcclusionQuery *GetMaxQuery() { return mMaxQueryObject.mpQuery; }
121 
123  // Entity implementation
124  tString GetEntityType() { return "Billboard"; }
125 
126  bool IsVisible();
127  void SetVisible(bool abVisible) { SetRendered(abVisible); }
128 
129  // Renderable implementations
130  iMaterial *GetMaterial() { return mpMaterial; }
131  iVertexBuffer *GetVertexBuffer() { return mpVtxBuffer; }
132 
133  void UpdateGraphics(cCamera3D *apCamera, float afFrameTime, cRenderList *apRenderList);
134 
135  bool IsShadowCaster() { return false; }
136 
137  cBoundingVolume *GetBoundingVolume();
138 
139  cMatrixf *GetModelMatrix(cCamera3D *apCamera);
140 
141  int GetMatrixUpdateCount();
142 
143  eRenderableType GetRenderType() { return eRenderableType_ParticleSystem; }
144 
145  // SaveObject implementation
146  virtual iSaveData *CreateSaveData();
147  virtual void SaveToSaveData(iSaveData *apSaveData);
148  virtual void LoadFromSaveData(iSaveData *apSaveData);
149  virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
150 
151 private:
152  eBillboardType ToType(const char *apString);
153 
154  void UpdateSourceBufferSize();
155 
156  cMaterialManager *mpMaterialManager;
157  cFileSearcher *mpFileSearcher;
158  iLowLevelGraphics *mpLowLevelGraphics;
159  cMeshCreator *mpMeshCreator;
160 
161  iMaterial *mpMaterial;
162  iVertexBuffer *mpVtxBuffer;
163 
164  iVertexBuffer *mpHaloSourceBuffer;
165 
166  cMatrixf m_mtxTempTransform;
167 
168  eBillboardType mType;
169  cVector2f mvSize;
170  cVector3f mvAxis;
171 
172  int mlLastRenderCount;
173 
174  bool mbIsHalo;
175  cVector3f mvHaloSourceSize;
176  bool mbHaloSourceIsParent;
177  cOcclusionQueryObject mQueryObject;
178  cOcclusionQueryObject mMaxQueryObject;
179 
180  float mfForwardOffset;
181  cColor mColor;
182  float mfHaloAlpha;
183 };
184 
185 } // namespace hpl
186 
187 #endif // HPL_BILLBOARD_H
Definition: AI.h:36
int GetMatrixUpdateCount()
Definition: Game.h:91
Definition: str.h:59
virtual void SaveToSaveData(iSaveData *apSaveData)
Definition: VertexBuffer.h:90
virtual iSaveData * CreateSaveData()
Definition: MaterialManager.h:41
virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame)
Definition: BoundingVolume.h:71
Definition: Renderable.h:70
Definition: FileSearcher.h:43
Definition: BillBoard.h:78
Definition: MeshCreator.h:43
Definition: SaveGame.h:111
Definition: RenderList.h:145
Definition: OcclusionQuery.h:33
Definition: RenderList.h:110
Definition: Resources.h:160
Definition: Color.h:37
Definition: Material.h:203
virtual void LoadFromSaveData(iSaveData *apSaveData)
Definition: SaveGame.h:183
Definition: Graphics.h:46
Definition: LowLevelGraphics.h:200
Definition: Camera3D.h:53