BsFBXUtility.h 2.0 KB

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