Bullet Collision Detection & Physics Library: GIM_TRIANGLE Class Reference

Bullet Collision Detection & Physics Library

Public Member Functions | Public Attributes | List of all members
GIM_TRIANGLE Class Reference

Class for colliding triangles. More...

`#include <gim_tri_collision.h>`

Collaboration diagram for GIM_TRIANGLE:
[legend]

## Public Member Functions
| GIM_TRIANGLE ()
GIM_AABB | get_box () const
void | get_normal (btVector3 &normal) const
void | get_plane (btVector4 &plane) const
void | apply_transform (const btTransform &trans)
void | get_edge_plane (GUINT edge_index, const btVector3 &triangle_normal, btVector4 &plane) const
void | get_triangle_transform (btTransform &triangle_transform) const
| Gets the relative transformation of this triangle. More...
bool | collide_triangle_hard_test (const GIM_TRIANGLE &other, GIM_TRIANGLE_CONTACT_DATA &contact_data) const
| Test triangles by finding separating axis. More...
bool | collide_triangle (const GIM_TRIANGLE &other, GIM_TRIANGLE_CONTACT_DATA &contact_data) const
| Test boxes before doing hard test. More...
bool | get_uv_parameters (const btVector3 &point, const btVector3 &tri_plane, GREAL &u, GREAL &v) const
bool | is_point_inside (const btVector3 &point, const btVector3 &tri_normal) const
| is point in triangle beam? More...
bool | ray_collision (const btVector3 &vPoint, const btVector3 &vDir, btVector3 &pout, btVector3 &triangle_normal, GREAL &tparam, GREAL tmax=G_REAL_INFINITY)
| Bidireccional ray collision. More...
bool | ray_collision_front_side (const btVector3 &vPoint, const btVector3 &vDir, btVector3 &pout, btVector3 &triangle_normal, GREAL &tparam, GREAL tmax=G_REAL_INFINITY)
| one direccion ray collision More...

## Public Attributes
btScalar | m_margin
btVector3 | m_vertices [3]

## Detailed Description

Class for colliding triangles.

Definition at line 120 of file gim_tri_collision.h.

## Constructor & Destructor Documentation

## ◆ GIM_TRIANGLE()

GIM_TRIANGLE::GIM_TRIANGLE | ( |  | ) |
| inline

Definition at line 126 of file gim_tri_collision.h.

## Member Function Documentation

## ◆ apply_transform()

void GIM_TRIANGLE::apply_transform | ( | const btTransform & | trans | ) |
| inline

Definition at line 146 of file gim_tri_collision.h.

## ◆ collide_triangle()

bool GIM_TRIANGLE::collide_triangle | ( | const GIM_TRIANGLE & | other,
|  | GIM_TRIANGLE_CONTACT_DATA & | contact_data
| ) |  | const
| inline

Test boxes before doing hard test.

Parameters

  other | Triangle for collide
  contact_data | Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle \

Definition at line 201 of file gim_tri_collision.h.

## ◆ collide_triangle_hard_test()

bool GIM_TRIANGLE::collide_triangle_hard_test | ( | const GIM_TRIANGLE & | other,
|  | GIM_TRIANGLE_CONTACT_DATA & | contact_data
| ) |  | const

Test triangles by finding separating axis.

Parameters

  other | Triangle for collide
  contact_data | Structure for holding contact points, normal and penetration depth; The normal is pointing toward this triangle from the other triangle

Definition at line 610 of file gim_tri_collision.cpp.

## ◆ get_box()

GIM_AABB GIM_TRIANGLE::get_box | ( |  | ) | const
| inline

Definition at line 130 of file gim_tri_collision.h.

## ◆ get_edge_plane()

void GIM_TRIANGLE::get_edge_plane | ( | GUINT | edge_index,
|  | const btVector3 & | triangle_normal,
|  | btVector4 & | plane
| ) |  | const
| inline

Definition at line 153 of file gim_tri_collision.h.

