1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsFBXPrerequisites.h"
6#include "BsFBXImportData.h"
7
8namespace bs
9{
10 /** @addtogroup FBX
11 * @{
12 */
13
14 /** Various helper methods to use during FBX import. */
15 class FBXUtility
16 {
17 public:
18 /** Calculates per-index normals based on the provided smoothing groups. */
19 static void normalsFromSmoothing(const Vector<Vector3>& positions, const Vector<int>& indices,
20 const Vector<int>& smoothing, Vector<Vector3>& normals);
21
22 /**
23 * Find vertices in the source mesh that have different attributes but have the same indexes, and splits them into
24 * two or more vertexes. Mesh with split vertices is output to @p dest.
25 *
26 * @param[in] source Source mesh to perform the split on. It's expected the position values are per-vertex, and
27 * all other attributes are per-index.
28 * @param[in] dest Output mesh with split vertices. Both vertex positions and attributes are per-vertex.
29 */
30 static void splitVertices(const FBXImportMesh& source, FBXImportMesh& dest);
31
32 /** Flips the triangle window order for all the triangles in the mesh. */
33 static void flipWindingOrder(FBXImportMesh& input);
34
35 private:
36 /** Checks if vertex attributes at the specified indexes are similar enough, or does the vertex require a split. */
37 static bool needsSplitAttributes(const FBXImportMesh& meshA, int idxA, const FBXImportMesh& meshB, int idxB);
38
39 /**
40 * Copies vertex attributes from the source mesh at the specified index, to the destination mesh at the specified
41 * index.
42 */
43 static void copyVertexAttributes(const FBXImportMesh& srcMesh, int srcIdx, FBXImportMesh& destMesh, int dstIdx);
44
45 /**
46 * Adds a new vertex to the destination mesh and copies the vertex from the source mesh at the vertex index, and
47 * vertex attributes from the source mesh at the source index.
48 */
49 static void addVertex(const FBXImportMesh& srcMesh, int srcIdx, int srcVertex, FBXImportMesh& destMesh);
50 };
51
52 /** @} */
53}