3d triangle template class for doing collision detection and other things. More...
#include <triangle3d.h>
3d triangle template class for doing collision detection and other things.
Definition at line 20 of file triangle3d.h.
irr::core::triangle3d< T >::triangle3d | ( | ) | [inline] |
Constructor for an all 0 triangle.
Definition at line 25 of file triangle3d.h.
irr::core::triangle3d< T >::triangle3d | ( | vector3d< T > | v1, |
vector3d< T > | v2, | ||
vector3d< T > | v3 | ||
) | [inline] |
Constructor for triangle with given three vertices.
Definition at line 27 of file triangle3d.h.
core::vector3d<T> irr::core::triangle3d< T >::closestPointOnTriangle | ( | const core::vector3d< T > & | p | ) | const [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. |
Definition at line 68 of file triangle3d.h.
References irr::core::vector3d< T >::getDistanceFrom(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
T irr::core::triangle3d< T >::getArea | ( | ) | const [inline] |
Get the area of the triangle.
Definition at line 224 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
bool irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine | ( | const vector3d< T > & | linePoint, |
const vector3d< T > & | lineVect, | ||
vector3d< T > & | outIntersection | ||
) | const [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. |
Definition at line 169 of file triangle3d.h.
References irr::core::vector3d< T >::dotProduct(), irr::core::triangle3d< T >::getNormal(), irr::core::iszero(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, irr::core::triangle3d< T >::pointC, irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.
Referenced by irr::core::triangle3d< T >::getIntersectionWithLine().
bool irr::core::triangle3d< T >::getIntersectionWithLimitedLine | ( | const line3d< T > & | line, |
vector3d< T > & | outIntersection | ||
) | const [inline] |
Get an intersection with a 3d line.
line | Line to intersect with. |
outIntersection | Place to store the intersection point, if there is one. |
Definition at line 136 of file triangle3d.h.
References irr::core::line3d< T >::end, irr::core::triangle3d< T >::getIntersectionWithLine(), irr::core::line3d< T >::getVector(), irr::core::vector3d< T >::isBetweenPoints(), and irr::core::line3d< T >::start.
bool irr::core::triangle3d< T >::getIntersectionWithLine | ( | const vector3d< T > & | linePoint, |
const vector3d< T > & | lineVect, | ||
vector3d< T > & | outIntersection | ||
) | const [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. |
Definition at line 154 of file triangle3d.h.
References irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), and irr::core::triangle3d< T >::isPointInside().
Referenced by irr::core::triangle3d< T >::getIntersectionWithLimitedLine().
vector3d<T> irr::core::triangle3d< T >::getNormal | ( | ) | const [inline] |
Get the normal of the triangle.
Please note: The normal is not always normalized.
Definition at line 199 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
Referenced by irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), and irr::core::triangle3d< T >::isFrontFacing().
plane3d<T> irr::core::triangle3d< T >::getPlane | ( | ) | const [inline] |
Get the plane of this triangle.
Definition at line 218 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
bool irr::core::triangle3d< T >::isFrontFacing | ( | const vector3d< T > & | lookDirection | ) | const [inline] |
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. |
Definition at line 210 of file triangle3d.h.
References irr::core::vector3d< T >::dotProduct(), F32_LOWER_EQUAL_0, and irr::core::triangle3d< T >::getNormal().
bool irr::core::triangle3d< T >::isPointInside | ( | const vector3d< T > & | p | ) | const [inline] |
Check if a point is inside the triangle (border-points count also as inside)
Definition at line 89 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, irr::core::triangle3d< T >::pointC, irr::core::vector3d< T >::X, irr::core::vector3d< T >::Y, and irr::core::vector3d< T >::Z.
Referenced by irr::core::triangle3d< T >::getIntersectionWithLine().
bool irr::core::triangle3d< T >::isPointInsideFast | ( | const vector3d< T > & | p | ) | const [inline] |
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 noticable 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. |
Definition at line 108 of file triangle3d.h.
References irr::core::vector3d< T >::dotProduct(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, irr::core::triangle3d< T >::pointC, and irr::core::ROUNDING_ERROR_f32.
bool irr::core::triangle3d< T >::isTotalInsideBox | ( | const aabbox3d< T > & | box | ) | const [inline] |
Determines if the triangle is totally inside a bounding box.
box | Box to check. |
Definition at line 44 of file triangle3d.h.
References irr::core::aabbox3d< T >::isPointInside(), irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
bool irr::core::triangle3d< T >::isTotalOutsideBox | ( | const aabbox3d< T > & | box | ) | const [inline] |
Determines if the triangle is totally outside a bounding box.
box | Box to check. |
Definition at line 54 of file triangle3d.h.
References irr::core::aabbox3d< T >::MaxEdge, irr::core::aabbox3d< T >::MinEdge, irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
bool irr::core::triangle3d< T >::operator!= | ( | const triangle3d< T > & | other | ) | const [inline] |
Inequality operator.
Definition at line 36 of file triangle3d.h.
bool irr::core::triangle3d< T >::operator== | ( | const triangle3d< T > & | other | ) | const [inline] |
Equality operator.
Definition at line 30 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
void irr::core::triangle3d< T >::set | ( | const core::vector3d< T > & | a, |
const core::vector3d< T > & | b, | ||
const core::vector3d< T > & | c | ||
) | [inline] |
sets the triangle's points
Definition at line 231 of file triangle3d.h.
References irr::core::triangle3d< T >::pointA, irr::core::triangle3d< T >::pointB, and irr::core::triangle3d< T >::pointC.
vector3d<T> irr::core::triangle3d< T >::pointA |
the three points of the triangle
Definition at line 239 of file triangle3d.h.
Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().
vector3d<T> irr::core::triangle3d< T >::pointB |
Definition at line 240 of file triangle3d.h.
Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().
vector3d<T> irr::core::triangle3d< T >::pointC |
Definition at line 241 of file triangle3d.h.
Referenced by irr::core::triangle3d< T >::closestPointOnTriangle(), irr::core::triangle3d< T >::getArea(), irr::core::triangle3d< T >::getIntersectionOfPlaneWithLine(), irr::core::triangle3d< T >::getNormal(), irr::core::triangle3d< T >::getPlane(), irr::core::triangle3d< T >::isPointInside(), irr::core::triangle3d< T >::isPointInsideFast(), irr::core::triangle3d< T >::isTotalInsideBox(), irr::core::triangle3d< T >::isTotalOutsideBox(), irr::core::triangle3d< T >::operator==(), and irr::core::triangle3d< T >::set().