Debian Codegraph @

include/imodelsurface.h

raw
1 #pragma once
2
3 // Math/Vertex classes
4 #include "render/MeshVertex.h"
5
6 class AABB;
7
8 namespace model
9 {
10
11 // A Polygon (Triangle) which is part of a model surface
12 struct ModelPolygon
13 {
14 MeshVertex a;
15 MeshVertex b;
16 MeshVertex c;
17 };
18
19 // Abstract definition of a model surface
20 class IModelSurface
21 {
22 public:
23 // Returns the number of vertices of this surface
24 virtual int getNumVertices() const = 0;
25
26 // Returns the number of tris of this surface
27 virtual int getNumTriangles() const = 0;
28
29 // Get a specific vertex of this surface
30 virtual const MeshVertex& getVertex(int vertexNum) const = 0;
31
32 /**
33 * greebo: Returns a specific polygon from this model surface.
34 * Don't expect this to be fast as things are returned by value.
35 * This is merely to provide read access to the model polygons
36 * for scripts and plugins.
37 */
38 virtual ModelPolygon getPolygon(int polygonNum) const = 0;
39
40 /**
41 * Get the name of the default material for this surface, i.e.
42 * the name of the material without any skin applied.
43 */
44 virtual const std::string& getDefaultMaterial() const = 0;
45
46 /**
47 * Return the name of the currently assigned material,
48 * respecting the applied skin.
49 */
50 virtual const std::string& getActiveMaterial() const = 0;
51
52 // Returns the local bounds of this surface
53 virtual const AABB& getSurfaceBounds() const = 0;
54 };
55
56 /**
57 * Model surface supporting direct access to its vertex and index arrays
58 * which define the polygons. Model surfaces in DarkRadiant are loaded by
59 * the PicoModel library which generates clockwise polygon windings.
60 */
61 class IIndexedModelSurface :
62 public IModelSurface
63 {
64 public:
65 // Const access to the vertices used in this surface.
66 virtual const std::vector<MeshVertex>& getVertexArray() const = 0;
67
68 // Const access to the index array connecting the vertices.
69 virtual const std::vector<unsigned int>& getIndexArray() const = 0;
70 };
71
72 } // namespace