ScummVM API documentation
material.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 WATCHMAKER_MATERIAL_H
23 #define WATCHMAKER_MATERIAL_H
24 
25 #include "common/array.h"
26 #include "common/ptr.h"
27 #include "watchmaker/3d/texture.h"
28 #include "watchmaker/3d/movie.h"
29 #include "watchmaker/3d/vertex.h"
30 
31 namespace Watchmaker {
32 
33 struct gMaterial;
34 typedef Common::SharedPtr<gMaterial> MaterialPtr;
35 typedef Common::Array<MaterialPtr> MaterialTable;
36 
37 struct VertexBuffer;
38 // Material definition
39 struct gMaterial {
40  gTexture *Texture = nullptr; // pointer to texture struct
41  Common::SharedPtr<gMovie> Movie; // pointer to movie struct
42  unsigned int Flags = 0; // material flags
43  int NumFaces() {
44  return FacesList.size();
45  }; // current number of faces to be processed
46  void addFace(uint16 face) {
47  FacesList.push_back(face);
48  }
49  uint16 getFace(int index) const {
50  return FacesList[index];
51  }
52  void clearFaceList() {
53  FacesList.clear();
54  }
55  void emptyFacesList() {
56  FacesList.resize(0);
57  }
58  Common::Array<uint16> getFacesList() {
59  return FacesList;
60  }
61 private:
62  Common::Array<uint16> FacesList; // list of verts indices
63 public:
64  Common::Array<gVertex *> VertsList; // pointers to pointers to verts
65  int NumAllocatedVerts() {
66  return this->VertsList.size();
67  }; // number of allocated vertex in mat VB
68  Common::SharedPtr<VertexBuffer> VBO = nullptr;
69 // LPDIRECT3DVERTEXBUFFER7 VB; // mat VB struct
70  int NumAllocatedMesh = 0; // num mesh to check for modifications
71  Common::Array<unsigned int *> FlagsList; // vector of pointer to mesh flags
72  unsigned char r, g, b; // default material color
73  int NumAddictionalMaterial = 0; // number of addictional material (lightmaps)
74  MaterialTable AddictionalMaterial; // pointer to addictional material struct
75 public:
76  gMaterial() : r(0), g(0), b(0) {
77 
78  }
79  void addColor(unsigned char r, unsigned char g, unsigned char b);
80  void addProperty(int flag);
81  bool hasFlag(int flag);
82  void clearFlag(int flag);
83  bool addNumFaces(unsigned int num);
84  bool addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num);
85  void clear();
86 };
87 
88 MaterialPtr rAddMaterial(MaterialTable &MList, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags);
89 MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags);
90 void rRemoveMaterial(MaterialPtr &m);
91 void rRemoveMaterials(MaterialTable &m);
92 void rCopyMaterialList(MaterialTable &dst, MaterialTable &src, uint count);
93 MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2);
94 void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum);
95 
96 
97 } // End of namespace Watchmaker
98 
99 #endif // WATCHMAKER_MATERIAL_H
Definition: 2d_stuff.h:30
Definition: str.h:59
void clear()
Definition: array.h:320
void push_back(const T &element)
Definition: array.h:180
Definition: texture.h:36
size_type size() const
Definition: array.h:315
void resize(size_type newSize)
Definition: array.h:411
Definition: material.h:39
Definition: dds_header.h:50