ScummVM API documentation
SubMeshEntity.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_SUB_MESH_ENTITY_H
29#define HPL_SUB_MESH_ENTITY_H
30
31#include "common/array.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/math/MeshTypes.h"
36#include "hpl1/engine/scene/Entity3D.h"
37#include "hpl1/engine/scene/SectorVisibility.h"
38#include "hpl1/engine/system/SystemTypes.h"
39#include "common/stablemap.h"
40#include "common/multimap.h"
41
42namespace hpl {
43
44class cMaterialManager;
45class cMeshManager;
46class cMesh;
47class cSubMesh;
48class cMeshEntity;
49class cAnimationState;
50class cNodeState;
51class cBone;
52class cNode3D;
53class iPhysicsBody;
54class iMaterial;
55class cBoneState;
56
57//-----------------------------------------------------------------------
58
59typedef Common::Array<cAnimationState *> tAnimationStateVec;
60typedef tAnimationStateVec::iterator tAnimationStateVecIt;
61
62typedef Common::StableMap<tString, int> tAnimationStateIndexMap;
63typedef tAnimationStateIndexMap::iterator tAnimationStateIndexMapIt;
64
65typedef Common::Array<cBoneState *> tNodeStateVec;
66typedef tNodeStateVec::iterator tNodeStateVecIt;
67
68typedef Common::StableMap<tString, int> tNodeStateIndexMap;
69typedef tNodeStateIndexMap::iterator tNodeStateIndexMapIt;
70
71//-----------------------------------------------------------------------
72
74public:
75 void OnTransformUpdate(iEntity3D *apEntity);
76};
77
78//-----------------------------------------------------------------------
79
80kSaveData_ChildClass(iRenderable, cSubMeshEntity) {
81 kSaveData_ClassInit(cSubMeshEntity) public : tString msMaterial;
82
83 bool mbCastShadows;
84
85 int mlBodyId;
86
87 bool mbUpdateBody;
88
89 iSaveObject *CreateSaveObject(cSaveObjectHandler * apSaveObjectHandler, cGame * apGame) { return NULL; }
90 int GetSaveCreatePrio() { return 0; }
91};
92
93//-----------------------------------------------------------------------
94
96 typedef iRenderable super;
97 friend class cMeshEntity;
98
99public:
100 cSubMeshEntity(const tString &asName, cMeshEntity *apMeshEntity, cSubMesh *apSubMesh, cMaterialManager *apMaterialManager);
101 virtual ~cSubMeshEntity();
102
103 iMaterial *GetMaterial();
104
105 void UpdateGraphics(cCamera3D *apCamera, float afFrameTime, cRenderList *apRenderList);
106
107 iVertexBuffer *GetVertexBuffer();
108
109 void SetCastsShadows(bool abX) { mbCastShadows = abX; }
110 bool IsShadowCaster() { return mbCastShadows; }
111
112 cBoundingVolume *GetBoundingVolume();
113
114 cMatrixf *GetModelMatrix(cCamera3D *apCamera);
115
117
118 eRenderableType GetRenderType() { return eRenderableType_Normal; }
119
120 cSubMesh *GetSubMesh() const { return mpSubMesh; }
121
122 void SetLocalNode(cNode3D *apNode);
123 cNode3D *GetLocalNode();
124
125 tRenderContainerDataList *GetRenderContainerDataList();
126
127 // Entity implementation
128 tString GetEntityType() { return "SubMesh"; }
129 bool IsVisible() { return IsRendered(); }
130 void SetVisible(bool abVisible) { SetRendered(abVisible); }
131
132 void UpdateLogic(float afTimeStep);
133
134 cTriangleData &GetTriangle(int alIndex);
135 int GetTriangleNum();
136 tTriangleDataVec *GetTriangleVecPtr();
137
138 iPhysicsBody *GetBody() { return mpBody; }
139 void SetBody(iPhysicsBody *apBody) { mpBody = apBody; }
140
141 void SetUpdateBody(bool abX);
142 bool GetUpdateBody();
143
144 void SetCustomMaterial(iMaterial *apMaterial, bool abDestroyOldCustom = true);
145 iMaterial *GetCustomMaterial() { return mpMaterial; }
146
147 cSector *GetCurrentSector() const;
148
149 // SaveObject implementation
151 virtual void SaveToSaveData(iSaveData *apSaveData);
152 virtual void LoadFromSaveData(iSaveData *apSaveData);
153 virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
154
155private:
156 bool mbCastShadows;
157 cSubMesh *mpSubMesh;
158 cMeshEntity *mpMeshEntity;
159
160 iMaterial *mpMaterial;
161
162 cNode3D *mpLocalNode;
163
164 cMaterialManager *mpMaterialManager;
165
166 iVertexBuffer *mpDynVtxBuffer;
167 tTriangleDataVec mvDynTriangles;
168
169 cSubMeshEntityBodyUpdate *mpEntityCallback;
170 bool mbUpdateBody;
171
172 bool mbGraphicsUpdated;
173
174 iPhysicsBody *mpBody;
175};
176
178typedef Common::Array<cSubMeshEntity *>::iterator tSubMeshEntityVecIt;
179
181typedef tSubMeshEntityMap::iterator tSubMeshEntityMapIt;
182
183} // namespace hpl
184
185#endif // HPL_SUB_MESH_ENTITY_H
cAnimationState * * iterator
Definition: array.h:54
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: str.h:59
Definition: BoundingVolume.h:71
Definition: Camera3D.h:53
Definition: Game.h:91
Definition: MaterialManager.h:41
Definition: MeshEntity.h:96
Definition: Node3D.h:52
Definition: RenderList.h:145
Definition: SaveGame.h:183
Definition: SubMeshEntity.h:73
Definition: SubMeshEntity.h:95
virtual void LoadFromSaveData(iSaveData *apSaveData)
virtual void SaveToSaveData(iSaveData *apSaveData)
virtual iSaveData * CreateSaveData()
virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame)
Definition: SubMesh.h:45
Definition: Entity3D.h:81
Definition: Entity3D.h:44
Definition: Material.h:203
Definition: PhysicsBody.h:117
Definition: Renderable.h:70
Definition: SaveGame.h:111
Definition: SaveGame.h:130
Definition: VertexBuffer.h:90