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{
93
96
101{
102 public:
104 [[nodiscard]] Builder& WithPoints(const std::array<Vector3D, 3>& _points);
105
107 [[nodiscard]] Builder& WithNormals(const std::array<Vector3D, 3>& _normals);
108
110 [[nodiscard]] Builder& WithUVs(const std::array<Vector2D, 3>& _uvs);
111
114
117
118 private:
119 std::array<Vector3D, 3> m_points;
120 std::array<Vector3D, 3> m_normals;
121 std::array<Vector2D, 3> m_uvs;
122};
123} // namespace CubbyFlow
124
125#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:101
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
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.
std::array< Vector3D, 3 > normals
Three normals.
Definition Triangle3.hpp:74
std::array< Vector3D, 3 > points
Three points.
Definition Triangle3.hpp:71
Triangle3(Triangle3 &&) noexcept=default
Default move constructor.
Triangle3(const Triangle3 &)=default
Default copy constructor.
Triangle3(const Transform3 &_transform=Transform3{}, bool _isNormalFlipped=false)
Constructs an empty triangle.
static Builder GetBuilder()
Returns builder fox Triangle3.
std::array< Vector2D, 3 > uvs
Three UV coordinates.
Definition Triangle3.hpp:77
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:21
std::shared_ptr< Triangle3 > Triangle3Ptr
Shared pointer for the Triangle3 type.
Definition Triangle3.hpp:95
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
Struct that represents ray-surface intersection point.
Definition Surface.hpp:26