![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Represents a 3D triangle with support for UV mapping and ray intersection testing. More...
#include <Triangle3D.h>
Public Member Functions | |
Triangle3D () | |
Default constructor. | |
Triangle3D (Vector3D *p1, Vector3D *p2, Vector3D *p3) | |
Constructs a triangle with specified vertices. | |
Vector3D * | Normal () |
Calculates and returns the normal of the triangle. | |
bool | DidIntersect (Vector3D ray, Vector3D direction, Vector3D *intersect, Vector3D *color) |
Tests whether a ray intersects with the triangle. | |
String | ToString () |
Converts the triangle's data to a string representation. | |
Public Attributes | |
Vector3D * | p1 |
Pointer to the first vertex of the triangle. | |
Vector3D * | p2 |
Pointer to the second vertex of the triangle. | |
Vector3D * | p3 |
Pointer to the third vertex of the triangle. | |
const Vector2D * | p1UV |
Pointer to the UV coordinates of the first vertex. | |
const Vector2D * | p2UV |
Pointer to the UV coordinates of the second vertex. | |
const Vector2D * | p3UV |
Pointer to the UV coordinates of the third vertex. | |
Vector3D | edge1 |
Edge vector from the first to the second vertex. | |
Vector3D | edge2 |
Edge vector from the first to the third vertex. | |
Vector3D | normal |
Normal vector of the triangle. | |
bool | hasUV = false |
Indicates whether the triangle has UV mapping. | |
Represents a 3D triangle with support for UV mapping and ray intersection testing.
Definition at line 22 of file Triangle3D.h.
Triangle3D | ( | ) |
Default constructor.
Definition at line 3 of file Triangle3D.cpp.
Triangle3D | ( | Vector3D * | p1, |
Vector3D * | p2, | ||
Vector3D * | p3 | ||
) |
Tests whether a ray intersects with the triangle.
ray | The origin of the ray. |
direction | The direction of the ray. |
intersect | Output parameter for the intersection point. |
color | Output parameter for color (optional). |
Definition at line 21 of file Triangle3D.cpp.
References Vector3D::CrossProduct(), Vector3D::DotProduct(), edge1, edge2, Vector3D::Multiply(), p1, Vector3D::X, Vector3D::Y, and Vector3D::Z.
Vector3D * Normal | ( | ) |
Calculates and returns the normal of the triangle.
Definition at line 13 of file Triangle3D.cpp.
References Vector3D::CrossProduct(), edge1, edge2, normal, p1, p2, p3, and Vector3D::UnitSphere().
Referenced by ObjectAlign::GetPlaneNormal(), Triangle2D::Triangle2D(), and Triangle3D().
String ToString | ( | ) |
Converts the triangle's data to a string representation.
Definition at line 58 of file Triangle3D.cpp.
References p1, p2, p3, and Vector3D::ToString().
Vector3D edge1 |
Edge vector from the first to the second vertex.
Definition at line 32 of file Triangle3D.h.
Referenced by DidIntersect(), and Normal().
Vector3D edge2 |
Edge vector from the first to the third vertex.
Definition at line 33 of file Triangle3D.h.
Referenced by DidIntersect(), and Normal().
Indicates whether the triangle has UV mapping.
Definition at line 36 of file Triangle3D.h.
Referenced by Triangle2D::Triangle2D().
Vector3D normal |
Vector3D* p1 |
Pointer to the first vertex of the triangle.
Definition at line 24 of file Triangle3D.h.
Referenced by DidIntersect(), Normal(), ToString(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), and Triangle3D().
Pointer to the UV coordinates of the first vertex.
Definition at line 28 of file Triangle3D.h.
Referenced by Triangle2D::Triangle2D().
Vector3D* p2 |
Pointer to the second vertex of the triangle.
Definition at line 25 of file Triangle3D.h.
Referenced by Normal(), ToString(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), and Triangle3D().
Pointer to the UV coordinates of the second vertex.
Definition at line 29 of file Triangle3D.h.
Referenced by Triangle2D::Triangle2D().
Vector3D* p3 |
Pointer to the third vertex of the triangle.
Definition at line 26 of file Triangle3D.h.
Referenced by Normal(), ToString(), Triangle2D::Triangle2D(), Triangle2D::Triangle2D(), and Triangle3D().
Pointer to the UV coordinates of the third vertex.
Definition at line 30 of file Triangle3D.h.
Referenced by Triangle2D::Triangle2D().