NL3D::CTrianglePatch Struct Reference

#include <patch.h>

Inheritance diagram for NL3D::CTrianglePatch:

NLMISC::CTriangleUV NLMISC::CTriangle

Detailed Description

A triangle from a patch identifier.

Author:
Lionel Berenguier

Nevrax France

Date:
2000

Definition at line 178 of file patch.h.

Public Member Functions

void computeGradient (float c0, float c1, float c2, CVector &grad) const
bool intersect (const CVector &p0, const CVector &p1, CVector &hit, const class NLMISC::CPlane &plane) const

Data Fields

CPatchIdent PatchId
 from which patch this triangle comes from.

CUV Uv0
CUV Uv1
CUV Uv2
CVector V0
CVector V1
CVector V2


Member Function Documentation

void NLMISC::CTriangle::computeGradient float  c0,
float  c1,
float  c2,
CVector grad
const [inherited]
 

3D Gradient computation. Given 3 values at the 3 corners 'ci' (gouraud, uv....), this method compute the gradients Grad. The formula to compute the interpolated value according to a 3d position 'v' in space is then simply:
c(v)= c0 + grad*(v-V0)

Definition at line 67 of file triangle.cpp.

References NLMISC::CVector::normalize(), NLMISC::CVector::set(), NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, NLMISC::CTriangle::V2, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::BuildTangentSpace(), NL3D::CLodCharacterShapeBuild::compile(), NL3D::CTessFace::computeTesselatedPos(), NL3D::CVisualCollisionEntity::computeUvForPos(), and RenderTriangle().

00068 {
00069         // Compute basis for 2D triangle.
00070         CVector         locI, locJ, locK;
00071         locI= V1-V0;
00072         locJ= V2-V0;
00073         locK= locI^locJ;
00074         locK.normalize();
00075         locI.normalize();
00076         locJ= locK^locI;
00077 
00078         // compute triangle in 2D.
00079         CTriangle       tri2D;
00080         tri2D.V0.set(0,0,0);
00081         tri2D.V1.x= (V1-V0)*locI;
00082         tri2D.V1.y= (V1-V0)*locJ;
00083         tri2D.V1.z= 0;
00084         tri2D.V2.x= (V2-V0)*locI;
00085         tri2D.V2.y= (V2-V0)*locJ;
00086         tri2D.V2.z= 0;
00087 
00088         // Compute 2 2D Gradients.
00089         float   dx01= tri2D.V0.x - tri2D.V2.x;
00090         float   dx02= tri2D.V1.x - tri2D.V2.x;
00091         float   dy01= tri2D.V0.y - tri2D.V2.y;
00092         float   dy02= tri2D.V1.y - tri2D.V2.y;
00093         float   dc01= c0 - c2;
00094         float   dc02= c1 - c2;
00095         float   gd= dx02*dy01 - dx01*dy02;
00096 
00097         float   OOgd;
00098         if(gd!=0)
00099                 OOgd= 1.0f/gd;
00100         else
00101                 OOgd= 1;        // for now, do not manage correctly this case.
00102         float   gx, gy;
00103         gx= (dc02*dy01 - dc01*dy02) * OOgd;
00104         gy= (dc01*dx02 - dc02*dx01) * OOgd;
00105 
00106         // transform in 3D.
00107         grad= locI*gx + locJ*gy;
00108 }

bool NLMISC::CTriangle::intersect const CVector p0,
const CVector p1,
CVector hit,
const class NLMISC::CPlane plane
const [inherited]
 

Intersection detection with a segment. You must pass the normalized plane of the triangle as parameter.

Parameters:
p0 is the first point of the segment.
p1 is the second point of the segment.
hit will receive the coordinate of the intersection if the method returns true.
plane is the plane of the triangle. Build it like this:
CPlane plane; plane.make (triangle.V0, triangle.V1, triangle.V2);
Returns:
true if the segement [p0,p1] intersects the triangle else false.

Referenced by NL3D::CInstanceLighter::computeSunContribution(), NL3D::CZoneLighter::CPointLightRT::testRaytrace(), and NL3D::CInstanceLighter::CPointLightRT::testRaytrace().


Field Documentation

CPatchIdent NL3D::CTrianglePatch::PatchId
 

from which patch this triangle comes from.

Definition at line 181 of file patch.h.

Referenced by NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::CVisualCollisionEntity::getStaticLightSetup(), NL3D::CVisualCollisionEntity::getSurfaceInfo(), and NL3D::CVisualCollisionEntity::snapToLandscapeCurrentTesselation().

CUV NLMISC::CTriangleUV::Uv0 [inherited]
 

Definition at line 170 of file geom_ext.h.

Referenced by NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::CVisualCollisionEntity::computeUvForPos(), and NL3D::CDriverUser::drawTriangle().

CUV NLMISC::CTriangleUV::Uv1 [inherited]
 

Definition at line 170 of file geom_ext.h.

Referenced by NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::CVisualCollisionEntity::computeUvForPos(), and NL3D::CDriverUser::drawTriangle().

