NL3D::CSegRemanence::CRibbon Class Reference


Public Member Functions

 CRibbon ()
void duplicateFirstPos ()
void fillVB (uint8 *dest, uint stride, uint nbSegs, float sliceTime)
void samplePos (const NLMISC::CVector &pos, float date, float sliceDuration)
void setNumSlices (uint numSlices)

Private Types

typedef std::deque< CSampledPosTSampledPosVect

Private Attributes

float _LastSamplingDate
TSampledPosVect _Ribbon

Member Typedef Documentation

typedef std::deque<CSampledPos> NL3D::CSegRemanence::CRibbon::TSampledPosVect [private]
 

Definition at line 153 of file seg_remanence.h.


Constructor & Destructor Documentation

NL3D::CSegRemanence::CRibbon::CRibbon  ) 
 

Definition at line 210 of file seg_remanence.cpp.

00210                               : _LastSamplingDate(0)
00211 {
00212 }


Member Function Documentation

void NL3D::CSegRemanence::CRibbon::duplicateFirstPos  ) 
 

Definition at line 274 of file seg_remanence.cpp.

References _Ribbon, and uint.

00275 {
00276         uint ribSize = _Ribbon.size();
00277         for(uint k = 1; k < ribSize; ++k)
00278         {
00279                 _Ribbon[k] = _Ribbon[0];
00280         }
00281 }

void NL3D::CSegRemanence::CRibbon::fillVB uint8 dest,
uint  stride,
uint  nbSegs,
float  sliceTime
 

compute a location

Definition at line 215 of file seg_remanence.cpp.

References _Ribbon, NL3D::BuildHermiteVector(), stride, uint, and uint8.

00216 {               
00217         TSampledPosVect::iterator currIt      = _Ribbon.begin();                        
00218 
00219         NLMISC::CVector t0 = (currIt + 1)->Pos - currIt->Pos;
00220         NLMISC::CVector t1 = 0.5f * ((currIt + 2)->Pos - currIt->Pos);
00221 
00222         uint leftToDo = nbSegs + 1;
00223 
00224         float lambda = 0.f;
00225         float lambdaStep = 1.f;
00226 
00227 /*      nlinfo("===============================");
00228         for(uint k = 0; k < _Ribbon.size(); ++k)
00229         {
00230                 nlinfo("pos = (%.2f, %.2f, %.2f)", _Ribbon[k].Pos.x, _Ribbon[k].Pos.y, _Ribbon[k].Pos.z);
00231         }*/
00232 
00233         for (;;)
00234         {               
00235                 float dt = currIt->SamplingDate - (currIt + 1)->SamplingDate;
00236 
00237                 if (dt < 10E-6f) // we reached the start of ribbon
00238                 {
00239 
00240                         do
00241                         {
00242                                 (NLMISC::CVector &) *dest = currIt->Pos;
00243                                 dest  += stride;
00244                         }
00245                         while (--leftToDo);                     
00246                         return;
00247                 }
00248 
00249                 float newLambdaStep = sliceTime / dt;
00250                 // readapt lambda
00251                 lambda *= newLambdaStep / lambdaStep;
00252                 lambdaStep = newLambdaStep;
00253                 for(;;)
00254                 {
00255                         if (lambda >= 1.f) break;
00257                         BuildHermiteVector(currIt->Pos, (currIt + 1)->Pos, t0, t1, (NLMISC::CVector &) *dest, lambda);
00258                         dest  += stride;
00259                         -- leftToDo;
00260                         if (!leftToDo) return;                                                                                          
00261                         lambda += lambdaStep;                   
00262                 }
00263                 
00264                 lambda -= 1.f;
00265 
00266                 // Start new segment and compute new tangents
00267                 t0 = t1;
00268                 ++currIt;               
00269                 t1 = 0.5f * ((currIt + 2)->Pos - currIt->Pos);
00270         }        
00271 }

void NL3D::CSegRemanence::CRibbon::samplePos const NLMISC::CVector pos,
float  date,
float  sliceDuration
 

Definition at line 308 of file seg_remanence.cpp.

References _LastSamplingDate, _Ribbon, and nlassert.

00309 {
00310         nlassert(_Ribbon.size() != 0);
00311         if (date - _LastSamplingDate > sliceDuration)
00312         {
00313                 _Ribbon.pop_back();
00314                 CSampledPos sp(pos, date);
00315                 _Ribbon.push_front(sp);
00316                 _LastSamplingDate = date;
00317         }
00318         else
00319         {
00320                 _Ribbon.front().Pos = pos;
00321                 _Ribbon.front().SamplingDate = date;
00322         }
00323 }

void NL3D::CSegRemanence::CRibbon::setNumSlices uint  numSlices  ) 
 

Definition at line 302 of file seg_remanence.cpp.

References _Ribbon, and uint.

00303 {       
00304         _Ribbon.resize(numSegs + 3);
00305 }


Field Documentation

float NL3D::CSegRemanence::CRibbon::_LastSamplingDate [private]
 

Definition at line 155 of file seg_remanence.h.

Referenced by samplePos().

TSampledPosVect NL3D::CSegRemanence::CRibbon::_Ribbon [private]
 

Definition at line 154 of file seg_remanence.h.

Referenced by duplicateFirstPos(), fillVB(), samplePos(), and setNumSlices().


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