ScummVM API documentation
Mesh.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_MESH_H
29#define HPL_MESH_H
30
31#include "hpl1/engine/graphics/GraphicsTypes.h"
32#include "hpl1/engine/math/MathTypes.h"
33#include "hpl1/engine/resources/ResourceBase.h"
34#include "hpl1/engine/system/SystemTypes.h"
35
36#include "hpl1/engine/physics/CollideShape.h"
37#include "hpl1/engine/physics/PhysicsJoint.h"
38
39#include "common/array.h"
40#include "hpl1/engine/scene/Light3D.h"
41#include "common/stablemap.h"
42#include "common/multimap.h"
43
44namespace hpl {
45
46class cMaterialManager;
47class cAnimationManager;
48class cSubMesh;
49class cMeshEntity;
50class cSkeleton;
51class cAnimation;
52class cNode3D;
53class iCollideShape;
54class iPhysicsWorld;
55class iPhysicsBody;
56class iPhysicsJoint;
57class cBillboard;
58class cBeam;
59class cParticleSystem3D;
60class cSoundEntity;
61class cWorld3D;
62
63//--------------------------------------------------
64
65typedef Common::Array<cAnimation *> tAnimationVec;
66typedef tAnimationVec::iterator tAnimationVecIt;
67
68typedef Common::StableMap<tString, int> tAnimationIndexMap;
69typedef tAnimationIndexMap::iterator tAnimationIndexMapIt;
70
71typedef Common::Array<cSubMesh *> tSubMeshVec;
72typedef Common::Array<cSubMesh *>::iterator tSubMeshVecIt;
73
75typedef tSubMeshMap::iterator tSubMeshMapIt;
76
77typedef Common::Array<cNode3D *> tNode3DVec;
78typedef tNode3DVec::iterator tNode3DVecIt;
79
80//--------------------------------------------------
81
83public:
84 tString msGroup;
85
86 eCollideShapeType mType;
87 cVector3f mvSize;
88 cMatrixf m_mtxOffset;
89};
90
92typedef tMeshColliderVec::iterator tMeshColliderVecIt;
93
94//--------------------------------------------------
95
97public:
98 ePhysicsJointType mType;
99
100 tString msName;
101
102 bool mbCollide;
103
104 cVector3f mvPivot;
105 cVector3f mvPinDir;
106
107 float mfMax;
108 float mfMin;
109
110 tString msChildBody;
111 tString msParentBody;
112};
113
115typedef tMeshJointVec::iterator tMeshJointVecIt;
116
117//--------------------------------------------------
118
120public:
121 tString msParent;
122 tString msFile;
123 tString msName;
124
125 eLight3DType mType;
126 cMatrixf m_mtxTransform;
127 cColor mColor;
128 float mfRadius;
129 float mfFOV;
130 bool mbCastShadows;
131};
132
134typedef tMeshLightVec::iterator tMeshLightVecIt;
135
136//--------------------------------------------------
137
139public:
140 tString msFile;
141 tString msName;
142
143 tString msStartParent;
144 cVector3f mvStartPosition;
145
146 tString msEndParent;
147 cVector3f mvEndPosition;
148};
149
151typedef tMeshBeamVec::iterator tMeshBeamVecIt;
152
153//--------------------------------------------------
154
156public:
157 tString msParent;
158 tString msFile;
159 tString msName;
160
161 cVector2f mvSize;
162 cVector3f mvPosition;
163 cVector3f mvAxis;
164 float mfOffset;
165};
166
168typedef tMeshBillboardVec::iterator tMeshBillboardVecIt;
169
170//--------------------------------------------------
171
173public:
174 tString msParent;
175 tString msType;
176 tString msName;
177
178 cMatrixf m_mtxTransform;
179 cVector3f mvSize;
180};
181
183typedef tMeshParticleSystemVec::iterator tMeshParticleSystemVecIt;
184
185//--------------------------------------------------
186
188public:
189 tString msParent;
190 tString msType;
191 tString msName;
192
193 cVector3f mvPosition;
194};
195
197typedef tMeshSoundEntityVec::iterator tMeshSoundEntityVecIt;
198
199//--------------------------------------------------
200
202public:
203 tString msParent;
204 tString msName;
205 tString msFile;
206
207 cMatrixf m_mtxTransform;
208};
209
211typedef tMeshReferenceVec::iterator tMeshReferenceVecIt;
212
213//--------------------------------------------------
214
215class cMesh : public iResourceBase {
216 friend class cSubMesh;
217 friend class cMeshEntity;
218
219public:
220 cMesh(const tString asName, cMaterialManager *apMaterialManager,
221 cAnimationManager *apAnimationManager);
222 ~cMesh();
223
224 bool CreateFromFile(const tString asFile);
225
226 cSubMesh *CreateSubMesh(const tString &asName);
227
228 cSubMesh *GetSubMesh(unsigned int alIdx);
229 cSubMesh *GetSubMeshName(const tString &asName);
230 int GetSubMeshNum();
231
232 void SetSkeleton(cSkeleton *apSkeleton);
233 cSkeleton *GetSkeleton();
234
235 void AddAnimation(cAnimation *apAnimation);
236
237 cAnimation *GetAnimation(int alIndex);
238 cAnimation *GetAnimationFromName(const tString &asName);
239 int GetAnimationIndex(const tString &asName);
240
241 void ClearAnimations(bool abDeleteAll);
242
243 int GetAnimationNum();
244
245 void SetupBones();
246
247 // Joints
248 cMeshJoint *CreatePhysicsJoint(ePhysicsJointType);
249 cMeshJoint *GetPhysicsJoint(int alIdx);
250 int GetPhysicsJointNum();
251 iPhysicsJoint *CreateJointInWorld(const tString &sNamePrefix, cMeshJoint *apMeshJoint,
252 iPhysicsBody *apParentBody, iPhysicsBody *apChildBody,
253 const cMatrixf &a_mtxOffset, iPhysicsWorld *apWorld);
254
255 void CreateNodeBodies(iPhysicsBody **apRootBodyPtr, Common::Array<iPhysicsBody *> *apSubBodyVec,
256 cMeshEntity *apEntity, iPhysicsWorld *apWorld,
257 const cMatrixf &a_mtxTransform);
258
259 void CreateJointsAndBodies(Common::Array<iPhysicsBody *> *apBodyVec, cMeshEntity *apEntity,
261 const cMatrixf &a_mtxOffset, iPhysicsWorld *apWorld);
262
263 bool HasSeveralBodies();
264
265 // Colliders
266 cMeshCollider *CreateCollider(eCollideShapeType aType);
267 cMeshCollider *GetCollider(int alIdx);
268 int GetColliderNum();
269 iCollideShape *CreateCollideShape(iPhysicsWorld *apWorld);
270 iCollideShape *CreateCollideShapeFromCollider(cMeshCollider *pCollider, iPhysicsWorld *apWorld);
271
272 // Lights
273 cMeshLight *CreateLight(eLight3DType aType);
274 cMeshLight *GetLight(int alIdx);
275 int GetLightNum();
276 iLight3D *CreateLightInWorld(const tString &sNamePrefix, cMeshLight *apMeshLight,
277 cMeshEntity *apMeshEntity, cWorld3D *apWorld);
278
279 // Billboards
280 cMeshBillboard *CreateBillboard();
281 cMeshBillboard *GetBillboard(int alIdx);
282 int GetBillboardNum();
283 cBillboard *CreateBillboardInWorld(const tString &sNamePrefix, cMeshBillboard *apMeshBillboard,
284 cMeshEntity *apMeshEntity, cWorld3D *apWorld);
285
286 // Beams
287 cMeshBeam *CreateBeam();
288 cMeshBeam *GetBeam(int alIdx);
289 int GetBeamNum();
290 cBeam *CreateBeamInWorld(const tString &sNamePrefix, cMeshBeam *apMeshBeam,
291 cMeshEntity *apMeshEntity, cWorld3D *apWorld);
292
293 // Particle systems
294 cMeshParticleSystem *CreateParticleSystem();
295 cMeshParticleSystem *GetParticleSystem(int alIdx);
296 int GetParticleSystemNum();
297 cParticleSystem3D *CreateParticleSystemInWorld(const tString &sNamePrefix, cMeshParticleSystem *apMeshPS,
298 cMeshEntity *apMeshEntity, cWorld3D *apWorld);
299
300 // References
301 cMeshReference *CreateReference();
302 cMeshReference *GetReference(int alIdx);
303 int GetReferenceNum();
304 iEntity3D *CreateReferenceInWorld(const tString &sNamePrefix, cMeshReference *apMeshRef,
305 cMeshEntity *apMeshEntity, cWorld3D *apWorld,
306 const cMatrixf &a_mtxOffset);
307
308 // Sound entities
309 cMeshSoundEntity *CreateSoundEntity();
310 cMeshSoundEntity *GetSoundEntity(int alIdx);
311 int GetSoundEntityNum();
312 cSoundEntity *CreateSoundEntityInWorld(const tString &sNamePrefix, cMeshSoundEntity *apMeshSound,
313 cMeshEntity *apMeshEntity, cWorld3D *apWorld);
314
315 // Node
316 cNode3D *GetRootNode();
317 void AddNode(cNode3D *apNode);
318 int GetNodeNum();
319 cNode3D *GetNode(int alIdx);
320
321 // Resources implementation
322 bool reload() { return false; }
323 void unload() {}
324 void destroy() {}
325
326private:
327 cMaterialManager *mpMaterialManager;
328 cAnimationManager *mpAnimationManager;
329
330 tSubMeshVec mvSubMeshes;
331 tSubMeshMap m_mapSubMeshes;
332
333 cSkeleton *mpSkeleton;
334
335 tAnimationVec mvAnimations;
336 tAnimationIndexMap m_mapAnimIndices;
337
338 cNode3D *mpRootNode;
339 tNode3DVec mvNodes;
340
341 tMeshJointVec mvPhysicJoints;
342 tMeshColliderVec mvColliders;
343
344 tMeshLightVec mvLights;
345 tMeshBillboardVec mvBillboards;
346 tMeshBeamVec mvBeams;
347 tMeshParticleSystemVec mvParticleSystems;
348 tMeshSoundEntityVec mvSoundEntities;
349 tMeshReferenceVec mvReferences;
350};
351
352} // namespace hpl
353
354#endif // HPL_MESH_H
cAnimation * * iterator
Definition: array.h:54
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: str.h:59
Definition: Animation.h:44
Definition: AnimationManager.h:39
Definition: Beam.h:80
Definition: BillBoard.h:78
Definition: Color.h:37
Definition: MaterialManager.h:41
Definition: Mesh.h:138
Definition: Mesh.h:155
Definition: Mesh.h:82
Definition: MeshEntity.h:96
Definition: Mesh.h:215
void destroy()
Definition: Mesh.h:324
bool reload()
Definition: Mesh.h:322
void unload()
Definition: Mesh.h:323
Definition: Mesh.h:96
Definition: Mesh.h:119
Definition: Mesh.h:172
Definition: Mesh.h:201
Definition: Mesh.h:187
Definition: Node3D.h:52
Definition: ParticleSystem3D.h:90
Definition: Skeleton.h:46
Definition: SoundEntity.h:86
Definition: SubMesh.h:45
Definition: World3D.h:179
Definition: CollideShape.h:50
Definition: Entity3D.h:81
Definition: Light3D.h:117
Definition: PhysicsBody.h:117
Definition: PhysicsJoint.h:135
Definition: PhysicsWorld.h:115
Definition: ResourceBase.h:36