ScummVM API documentation
Entity3D.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_ENTITY3D_H
29#define HPL_ENTITY3D_H
30
31#include "hpl1/engine/math/MathTypes.h"
32#include "hpl1/engine/scene/Entity.h"
33#include "hpl1/engine/system/Container.h"
34#include "hpl1/engine/system/SystemTypes.h"
35
36#include "common/list.h"
37#include "hpl1/engine/math/BoundingVolume.h"
38
39namespace hpl {
40
41class iEntity3D;
42class cSector;
43
45public:
46 virtual ~iEntityCallback() = default;
47 virtual void OnTransformUpdate(iEntity3D *apEntity) = 0;
48};
49
52
53//------------------------------------
54
55// Used for the render container to add specific data to
56// the object.
58};
59
62
63//------------------------------------
64
65kSaveData_ChildClass(iEntity, iEntity3D) {
66 kSaveData_ClassInit(iEntity3D) public : cMatrixf m_mtxLocalTransform;
67 cBoundingVolume mBoundingVolume;
68 tString msSourceFile;
69
70 int mlParentId;
71 cContainerList<int> mlstChildren;
72};
73
74//-----------------------------------------
75
76class iEntity3D;
77
78typedef Common::List<iEntity3D *> tEntity3DList;
79typedef tEntity3DList::iterator tEntity3DListIt;
80
81class iEntity3D : public iEntity {
82 typedef iEntity super;
83
84public:
85 iEntity3D(tString asName);
86 virtual ~iEntity3D();
87
88 cVector3f GetLocalPosition();
89 cMatrixf &GetLocalMatrix();
90
91 cVector3f GetWorldPosition();
92 cMatrixf &GetWorldMatrix();
93
94 void SetPosition(const cVector3f &avPos);
95 void SetMatrix(const cMatrixf &a_mtxTransform);
96
97 void SetWorldPosition(const cVector3f &avWorldPos);
98 void SetWorldMatrix(const cMatrixf &a_mtxWorldTransform);
99
100 void SetTransformUpdated(bool abUpdateCallbacks = true);
101 bool GetTransformUpdated();
102
103 int GetTransformUpdateCount();
104
105 void AddCallback(iEntityCallback *apCallback);
106 void RemoveCallback(iEntityCallback *apCallback);
107
108 void SetSourceFile(const tString &asFile) { msSourceFile = asFile; }
109 const tString &GetSourceFile() { return msSourceFile; }
110
111 virtual cBoundingVolume *GetBoundingVolume() { return &mBoundingVolume; }
112
116 void AddChild(iEntity3D *apEntity);
117 void RemoveChild(iEntity3D *apEntity);
118 bool IsChild(iEntity3D *apEntity);
119 iEntity3D *GetEntityParent();
120
121 virtual tRenderContainerDataList *GetRenderContainerDataList() { return &mlstRenderContainerData; }
122
123 inline int GetIteratorCount() { return mlIteratorCount; }
124 inline void SetIteratorCount(const int alX) { mlIteratorCount = alX; }
125
126 inline void SetCurrentSector(cSector *apSetor) { mpCurrentSector = apSetor; }
127 virtual cSector *GetCurrentSector() const { return mpCurrentSector; }
128
129 bool IsInSector(cSector *apSector);
130
131 inline int GetGlobalRenderCount() { return mlGlobalRenderCount; }
132 inline void SetGlobalRenderCount(int alX) { mlGlobalRenderCount = alX; }
133
134 // SaveObject implementation
136 virtual void SaveToSaveData(iSaveData *apSaveData);
137 virtual void LoadFromSaveData(iSaveData *apSaveData);
138 virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
139
140protected:
141 cMatrixf m_mtxLocalTransform;
142 cMatrixf m_mtxWorldTransform;
143
144 cBoundingVolume mBoundingVolume;
145 bool mbUpdateBoundingVolume;
146 bool mbApplyTransformToBV; // Only temp!!
147
148 bool mbTransformUpdated;
149
150 int mlGlobalRenderCount;
151
152 int mlCount;
153
154 tString msSourceFile;
155
156 tEntityCallbackList mlstCallbacks;
157
158 tRenderContainerDataList mlstRenderContainerData;
159
160 tEntity3DList mlstChildren;
161 iEntity3D *mpParent;
162
163 cSector *mpCurrentSector;
164
165 int mlIteratorCount;
166
167private:
168 void UpdateWorldTransform();
169};
170
171} // namespace hpl
172
173#endif // HPL_ENTITY3D_H
ListInternal::Iterator< iEntity3D * > iterator
Definition: list.h:52
Definition: str.h:59
Definition: BoundingVolume.h:71
Definition: Container.h:219
Definition: Game.h:91
Definition: SaveGame.h:183
Definition: PortalContainer.h:181
Definition: Entity3D.h:81
virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame)
virtual void SaveToSaveData(iSaveData *apSaveData)
void AddChild(iEntity3D *apEntity)
virtual iSaveData * CreateSaveData()
virtual void LoadFromSaveData(iSaveData *apSaveData)
Definition: Entity3D.h:44
Definition: Entity.h:50
Definition: Entity3D.h:57
Definition: SaveGame.h:111
Definition: SaveGame.h:130
Definition: list_intern.h:54