NL3D::CPatchQuadBlock Class Reference

#include <patch.h>


Detailed Description

A group of tiles faces in a patch. For speed/mem, max size of a CPatchQuadBlock is fixed.

Author:
Lionel Berenguier

Nevrax France

Date:
2000

Definition at line 251 of file patch.h.

Public Member Functions

void buildTileTriangles (uint8 quadId, CTrianglePatch triangles[2]) const

Data Fields

CPatchBlockIdent PatchBlockId
 from what subPart of the patch those data comes from.

CVector Vertices [(4+1)*(4+1)]
 evaluated Vertices of this patch.


Member Function Documentation

void NL3D::CPatchQuadBlock::buildTileTriangles uint8  quadId,
CTrianglePatch  triangles[2]
const
 

build the 2 triangles from a quad of the CPatchQuadBlock. quadId is the number of the quad, relatively to the PatchQuadBlock.

Definition at line 410 of file patch.cpp.

References NL_PATCH_BLOCK_MAX_QUAD, NL_PATCH_BLOCK_MAX_VERTEX, nlassert, NL3D::CPatchBlockIdent::OrderS, NL3D::CPatchBlockIdent::OrderT, PatchBlockId, NL3D::CPatchBlockIdent::PatchId, NL3D::CTrianglePatch::PatchId, s, NL3D::CPatchBlockIdent::S0, NL3D::CPatchBlockIdent::S1, t, NL3D::CPatchBlockIdent::T0, NL3D::CPatchBlockIdent::T1, NLMISC::CUV::U, uint, uint8, NLMISC::CTriangleUV::Uv0, NLMISC::CTriangleUV::Uv1, NLMISC::CTriangleUV::Uv2, NLMISC::CUV::V, NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, and NLMISC::CTriangle::V2.

Referenced by NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs().

00411 {
00412         // copute coordinate of the tile we want.
00413         uint    sd0= quadId&(NL_PATCH_BLOCK_MAX_QUAD-1);
00414         uint    td0= quadId/(NL_PATCH_BLOCK_MAX_QUAD);
00415         uint    sd1= sd0+1;
00416         uint    td1= td0+1;
00417         uint    s= PatchBlockId.S0+sd0;
00418         uint    t= PatchBlockId.T0+td0;
00419         nlassert(s<PatchBlockId.S1);
00420         nlassert(t<PatchBlockId.T1);
00421 
00422         // Compute UV coord.
00423         float   fs0= (float)s / (float)(PatchBlockId.OrderS);
00424         float   ft0= (float)t / (float)(PatchBlockId.OrderT);
00425         float   fs1= (float)(s+1) / (float)(PatchBlockId.OrderS);
00426         float   ft1= (float)(t+1) / (float)(PatchBlockId.OrderT);
00427         CUV                     uv0, uv1, uv2, uv3;
00428         uv0.U= fs0; uv0.V= ft0;
00429         uv1.U= fs0; uv1.V= ft1;
00430         uv2.U= fs1; uv2.V= ft1;
00431         uv3.U= fs1; uv3.V= ft0;
00432 
00433         // get vertex coord.
00434         const CVector   &p0= Vertices[sd0 + td0*NL_PATCH_BLOCK_MAX_VERTEX];
00435         const CVector   &p1= Vertices[sd0 + td1*NL_PATCH_BLOCK_MAX_VERTEX];
00436         const CVector   &p2= Vertices[sd1 + td1*NL_PATCH_BLOCK_MAX_VERTEX];
00437         const CVector   &p3= Vertices[sd1 + td0*NL_PATCH_BLOCK_MAX_VERTEX];
00438 
00439         // build triangles.
00440         // first tri.
00441         {
00442                 CTrianglePatch &tri= triangles[0];
00443                 tri.PatchId= PatchBlockId.PatchId;
00444                 tri.V0= p0; tri.V1= p1; tri.V2= p2;
00445                 tri.Uv0= uv0; tri.Uv1= uv1; tri.Uv2= uv2;
00446         }
00447 
00448         // second tri.
00449         {
00450                 CTrianglePatch &tri= triangles[1];
00451                 tri.PatchId= PatchBlockId.PatchId;
00452                 tri.V0= p2; tri.V1= p3; tri.V2= p0;
00453                 tri.Uv0= uv2; tri.Uv1= uv3; tri.Uv2= uv0;
00454         }
00455 
00456 }


Field Documentation

CPatchBlockIdent NL3D::CPatchQuadBlock::PatchBlockId
 

from what subPart of the patch those data comes from.

Definition at line 255 of file patch.h.

Referenced by NL3D::CLandscapeCollisionGrid::build(), buildTileTriangles(), NL3D::CVisualCollisionEntity::displayDebugGrid(), and NL3D::CLandscape::fillPatchQuadBlock().

CVector NL3D::CPatchQuadBlock::Vertices[ ( 4 +1) * ( 4 +1) ]
 

evaluated Vertices of this patch.

Definition at line 258 of file patch.h.

Referenced by NL3D::CLandscapeCollisionGrid::build(), and NL3D::CVisualCollisionEntity::displayDebugGrid().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 07:01:07 2004 for NeL by doxygen 1.3.6