10 #include <AtomsUtils/Globals.h>
11 #include <AtomsUtils/AtomsMath.h>
12 #include <AtomsUtils/Triangle.h>
29 class ATOMSUTILS_EXPORT
Mesh
42 std::vector<AtomsMath::Vector2f> uvs;
43 std::vector<unsigned int> uvIndices;
59 bool hasGrid() {
return m_grid !=
nullptr; };
62 inline std::vector<AtomsMath::Vector3f>& points();
64 inline const std::vector<AtomsMath::Vector3f>& points()
const;
67 inline std::vector<AtomsMath::Vector3f>& normals();
69 inline const std::vector<AtomsMath::Vector3f>& normals()
const;
72 inline std::vector<unsigned int>& indices();
74 inline const std::vector<unsigned int>& indices()
const;
77 inline std::vector<unsigned int>& vertexCount();
79 inline const std::vector<unsigned int>& vertexCount()
const;
82 inline std::vector<AtomsMath::Vector2f>& uvs();
84 inline const std::vector<AtomsMath::Vector2f>& uvs()
const;
87 inline unsigned int numberOfFaces()
const;
90 inline unsigned int numberOfVertices()
const;
93 inline std::vector<AtomsMath::Vector3f>& jointWeights();
96 inline const std::vector<AtomsMath::Vector3f>& jointWeights()
const;
99 inline std::vector<AtomsMath::Vector3i>& jointIndices();
102 inline const std::vector<AtomsMath::Vector3i>& jointIndices()
const;
105 inline std::vector<UVData>& uvSets();
108 inline const std::vector<UVData>& uvSets()
const;
117 virtual bool intersect(
const AtomsMath::Vector3f &orig,
const AtomsMath::Vector3f &dir,
float ¶m,
unsigned int &outFaceId,
float& outU,
float &outV,
bool bothDirection =
false)
const;
120 virtual bool closestPoint(
const AtomsMath::Vector3f& inP, AtomsMath::Vector3f& outP,
unsigned int& outFaceId,
float& outU,
float& outV,
float& sqrDistance)
const;
123 virtual bool isInside(
const AtomsMath::Vector3f& point)
const;
147 void createPlane(
const AtomsMath::Box2f& b,
const AtomsMath::Vector2i& divisions);
150 void createSphere(
float radius,
unsigned int sectorCount,
unsigned int stackCount);
161 AtomsMath::Box3f boundingBox(
const AtomsMath::Matrixf& matrix)
const;
165 static void triangulateMesh(
const Mesh& input,
Mesh& output);
170 std::vector<AtomsMath::Vector3f> m_points;
173 std::vector<AtomsMath::Vector3f> m_normal;
176 std::vector<unsigned int> m_indices;
179 std::vector<unsigned int> m_vertexCount;
182 std::vector<AtomsMath::Vector2f> m_uvs;
185 std::vector<AtomsMath::Vector3f> m_jointWeights;
188 std::vector<AtomsMath::Vector3i> m_jointIndices;
191 std::vector<UVData> m_uvSets;
202 #include "Mesh.impl.h"
Mesh class.
Definition: Mesh.h:30
void createBox(const AtomsMath::Box3f &b)
Create a box.
void createDisk(float radius, unsigned int sectorCount)
Create a disk.
void createSphere(float radius, unsigned int sectorCount, unsigned int stackCount)
Create a sphere.
void clear()
Clear mesh data.
void createPlane(const AtomsMath::Box2f &b, const AtomsMath::Vector2i &divisions)
Create a plane.
void merge(Mesh &inMesh)
Merge a mesh.
void transform(const AtomsMath::Matrixf &matrix)
Transform.
virtual bool intersect(const AtomsMath::Vector3f &orig, const AtomsMath::Vector3f &dir, float ¶m, unsigned int &outFaceId, float &outU, float &outV, bool bothDirection=false) const
intersect
void clearIntersectionGrid()
Clear the intersection grid.
void buildIntersectionGrid(short gridMode=kKdtree)
Build kd tree.
void multiplyPointsByMatrix(const AtomsMath::Matrix &matrix)
Multiply all points by the given matrix.
Mesh & operator=(const Mesh &rhs)
Assign operator.
bool hasGrid()
Check if it has underlying kdtree grid.
Definition: Mesh.h:59
void changeWindingOrder()
Change winding order.
virtual ~Mesh()
Destructor.
void computeSoftEdgeNormals()
Compute averaged face vertex normals.
void createPyramid(float radius, float height, unsigned int faceCount)
Create a pyramid.
Mesh(const Mesh &rhs)
Copy constructor.
virtual bool closestPoint(const AtomsMath::Vector3f &inP, AtomsMath::Vector3f &outP, unsigned int &outFaceId, float &outU, float &outV, float &sqrDistance) const
Closets point.
void triangulate()
Triangulate.
virtual bool isInside(const AtomsMath::Vector3f &point) const
Check if a point is inside this mesh.
AtomsCore namespace.
Definition: Base64.h:13