BsFBXUtility.h 2.2 KB

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