ScummVM API documentation
Mesh2d.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_MESH2D_H
29 #define HPL_MESH2D_H
30 
31 #include "common/array.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/math/MathTypes.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 
36 namespace hpl {
37 class cMesh2DEdge {
38 public:
39  cMesh2DEdge(cVector2f avNormal, cVector2f avMidPos, unsigned int alStartIndex, unsigned int alEndIndex)
40  : mvNormal(avNormal), mvMidPos(avMidPos), mlStartIndex(alStartIndex), mlEndIndex(alEndIndex) {}
41 
42  cVector2f mvNormal;
43  cVector2f mvMidPos;
44  unsigned int mlStartIndex;
45  unsigned int mlEndIndex;
46 };
47 
49 typedef tMesh2DEdgeVec::iterator tMesh2DEdgeVecIt;
50 
52 public:
53  cCollisionMesh2D() {}
54 
55  tVector2fVec mvPos;
56  tVector2fVec mvNormal;
57 };
58 
68 class cMesh2D {
69 public:
70  cMesh2D();
71  ~cMesh2D();
72 
73  void AddVertex(cVector2f avPos, cVector2f avTexCoord = 0, cColor aCol = 1);
74  void AddIndex(unsigned int alIndex);
75  void AddEdgeIndex(unsigned int alIndex);
76 
77  void CreateVertexVec();
78  void CreateTileVertexVec();
79 
80  tVertexVec *GetVertexVec(const cRect2f &aImageRect, cVector2f avSize, eTileRotation aRotation = eTileRotation_0);
81  tUIntVec *GetIndexVec();
82  tMesh2DEdgeVec *GetEdgeVec(eTileRotation aRotation = eTileRotation_0);
83 
91  bool PointIsInside(const cVector2f &avPoint, const cVector2f &avMeshPos,
92  eTileRotation aRotation = eTileRotation_0);
93 
94  cCollisionMesh2D *CreateCollisonMesh(const cVector2f &avPos, const cVector2f &avSizeMul,
95  eTileRotation aRotation = eTileRotation_0);
96 
97 private:
98  tVector2fVec mvPos;
99  tColorVec mvColor;
100  tMesh2DEdgeVec mvEdge[eTileRotation_LastEnum];
101  tVector2fVec mvTexCoord;
102  tUIntVec mvIndex;
103  tUIntVec mvEdgeIndex;
104  cRect2f mvBoundingBox[eTileRotation_LastEnum];
105 
106  tVertexVec mvVtx[eTileRotation_LastEnum]; // One for each tile angle.
107 
108  void CalculateEdges(eTileRotation aRotation, tVertexVec &aVtx, tUIntVec &aIdx);
109 };
110 
111 } // namespace hpl
112 
113 #endif // HPL_MESH2D_H
Definition: AI.h:36
Definition: Mesh2d.h:37
cMesh2DEdge * iterator
Definition: array.h:54
Definition: Mesh2d.h:68
Definition: Mesh2d.h:51
Definition: Color.h:37