ScummVM API documentation
xskinmesh_loader.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 #ifndef WINTERMUTE_XSKINMESH_LOADER_H
23 #define WINTERMUTE_XSKINMESH_LOADER_H
24 
25 #include "engines/wintermute/base/gfx/xmodel.h"
26 
27 #include "math/matrix4.h"
28 #include "math/vector3d.h"
29 
30 namespace Wintermute {
31 
32 class Material;
33 class XModel;
34 class XMesh;
35 class ShadowVolume;
36 class SkinMeshHelper;
37 class VideoTheoraPlayer;
38 struct XMeshObject;
39 
40 struct SkinWeights {
41  Common::String _boneName;
42  Math::Matrix4 _offsetMatrix;
43  BaseArray<uint32> _vertexIndices;
44  BaseArray<float> _vertexWeights;
45 };
46 
48  friend class XMesh;
49  friend class XMeshOpenGL;
50  friend class XMeshOpenGLShader;
51  friend class SkinMeshHelper;
52 
53 public:
54  XSkinMeshLoader(XMesh *mesh, XMeshObject *meshObject);
55  virtual ~XSkinMeshLoader();
56  void loadMesh(const Common::String &filename, XFileData *xobj, Common::Array<MaterialReference> &materialReferences);
57 
58 protected:
59  static const int kVertexComponentCount = 8;
60  static const int kPositionOffset = 5;
61  static const int kTextureCoordOffset = 0;
62  static const int kNormalOffset = 2;
63 
64  // anything which does not fit into 16 bits would we fine
65  static const uint32 kNullIndex = 0xFFFFFFFF;
66 
67  bool generateAdjacency(Common::Array<uint32> &adjacency);
68  bool adjacentEdge(uint16 index1, uint16 index2, uint16 index3, uint16 index4);
69 
70 public:
71  bool parsePositionCoords(XMeshObject *mesh);
72  bool parseFaces(XMeshObject *mesh, int faceCount, Common::Array<int> &indexCountPerFace);
73  bool parseTextureCoords(XFileData *xobj);
74  bool parseNormalCoords(XFileData *xobj);
75  bool parseMaterials(XFileData *xobj, BaseGame *inGame, int faceCount, const Common::String &filename,
76  Common::Array<MaterialReference> &materialReferences, const Common::Array<int> &indexCountPerFace);
77  bool parseSkinWeights(XFileData *xobj);
78  bool parseVertexDeclaration(XFileData *xobj);
79 
80 protected:
81 
82  float *_vertexData;
83  float *_vertexPositionData;
84  float *_vertexNormalData;
85  uint32 _vertexCount;
86  Common::Array<uint16> _indexData;
87 
88  BaseArray<Math::Matrix4 *> _boneMatrices;
89  BaseArray<SkinWeights> _skinWeightsList;
90 
91  BaseArray<int> _indexRanges;
92  BaseArray<int> _materialIndices;
93 
94  XMesh *_mesh;
95  XMeshObject *_meshObject;
96 };
97 
98 } // namespace Wintermute
99 
100 #endif
Definition: base_game.h:75
Definition: str.h:59
Definition: array.h:52
Definition: xskinmesh_loader.h:40
Definition: skin_mesh_helper.h:41
Definition: xmesh.h:48
Definition: xfile_loader.h:158
Definition: xskinmesh_loader.h:47
Definition: xfile_loader.h:452
Definition: achievements_tables.h:27