DatasmithMesh.h
1 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
2 #pragma once
3 
4 #include "Math/Box.h"
5 
6 class DATASMITHCORE_API FDatasmithMesh
7 {
8 public:
10  ~FDatasmithMesh();
11 
12  FDatasmithMesh( const FDatasmithMesh& Other );
13  FDatasmithMesh( FDatasmithMesh&& Other );
14 
15  FDatasmithMesh& operator=( const FDatasmithMesh& Other );
16  FDatasmithMesh& operator=( FDatasmithMesh&& Other );
17 
18  void SetName(const TCHAR* InName);
19  const TCHAR* GetName() const;
20 
21  //--------------------------
22  // Faces
23  //--------------------------
24  /** Setting the amount of faces is mandatory before filling the array */
25  void SetFacesCount(int32 NumFaces);
26 
27  /** Retrieves the amount of faces */
28  int32 GetFacesCount() const;
29 
30  /**
31  * Sets the geometry of the face
32  *
33  * @param Index value to choose the face that will be affected
34  * @param Vertex1 Index of the first geometric vertex that defines this face
35  * @param Vertex2 Index of the second geometric vertex that defines this face
36  * @param Vertex3 Index of the third geometric vertex that defines this face
37  */
38  void SetFace(int32 Index, int32 Vertex1, int32 Vertex2, int32 Vertex3, int32 MaterialId = 0);
39  void GetFace(int32 Index, int32& Vertex1, int32& Vertex2, int32& Vertex3, int32& MaterialId) const;
40 
41  /**
42  * Sets the smoothing mask of the face
43  *
44  * @param Index Index of the face that will be affected
45  * @param SmoothingMask 32 bits mask, 0 means no smoothing
46  */
47  void SetFaceSmoothingMask(int32 Index, uint32 SmoothingMask);
48 
49  /**
50  * Gets the smoothing mask of a face
51  *
52  * @param Index Index of the face to retrieve the smoothing mask from
53  */
54  uint32 GetFaceSmoothingMask(int32 Index) const;
55 
56  int32 GetMaterialsCount() const;
57  bool IsMaterialIdUsed(int32 MaterialId) const;
58 
59  //--------------------------
60  // Vertices
61  //--------------------------
62  /** Setting the amount of geometric vertices is mandatory before filling the array */
63  void SetVerticesCount(int32 NumVerts);
64 
65  /** Retrieves the amount of geometric vertices. The validity of the vertex data is not guaranteed */
66  int32 GetVerticesCount() const;
67 
68  /**
69  * Sets the 3d position of the vertex
70  *
71  * @param Index value to choose the vertex that will be affected
72  * @x position on the x axis
73  * @y position on the y axis
74  * @z position on the z axis
75  */
76  void SetVertex(int32 Index, float X, float Y, float Z);
77  FVector GetVertex(int32 Index) const;
78 
79  //--------------------------
80  // Normals
81  //--------------------------
82  /**
83  * Sets the 3d normal
84  *
85  * @param Index value to choose the normal that will be affected
86  * @x direction on the x axis
87  * @y direction on the y axis
88  * @z direction on the z axis
89  */
90  void SetNormal(int32 Index, float X, float Y, float Z);
91  FVector GetNormal(int32 Index) const;
92 
93  //--------------------------
94  // UVs
95  //--------------------------
96  /**
97  * Sets the amount of UV channels on this mesh
98  *
99  * @param ChannelCount The number of UV channels
100  */
101  void SetUVChannelsCount(int32 ChannelCount);
102 
103  /**
104  * Add a UV channel at the end
105  */
106  void AddUVChannel();
107 
108  /**
109  * Remove the last UV channel
110  */
111  void RemoveUVChannel();
112 
113  /** Gets the amount of UV channels on this mesh */
114  int32 GetUVChannelsCount() const;
115 
116  /**
117  * Setting the amount of UV coordinates on the channel is mandatory before filling the array
118  *
119  * @param Channel The channel to set the numbers of UVs
120  * @param NumVerts The number of UVs in the channel
121  */
122  void SetUVCount(int32 Channel, int32 NumVerts);
123 
124  /** Retrieves the amount of UV coordinates on the channel. The validity of the vertex data is not guaranteed */
125  int32 GetUVCount(int32 Channel) const;
126 
127  /**
128  * Sets the 2d position of the UV vertex for the first uv mapping
129  *
130  * @param Index Value to choose the vertex that will be affected
131  * @param U Horizontal coordinate
132  * @param V Vertical coordinate
133  */
134  void SetUV(int32 Channel, int32 Index, double U, double V);
135 
136  /**
137  * Get the hash for a uv channel
138  */
139  uint32 GetHashForUVChannel(int32 Channel) const;
140 
141  /**
142  * Gets the UV coordinates for a channel
143  *
144  * @param Channel The channel we want to retrieve the UVs from
145  * @param Index The UV coordinates to retrieve
146  */
147  FVector2D GetUV(int32 Channel, int32 Index) const;
148 
149  /**
150  * Sets the channel UV coordinates of the face
151  *
152  * @param Index Index of the face that will be affected
153  * @param Channel UV channel, starting at 0
154  * @param Vertex1 Index of the first uv vertex that defines this face
155  * @param Vertex2 Index of the second uv vertex that defines this face
156  * @param Vertex3 Index of the third uv vertex that defines this face
157  */
158  void SetFaceUV(int32 Index, int32 Channel, int32 Vertex1, int32 Vertex2, int32 Vertex3);
159 
160  /**
161  * Gets the UV coordinates of the vertices of a face
162  *
163  * @param Index Index of the face to retrieve the UVs from
164  * @param Channel UV channel, starting at 0
165  * @param Vertex1 Index of the first uv vertex that defines this face
166  * @param Vertex2 Index of the second uv vertex that defines this face
167  * @param Vertex3 Index of the third uv vertex that defines this face
168  */
169  void GetFaceUV(int32 Index, int32 Channel, int32& Vertex1, int32& Vertex2, int32& Vertex3) const;
170 
171  /** Get the number of vertex color */
172  int32 GetVertexColorCount() const;
173 
174  /**
175  * Set a vertex color
176  *
177  * @param Index Index of the vertex color that will be affected
178  * @param Color The color for the vertex
179  */
180  void SetVertexColor(int32 Index, const FColor& Color);
181 
182  /**
183  * Get the color for a vertex
184  *
185  * @param Index Index of the vertex color to retrieve
186  */
187  FColor GetVertexColor(int32 Index) const;
188 
189  /**
190  * Sets the UV channel that will be used as the source UVs for lightmap UVs generation at import, defaults to channel 0.
191  * Will be overwritten during Mesh export if we choose to generate the lightmap source UVs.
192  */
193  void SetLightmapSourceUVChannel(int32 Channel);
194 
195  /** Gets the UV channel that will be used for lightmap UVs generation at import */
196  int32 GetLightmapSourceUVChannel() const;
197 
198  //--------------------------
199  // LODs
200  //--------------------------
201 
202  /** Adds a LOD mesh to this base LOD mesh */
203  void AddLOD( const FDatasmithMesh& InLODMesh );
204  void AddLOD( FDatasmithMesh&& InLODMesh );
205  int32 GetLODsCount() const;
206  FDatasmithMesh& GetLOD( int32 Index );
207  const FDatasmithMesh& GetLOD( int32 Index ) const;
208 
209  //--------------------------
210  // Misc
211  //--------------------------
212  /** Returns the total surface area */
213  float ComputeArea() const;
214 
215  /** Returns the bounding box containing all vertices of this mesh */
216  FBox GetExtents() const;
217 
218 private:
219  class FDatasmithMeshImpl;
220  FDatasmithMeshImpl* Impl;
221 
222 };
FDatasmithMesh
Definition: DatasmithMesh.h:6