## ◆ get_normal()

void GIM_TRIANGLE::get_normal | ( | btVector3 & | normal | ) | const
| inline

Definition at line 135 of file gim_tri_collision.h.

## ◆ get_plane()

void GIM_TRIANGLE::get_plane | ( | btVector4 & | plane | ) | const
| inline

Definition at line 140 of file gim_tri_collision.h.

## ◆ get_triangle_transform()

void GIM_TRIANGLE::get_triangle_transform | ( | btTransform & | triangle_transform | ) | const
| inline

Gets the relative transformation of this triangle.

The transformation is oriented to the triangle normal , and aligned to the 1st edge of this triangle. The position corresponds to vertice 0:

- triangle normal corresponds to Z axis.
- 1st normalized edge corresponds to X axis,

Definition at line 167 of file gim_tri_collision.h.

## ◆ get_uv_parameters()

bool GIM_TRIANGLE::get_uv_parameters | ( | const btVector3 & | point,
|  | const btVector3 & | tri_plane,
|  | GREAL & | u,
|  | GREAL & | v
| ) |  | const
| inline

Solve the System for u,v parameters:

u*axe1[i1] + v*axe2[i1] = vecproj[i1] u*axe1[i2] + v*axe2[i2] = vecproj[i2]

sustitute: v = (vecproj[i2] - u*axe1[i2])/axe2[i2]

then the first equation in terms of 'u':

--> u*axe1[i1] + ((vecproj[i2] - u*axe1[i2])/axe2[i2])*axe2[i1] = vecproj[i1]

--> u*axe1[i1] + vecproj[i2]*axe2[i1]/axe2[i2] - u*axe1[i2]*axe2[i1]/axe2[i2] = vecproj[i1]

--> u*(axe1[i1] - axe1[i2]*axe2[i1]/axe2[i2]) = vecproj[i1] - vecproj[i2]*axe2[i1]/axe2[i2]

--> u*((axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])/axe2[i2]) = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1])/axe2[i2]

--> u*(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) = vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]

--> u = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]) /(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])

if 0.0<= u+v <=1.0 then they are inside of triangle

        \return false if the point is outside of triangle.This function  doesn't take the margin

Definition at line 242 of file gim_tri_collision.h.

## ◆ is_point_inside()

bool GIM_TRIANGLE::is_point_inside | ( | const btVector3 & | point,
|  | const btVector3 & | tri_normal
| ) |  | const
| inline

is point in triangle beam?

Test if point is in triangle, with m_margin tolerance

Definition at line 291 of file gim_tri_collision.h.

## ◆ ray_collision()

bool GIM_TRIANGLE::ray_collision | ( | const btVector3 & | vPoint,
|  | const btVector3 & | vDir,
|  | btVector3 & | pout,
|  | btVector3 & | triangle_normal,
|  | GREAL & | tparam,
|  | GREAL | tmax = `G_REAL_INFINITY`
| ) |  |
| inline

Bidireccional ray collision.

Definition at line 310 of file gim_tri_collision.h.

## ◆ ray_collision_front_side()

bool GIM_TRIANGLE::ray_collision_front_side | ( | const btVector3 & | vPoint,
|  | const btVector3 & | vDir,
|  | btVector3 & | pout,
|  | btVector3 & | triangle_normal,
|  | GREAL & | tparam,
|  | GREAL | tmax = `G_REAL_INFINITY`
| ) |  |
| inline

one direccion ray collision

Definition at line 342 of file gim_tri_collision.h.

## Member Data Documentation

## ◆ m_margin

btScalar GIM_TRIANGLE::m_margin

Definition at line 123 of file gim_tri_collision.h.

## ◆ m_vertices

btVector3 GIM_TRIANGLE::m_vertices[3]

Definition at line 124 of file gim_tri_collision.h.

The documentation for this class was generated from the following files:

- gim_tri_collision.h
- gim_tri_collision.cpp