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 
42 namespace hpl {
43 
44 class cMaterialManager;
45 class cMeshManager;
46 class cMesh;
47 class cSubMesh;
48 class cMeshEntity;
49 class cAnimationState;
50 class cNodeState;
51 class cBone;
52 class cNode3D;
53 class iPhysicsBody;
54 class iMaterial;
55 class cBoneState;
56 
57 //-----------------------------------------------------------------------
58 
59 typedef Common::Array<cAnimationState *> tAnimationStateVec;
60 typedef tAnimationStateVec::iterator tAnimationStateVecIt;
61 
62 typedef Common::StableMap<tString, int> tAnimationStateIndexMap;
63 typedef tAnimationStateIndexMap::iterator tAnimationStateIndexMapIt;
64 
65 typedef Common::Array<cBoneState *> tNodeStateVec;
66 typedef tNodeStateVec::iterator tNodeStateVecIt;
67 
68 typedef Common::StableMap<tString, int> tNodeStateIndexMap;
69 typedef tNodeStateIndexMap::iterator tNodeStateIndexMapIt;
70 
71 //-----------------------------------------------------------------------
72 
74 public:
75  void OnTransformUpdate(iEntity3D *apEntity);
76 };
77 
78 //-----------------------------------------------------------------------
79 
80 kSaveData_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 
95 class cSubMeshEntity : public iRenderable {
96  typedef iRenderable super;
97  friend class cMeshEntity;
98 
99 public:
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 
116  int GetMatrixUpdateCount();
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
150  virtual iSaveData *CreateSaveData();
151  virtual void SaveToSaveData(iSaveData *apSaveData);
152  virtual void LoadFromSaveData(iSaveData *apSaveData);
153  virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
154 
155 private:
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 
178 typedef Common::Array<cSubMeshEntity *>::iterator tSubMeshEntityVecIt;
179 
181 typedef tSubMeshEntityMap::iterator tSubMeshEntityMapIt;
182 
183 } // namespace hpl
184 
185 #endif // HPL_SUB_MESH_ENTITY_H
Definition: PortalContainer.h:181
Definition: AI.h:36
Definition: SubMeshEntity.h:95
Definition: Game.h:91
Definition: str.h:59
Definition: VertexBuffer.h:90
Definition: MaterialManager.h:41
Definition: list.h:44
T * iterator
Definition: array.h:54
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: BoundingVolume.h:71
Definition: SaveGame.h:130
Definition: SubMesh.h:45
Definition: Renderable.h:70
Definition: Node3D.h:52
Definition: PhysicsBody.h:117
Definition: MeshTypes.h:38
Definition: SaveGame.h:111
Definition: SubMeshEntity.h:73
Definition: RenderList.h:145
Definition: Entity3D.h:81
Definition: MeshEntity.h:96
Definition: Material.h:203
Definition: Entity3D.h:44
Definition: SaveGame.h:183
Definition: Camera3D.h:53