NL3D::CPSShockWaveHelper Class Reference


Detailed Description

Well, we could have put a method template in CPSShockWave, but some compilers want the definition of the methods in the header, and some compilers don't want friend with function template, so we use a static method template of a friend class instead, which gives us the same result :)

Definition at line 65 of file ps_shockwave.cpp.

Static Public Member Functions

template<class T> void drawShockWave (T posIt, CPSShockWave &s, uint size, uint32 srcStep)


Member Function Documentation

template<class T>
void NL3D::CPSShockWaveHelper::drawShockWave posIt,
CPSShockWave s,
uint  size,
uint32  srcStep
[inline, static]
 

Definition at line 69 of file ps_shockwave.cpp.

References NL3D::IDriver::activeVertexBuffer(), CHECK_VERTEX_BUFFER, NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), min, nlassert, PARTICLES_CHECK_MEM, NL3D::IDriver::render(), s, NL3D::CPrimitiveBlock::setNumQuad(), NL3D::ShockWaveBufSize, sint32, size, uint, uint32, uint8, NL3D::CPlaneBasis::X, and NL3D::CPlaneBasis::Y.

00070         {
00071                 PARTICLES_CHECK_MEM;
00072                 nlassert(s._Owner);
00073 
00074                 // get / build the vertex buffer and the primitive block
00075                 CVertexBuffer *vb;
00076                 CPrimitiveBlock *pb;
00077                 s.getVBnPB(vb, pb);
00078 
00079                 const uint32 vSize = vb->getVertexSize();
00080                 IDriver *driver = s.getDriver();
00081                 s._Owner->incrementNbDrawnParticles(size); // for benchmark purpose     
00082                 s.setupDriverModelMatrix();
00083                 const uint numShockWaveToDealWith = std::min(ShockWaveBufSize, s.getNumShockWavesInVB());
00084                 driver->activeVertexBuffer(*vb);        
00085 
00086                 static CPlaneBasis planeBasis[ShockWaveBufSize];
00087                 float       sizes[ShockWaveBufSize];
00088                 float       angles[ShockWaveBufSize];
00089                 
00090                 uint leftToDo  = size, toProcess;
00091                 T endIt;
00092                 uint8 *currVertex;
00093                 uint k ;
00094 
00095                 const float angleStep = 256.f / s._NbSeg;
00096                 float currAngle;
00097 
00098                 CPlaneBasis *ptCurrBasis;
00099                 uint32  ptCurrBasisIncrement = s._PlaneBasisScheme ? 1 : 0;
00100 
00101                 float *ptCurrSize;
00102                 uint32 ptCurrSizeIncrement = s._SizeScheme ? 1 : 0;
00103 
00104                 float *ptCurrAngle;
00105                 uint32 ptCurrAngleIncrement = s._Angle2DScheme ? 1 : 0;
00106 
00107                 CVector radVect, innerVect;
00108                 float radiusRatio;
00109 
00110                 do
00111                 {
00112                         currVertex = (uint8 *) vb->getVertexCoordPointer();
00113                         toProcess = leftToDo > numShockWaveToDealWith ? numShockWaveToDealWith : leftToDo;
00114                         endIt = posIt + toProcess;
00115                         if (s._SizeScheme)
00116                         {
00117                                 ptCurrSize  = (float *) (s._SizeScheme->make(s._Owner, size - leftToDo, (void *) sizes, sizeof(float), toProcess, true, srcStep));                      
00118                         }
00119                         else
00120                         {
00121                                 ptCurrSize = &s._ParticleSize;
00122                         }
00123 
00124                         if (s._PlaneBasisScheme)
00125                         {
00126                                 ptCurrBasis  = (CPlaneBasis *) (s._PlaneBasisScheme->make(s._Owner, size - leftToDo, (void *) planeBasis, sizeof(CPlaneBasis), toProcess, true, srcStep));                      
00127                         }
00128                         else
00129                         {
00130                                 ptCurrBasis = &s._PlaneBasis;
00131                         }
00132 
00133                         if (s._Angle2DScheme)
00134                         {
00135                                 ptCurrAngle  = (float *) (s._Angle2DScheme->make(s._Owner, size - leftToDo, (void *) angles, sizeof(float), toProcess, true, srcStep));                 
00136                         }
00137                         else
00138                         {
00139                                 ptCurrAngle = &s._Angle2D;
00140                         }
00141                         
00142 
00143                         s.updateVbColNUVForRender(size - leftToDo, toProcess, srcStep, *vb);
00144                         do
00145                         {                       
00146                                 currAngle = *ptCurrAngle;
00147                                 if (fabsf(*ptCurrSize) > 10E-6)
00148                                 {
00149                                         radiusRatio = (*ptCurrSize - s._RadiusCut) / *ptCurrSize;
00150                                 }
00151                                 else
00152                                 {
00153                                         radiusRatio = 0.f;
00154                                 }
00155 
00156                                 for (k = 0; k <= s._NbSeg; ++k)
00157                                 {
00158                                         radVect = *ptCurrSize * (CPSUtil::getCos((sint32) currAngle) * ptCurrBasis->X + CPSUtil::getSin((sint32) currAngle) * ptCurrBasis->Y);
00159                                         innerVect = radiusRatio * radVect;
00160                                         CHECK_VERTEX_BUFFER(*vb, currVertex);
00161                                         * (CVector *) currVertex = *posIt + radVect;
00162                                         currVertex += vSize;
00163                                         CHECK_VERTEX_BUFFER(*vb, currVertex);
00164                                         * (CVector *) currVertex = *posIt + innerVect;
00165                                         currVertex += vSize;
00166                                         currAngle += angleStep;                         
00167                                 }
00168                                 
00169                                 ++posIt;
00170                                 ptCurrBasis +=  ptCurrBasisIncrement;
00171                                 ptCurrSize  +=  ptCurrSizeIncrement;
00172                                 ptCurrAngle  +=  ptCurrAngleIncrement;
00173                         }
00174                         while (posIt != endIt);                 
00175 
00176                         pb->setNumQuad(toProcess * s._NbSeg);
00177                         driver->render(*pb, s._Mat);
00178                         leftToDo -= toProcess;          
00179                 }
00180                 while (leftToDo);
00181                 PARTICLES_CHECK_MEM;
00182         }


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