Loading...
Searching...
No Matches
Triangle3.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_TRIANGLE3_HPP
12#define CUBBYFLOW_TRIANGLE3_HPP
13
15
16namespace CubbyFlow
17{
24class Triangle3 final : public Surface3
25{
26 public:
27 class Builder;
28
31 {
32 // Do nothing
33 }
34
37 bool _isNormalFlipped = false);
38
40 Triangle3(std::array<Vector3D, 3> points, std::array<Vector3D, 3> normals,
41 std::array<Vector2D, 3> uvs,
43 bool _isNormalFlipped = false);
44
46 Triangle3(const Triangle3&) = default;
47
50
53
56
59
61 [[nodiscard]] double Area() const;
62
64 void GetBarycentricCoords(const Vector3D& pt, double* b0, double* b1,
65 double* b2) const;
66
69
72
75
78
81
84
88
90
92
95
98};
99
102
107{
108 public:
110 [[nodiscard]] Builder& WithPoints(const std::array<Vector3D, 3>& _points);
111
113 [[nodiscard]] Builder& WithNormals(const std::array<Vector3D, 3>& _normals);
114
116 [[nodiscard]] Builder& WithUVs(const std::array<Vector2D, 3>& _uvs);
117
120
123
124 private:
125 std::array<Vector3D, 3> m_points;
126 std::array<Vector3D, 3> m_normals;
127 std::array<Vector2D, 3> m_uvs;
128};
129} // namespace CubbyFlow
130
131#endif
N-D axis-aligned bounding box class.
Definition BoundingBox.hpp:47
Definition Matrix.hpp:30
Class for N-D ray.
Definition Ray.hpp:26
Base class for N-D surface builder.
Definition Surface.hpp:154
Abstract base class for N-D surface.
Definition Surface.hpp:39
Represents N-D rigid body transform.
Definition Transform.hpp:83
Front-end to create Triangle3 objects step by step.
Definition Triangle3.hpp:107
Builder & WithUVs(const std::array< Vector2D, 3 > &_uvs)
Returns builder with uvs.
Triangle3 Build() const
Builds Triangle3.
Triangle3Ptr MakeShared() const
Builds shared pointer of Triangle3 instance.
Builder & WithPoints(const std::array< Vector3D, 3 > &_points)
Returns builder with points.
Builder & WithNormals(const std::array< Vector3D, 3 > &_normals)
Returns builder with normals.
3-D triangle geometry.
Definition Triangle3.hpp:25
Triangle3()
Constructs an empty triangle.
Definition Triangle3.hpp:30
Vector3D FaceNormal() const
Returns the face normal of the triangle.
BoundingBox3D BoundingBoxLocal() const override
Returns the bounding box of this surface object in local frame.
SurfaceRayIntersection3 ClosestIntersectionLocal(const Ray3D &ray) const override
void GetBarycentricCoords(const Vector3D &pt, double *b0, double *b1, double *b2) const
Returns barycentric coordinates for the given point pt.
bool IntersectsLocal(const Ray3D &ray) const override
void SetNormalsToFaceNormal()
Set Triangle3::normals to the face normal.
Triangle3(const Transform3 &_transform, bool _isNormalFlipped=false)
Constructs an empty triangle with a transform.
std::array< Vector3D, 3 > normals
Three normals.
Definition Triangle3.hpp:80
std::array< Vector3D, 3 > points
Three points.
Definition Triangle3.hpp:77
Triangle3(Triangle3 &&) noexcept=default
Default move constructor.
Triangle3(const Triangle3 &)=default
Default copy constructor.
static Builder GetBuilder()
Returns builder fox Triangle3.
std::array< Vector2D, 3 > uvs
Three UV coordinates.
Definition Triangle3.hpp:83
Triangle3(std::array< Vector3D, 3 > points, std::array< Vector3D, 3 > normals, std::array< Vector2D, 3 > uvs, const Transform3 &_transform=Transform3{}, bool _isNormalFlipped=false)
Constructs a triangle with given points, normals, and uvs.
double Area() const
Returns the area of this triangle.
Vector3D ClosestPointLocal(const Vector3D &otherPoint) const override
Vector3D ClosestNormalLocal(const Vector3D &otherPoint) const override
Definition pybind11Utils.hpp:22
std::shared_ptr< Triangle3 > Triangle3Ptr
Shared pointer for the Triangle3 type.
Definition Triangle3.hpp:101
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26