NL3D::CLandscapeVegetableBlockCreateContext Class Reference

#include <landscape_vegetable_block.h>


Detailed Description

Information for instanciation of vegetable IG. NB: there is one CLandscapeVegetableBlock per landscape TessBlock.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 127 of file landscape_vegetable_block.h.

Public Member Functions

 CLandscapeVegetableBlockCreateContext ()
void eval (uint ts, uint tt, float x, float y, CVector &pos)
void init (CPatch *patch, uint ts, uint tt)

Private Attributes

bool _Empty
CPatch_Patch
CVector _Pos [9]
uint _Ts
 Coordinate of the lower-left tile. 2x2 tile vegetables are generated.

uint _Tt
 Coordinate of the lower-left tile. 2x2 tile vegetables are generated.


Constructor & Destructor Documentation

NL3D::CLandscapeVegetableBlockCreateContext::CLandscapeVegetableBlockCreateContext  ) 
 

Definition at line 277 of file landscape_vegetable_block.cpp.

00278 {
00279         _Patch= NULL;
00280 }


Member Function Documentation

void NL3D::CLandscapeVegetableBlockCreateContext::eval uint  ts,
uint  tt,
float  x,
float  y,
CVector pos
 

If Empty, create all the necessary information from patch. Then compute requested Pos, from the tile ts,tt, and pos in this tile.

Parameters:
ts,tt coordinate of the tile.
x,y coordinate [0..1] in the tile.

Definition at line 295 of file landscape_vegetable_block.cpp.

References _Empty, NL3D::CPatch::computeVertex(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL3D_TESSBLOCK_TILESIZE, nlassert, s, t, uint, x, and y.

Referenced by NL3D::CPatch::generateTileVegetable().

00296 {
00297         nlassert(NL3D_TESSBLOCK_TILESIZE==4);
00298 
00299         // If never created, do it now
00300         // ==================
00301         if(_Empty)
00302         {
00303                 // Eval Position and normals for the 9 vertices (around the 2x2 tiles)
00304                 for(uint j=0; j<3;j++)
00305                 {
00306                         float   t= (float)(_Tt+j)/_Patch->getOrderT();
00307                         for(uint i=0; i<3;i++)
00308                         {
00309                                 float   s= (float)(_Ts+i)/_Patch->getOrderS();
00310                                 // eval position.
00311                                 // use computeVertex() and not bpatch->eval() because vegetables must follow the 
00312                                 // noise (at least at tile precision...). It is slower but necessary.
00313                                 _Pos[j*3+i]= _Patch->computeVertex(s, t);
00314                         }
00315                 }
00316 
00317                 // Ok, it's done
00318                 _Empty= false;
00319         }
00320 
00321 
00322         // Eval, with simple bilinear
00323         // ==================
00324         nlassert(ts==_Ts || ts==_Ts+1);
00325         nlassert(tt==_Tt || tt==_Tt+1);
00326         uint    ds= ts-_Ts;
00327         uint    dt= tt-_Tt;
00328         // Indices.
00329         uint    v00= dt*3 + ds;
00330         uint    v10= v00 + 1;
00331         uint    v01= v00 + 3;
00332         uint    v11= v00 + 4;
00333         // BiLinearFactor.
00334         float   dxdy= (1-x)*(1-y);
00335         float   dx2dy= x*(1-y);
00336         float   dxdy2= (1-x)*y;
00337         float   dx2dy2= x*y;
00338 
00339         // Compute Pos.
00340         pos = _Pos[v00] * dxdy;
00341         pos+= _Pos[v10] * dx2dy;
00342         pos+= _Pos[v01] * dxdy2;
00343         pos+= _Pos[v11] * dx2dy2;
00344 }

void NL3D::CLandscapeVegetableBlockCreateContext::init CPatch patch,
uint  ts,
uint  tt
 

Definition at line 284 of file landscape_vegetable_block.cpp.

References _Empty, nlassert, and uint.

Referenced by NL3D::CLandscapeVegetableBlock::update().

00285 {
00286         nlassert(patch);
00287         _Empty= true;
00288         _Patch= patch;
00289         _Ts= ts;
00290         _Tt= tt;
00291 }


Field Documentation

bool NL3D::CLandscapeVegetableBlockCreateContext::_Empty [private]
 

Definition at line 144 of file landscape_vegetable_block.h.

Referenced by eval(), and init().

CPatch* NL3D::CLandscapeVegetableBlockCreateContext::_Patch [private]
 

Definition at line 145 of file landscape_vegetable_block.h.

CVector NL3D::CLandscapeVegetableBlockCreateContext::_Pos[ 9 ] [private]
 

Definition at line 149 of file landscape_vegetable_block.h.

uint NL3D::CLandscapeVegetableBlockCreateContext::_Ts [private]
 

Coordinate of the lower-left tile. 2x2 tile vegetables are generated.

Definition at line 147 of file landscape_vegetable_block.h.

uint NL3D::CLandscapeVegetableBlockCreateContext::_Tt [private]
 

Coordinate of the lower-left tile. 2x2 tile vegetables are generated.

Definition at line 147 of file landscape_vegetable_block.h.


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