Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
|
3d triangle template class for doing collision detection and other things. More...
#include <nirtcpp/core/engine/triangle3d.hpp>
Public Member Functions | |
triangle3d () | |
Constructor for an all 0 triangle. | |
triangle3d (const vector3d< T > &v1, const vector3d< T > &v2, const vector3d< T > &v3) | |
Constructor for triangle with given three vertices. | |
bool | operator== (const triangle3d< T > &other) const |
Equality operator. | |
bool | operator!= (const triangle3d< T > &other) const |
Inequality operator. | |
bool | isTotalInsideBox (const aabbox3d< T > &box) const |
Determines if the triangle is totally inside a bounding box. | |
bool | isTotalOutsideBox (const aabbox3d< T > &box) const |
Determines if the triangle is totally outside a bounding box. | |
core::vector3d< T > | closestPointOnTriangle (const core::vector3d< T > &p) const |
Get the closest point on a triangle to a point on the same plane. | |
bool | isPointInside (const vector3d< T > &p) const |
Check if a point is inside the triangle (border-points count also as inside) | |
bool | isPointInsideFast (const vector3d< T > &p) const |
Check if a point is inside the triangle (border-points count also as inside) | |
bool | getIntersectionWithLimitedLine (const line3d< T > &line, vector3d< T > &outIntersection) const |
Get an intersection with a 3d line. | |
bool | getIntersectionWithLine (const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const |
Get an intersection with a 3d line. | |
bool | getIntersectionOfPlaneWithLine (const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const |
Calculates the intersection between a 3d line and the plane the triangle is on. | |
vector3d< T > | getNormal () const |
Get the normal of the triangle. | |
bool | isFrontFacing (const vector3d< T > &lookDirection) const |
Test if the triangle would be front or backfacing from any point. | |
plane3d< T > | getPlane () const |
Get the plane of this triangle. | |
T | getArea () const |
Get the area of the triangle. | |
void | set (const core::vector3d< T > &a, const core::vector3d< T > &b, const core::vector3d< T > &c) |
sets the triangle's points | |
Public Attributes | |
vector3d< T > | pointA |
the three points of the triangle | |
vector3d< T > | pointB |
vector3d< T > | pointC |
3d triangle template class for doing collision detection and other things.
|
inline |
Get the closest point on a triangle to a point on the same plane.
p | Point which must be on the same plane as the triangle. |
|
inline |
Calculates the intersection between a 3d line and the plane the triangle is on.
lineVect | Vector of the line to intersect with. |
linePoint | Point of the line to intersect with. |
outIntersection | Place to store the intersection point, if there is one. |
|
inline |
Get an intersection with a 3d line.
line | Line to intersect with. |
outIntersection | Place to store the intersection point, if there is one. |
|
inline |
Get an intersection with a 3d line.
Please note that also points are returned as intersection which are on the line, but not between the start and end point of the line. If you want the returned point be between start and end use getIntersectionWithLimitedLine().
linePoint | Point of the line to intersect with. |
lineVect | Vector of the line to intersect with. |
outIntersection | Place to store the intersection point, if there is one. |
Get the normal of the triangle.
Please note: The normal is not always normalized.
Test if the triangle would be front or backfacing from any point.
Thus, this method assumes a camera position from which the triangle is definitely visible when looking at the given direction. Do not use this method with points as it will give wrong results!
lookDirection | Look direction. |
Check if a point is inside the triangle (border-points count also as inside)
This method uses a barycentric coordinate system. It is faster than isPointInside but is more susceptible to floating point rounding errors. This will especially be noticeable when the FPU is in single precision mode (which is for example set on default by Direct3D).
p | Point to test. Assumes that this point is already on the plane of the triangle. |
Determines if the triangle is totally inside a bounding box.
box | Box to check. |
Determines if the triangle is totally outside a bounding box.
box | Box to check. |