ScummVM API documentation
te_mesh.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 TETRAEDGE_TE_TE_MESH_H
23 #define TETRAEDGE_TE_TE_MESH_H
24 
25 #include "common/array.h"
26 #include "common/ptr.h"
27 
28 #include "tetraedge/te/te_3d_object2.h"
29 #include "tetraedge/te/te_3d_texture.h"
30 #include "tetraedge/te/te_color.h"
31 #include "tetraedge/te/te_intrusive_ptr.h"
32 #include "tetraedge/te/te_vector2f32.h"
33 #include "tetraedge/te/te_vector3f32.h"
34 #include "tetraedge/te/te_matrix4x4.h"
35 #include "tetraedge/te/te_material.h"
36 #include "tetraedge/te/te_model_vertex_animation.h"
37 
38 namespace Tetraedge {
39 
40 class TeModel;
41 class TeModelVertexAnimation;
42 
43 class TeMesh : public Te3DObject2 {
44 public:
45  TeMesh();
46 
47  virtual ~TeMesh() {};
48 
49  enum Mode {
50  MeshMode_None = 0,
51  MeshMode_Points,
52  MeshMode_Lines,
53  MeshMode_LineLoop,
54  MeshMode_LineStrip,
55  MeshMode_Triangles,
56  MeshMode_TriangleStrip,
57  MeshMode_TriangleFan
58  };
59 
60  void attachMaterial(uint idx, const TeMaterial &material);
61  void boundingBox(TeVector3f32 &boxmin, TeVector3f32 boxmax);
62  void checkArrays() {};
63  void clearColors() { _colors.clear(); }
64  TeColor color(uint idx) const { return _colors[idx]; }
65  void copy(const TeMesh &other);
66  void create();
67  void defaultMaterial(const TeIntrusivePtr<Te3DTexture> &texture);
68  void destroy();
69  void facesPerMaterial(uint idx, unsigned short value);
70  unsigned short facesPerMaterial(uint idx) const { return _faceCounts[idx]; }
71  void forceMatrix(const TeMatrix4x4 &matrix);
72  byte getFaceMaterial(uint idx);
73  virtual uint32 getTexEnvMode() const = 0;
74  virtual TeMesh::Mode getMode() const = 0;
75  virtual void setMode(enum Mode mode) = 0;
76  bool hasAlpha(uint idx);
77  bool hasColor() const { return !_colors.empty(); }
78  bool hasUvs() const { return !_uvs.empty(); }
79  unsigned short index(uint num) const { return _indexes[num]; }
80  TeMaterial *material(uint idx);
81  const TeMaterial *material(uint idx) const;
82  void materialIndex(uint idx, byte val);
83  byte materialIndex(uint idx) const { return _materialIndexes[idx]; }
84  void matrixIndex(uint num, unsigned short val);
85  unsigned short matrixIndex(uint num) const { return _matricies[num]; }
86  TeVector3f32 normal(uint idx) const;
87 
88  void optimizeVerticies();
89  void resizeUpdatedTables(uint newSize);
90 
91  void setColor(const TeColor &col) override;
92  void setColor(uint idx, const TeColor &col);
93  void setConf(uint vertexCount, uint indexCount, enum Mode mode, uint materialCount, uint materialIndexCount);
94  void setIndex(uint idx, uint val);
95  void setNormal(uint idx, const TeVector3f32 &val);
96  void setTextureUV(uint idx, const TeVector2f32 &val);
97  void setVertex(uint idx, const TeVector3f32 &val);
98  void sortFaces();
99 
100  void update(const Common::Array<TeMatrix4x4> *matricies1, const Common::Array<TeMatrix4x4> *matricies2);
101  void update(TeIntrusivePtr<TeModelVertexAnimation> vertexanim);
102  void updateTo(const Common::Array<TeMatrix4x4> *matricies1, const Common::Array<TeMatrix4x4> *matricies2,
104 
105  TeVector2f32 textureUV(uint idx) const { return _uvs[idx]; }
106  TeVector3f32 vertex(uint idx) const;
107 
108  uint numIndexes() const { return _indexes.size(); }
109  uint numVerticies() const { return _verticies.size(); }
110  bool shouldDrawMaybe() const { return _shouldDraw; }
111 
112  void setShouldDraw(bool val) { _shouldDraw = val; }
113  virtual void setglTexEnvBlend() = 0;
114  void setHasAlpha(bool val) { _hasAlpha = val; }
115 
116  Common::Array<TeMaterial> &materials() { return _materials; }
117  void setUpdatedVertex(uint idx, const TeVector3f32 &val) { _updatedVerticies[idx] = val; }
118  void setUpdatedNormal(uint idx, const TeVector3f32 &val) { _updatedNormals[idx] = val; }
119 
120  const TeVector3f32 &preUpdatedVertex(uint idx) const { return _verticies[idx]; }
121  const TeVector3f32 &preUpdatedNormal(uint idx) const { return _normals[idx]; }
122 
123  static TeMesh *makeInstance();
124 
125 protected:
126  Common::Array<unsigned char> _materialIndexes;
127  Common::Array<TeVector3f32> _verticies;
129  Common::Array<TeVector3f32> _updatedVerticies;
130  Common::Array<TeVector3f32> _updatedNormals;
133  Common::Array<unsigned short> _faceCounts;
135  Common::Array<TeColor> _colors;
136  Common::Array<TeMaterial> _materials;
137 
138  bool _matrixForced;
139  TeMatrix4x4 _forcedMatrix;
140  bool _hasAlpha;
141  uint _initialMaterialIndexCount;
142  bool _drawWires;
143  bool _shouldDraw;
144 
145 };
146 
147 } // end namespace Tetraedge
148 
149 #endif // TETRAEDGE_TE_TE_MESH_H
Definition: detection.h:27
Definition: te_mesh.h:43
Definition: array.h:52
Definition: te_color.h:30
Definition: te_matrix4x4.h:37
Definition: te_3d_object2.h:36
Definition: te_material.h:35
size_type size() const
Definition: array.h:315
Definition: te_intrusive_ptr.h:31
Definition: te_vector3f32.h:33
Definition: te_vector2f32.h:32