CUV NLMISC::CTriangleUV::Uv2 [inherited]
 

Definition at line 170 of file geom_ext.h.

Referenced by NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::CVisualCollisionEntity::computeUvForPos(), and NL3D::CDriverUser::drawTriangle().

CVector NLMISC::CTriangle::V0 [inherited]
 

Definition at line 51 of file triangle.h.

Referenced by NL3D::CMiniCol::addFaces(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CLandscape::appendToShadowPolyReceiver(), NL3D::CLandscape::buildCollideFaces(), NL3D::BuildTangentSpace(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::BuildTriFromMB(), NL3D::CBSPTree< T >::CBSPNode::CBSPNode(), NL3D::CLodCharacterShapeBuild::compile(), NL3D::CZoneLighter::compilePointLightRT(), NLMISC::CTriangle::computeGradient(), NL3D::CTessFace::computeTesselatedPos(), NL3D::CVisualCollisionEntity::computeUvForPos(), NLMISC::CPolygon2D::CPolygon2D(), NL3D::CDriverUser::drawTriangle(), NL3D::CMiniCol::getFaces(), NL3D::CMiniCol::getGroundNormal(), NL3D::CCubeGrid< TCell >::insert(), NL3D::CBSPTree< T >::CBSPNode::insert(), NL3D::CZoneLighter::light(), NL3D::CInstanceLighter::light(), NL3D::CCubeGrid< TCell >::project(), RenderTriangle(), NL3D::CVisualCollisionEntity::snapToGround(), NL3D::CMiniCol::snapToGround(), NL3D::CVisualCollisionEntity::triangleIntersect(), NL3D::CVisualCollisionEntity::triangleIntersect2DCeil(), and NL3D::CVisualCollisionEntity::triangleIntersect2DGround().

CVector NLMISC::CTriangle::V1 [inherited]
 

Definition at line 51 of file triangle.h.

Referenced by NL3D::CMiniCol::addFaces(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CLandscape::appendToShadowPolyReceiver(), NL3D::CLandscape::buildCollideFaces(), NL3D::BuildTangentSpace(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::BuildTriFromMB(), NL3D::CBSPTree< T >::CBSPNode::CBSPNode(), NL3D::CLodCharacterShapeBuild::compile(), NL3D::CZoneLighter::compilePointLightRT(), NLMISC::CTriangle::computeGradient(), NL3D::CTessFace::computeTesselatedPos(), NLMISC::CPolygon2D::CPolygon2D(), NL3D::CDriverUser::drawTriangle(), NL3D::CMiniCol::getFaces(), NL3D::CMiniCol::getGroundNormal(), NL3D::CCubeGrid< TCell >::insert(), NL3D::CBSPTree< T >::CBSPNode::insert(), NL3D::CZoneLighter::light(), NL3D::CInstanceLighter::light(), NL3D::CCubeGrid< TCell >::project(), NL3D::CVisualCollisionEntity::snapToGround(), NL3D::CMiniCol::snapToGround(), NL3D::CVisualCollisionEntity::triangleIntersect(), NL3D::CVisualCollisionEntity::triangleIntersect2DCeil(), and NL3D::CVisualCollisionEntity::triangleIntersect2DGround().

CVector NLMISC::CTriangle::V2 [inherited]
 

Definition at line 51 of file triangle.h.

Referenced by NL3D::CMiniCol::addFaces(), NL3D::CPatch::addTileTrianglesInBBox(), NL3D::CShadowPolyReceiver::addTriangle(), NL3D::CLandscape::appendToShadowPolyReceiver(), NL3D::CLandscape::buildCollideFaces(), NL3D::BuildTangentSpace(), NL3D::CPatchQuadBlock::buildTileTriangles(), NL3D::BuildTriFromMB(), NL3D::CBSPTree< T >::CBSPNode::CBSPNode(), NL3D::CLodCharacterShapeBuild::compile(), NL3D::CZoneLighter::compilePointLightRT(), NLMISC::CTriangle::computeGradient(), NL3D::CTessFace::computeTesselatedPos(), NLMISC::CPolygon2D::CPolygon2D(), NL3D::CDriverUser::drawTriangle(), NL3D::CMiniCol::getFaces(), NL3D::CMiniCol::getGroundNormal(), NL3D::CCubeGrid< TCell >::insert(), NL3D::CBSPTree< T >::CBSPNode::insert(), NL3D::CZoneLighter::light(), NL3D::CInstanceLighter::light(), NL3D::CCubeGrid< TCell >::project(), NL3D::CVisualCollisionEntity::snapToGround(), NL3D::CMiniCol::snapToGround(), NL3D::CVisualCollisionEntity::triangleIntersect(), NL3D::CVisualCollisionEntity::triangleIntersect2DCeil(), and NL3D::CVisualCollisionEntity::triangleIntersect2DGround().


The documentation for this struct was generated from the following file:
Generated on Tue Mar 16 08:18:56 2004 for NeL by doxygen 1.3.6