|
Nokia N97 SDK Example Applications Guide |
#include <Rain.h>
Inheritance diagram for CRainfall:

Definition at line 196 of file Rain.h.
Public Member Functions |
|
| virtual | ~CRainfall () |
| GLfloat | Random () |
| void | ResetParticle (GLint aIndex) |
| void | UpdateEngine (GLfloat aElapsedTime) |
| void | RenderEngine (TCamera &aCamera) |
Static Public Member Functions |
|
| static CRainfall * | NewL (GLint aParticlesCount, TVector aPosition, GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel) |
Public Attributes |
|
| GLfloat | iWidth |
| GLfloat | iDepth |
| GLfloat | iGroundLevel |
Protected Member Functions |
|
| CRainfall () | |
| void | ConstructL (GLint aParticlesCount, TVector aPosition, GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel) |
Protected Attributes |
|
| TInt64 | iSeed |
|
|
Destructor. Does nothing in this implementation. Definition at line 460 of file Rain.cpp.
|
|
|
Standard constructor that must never Leave. Does nothing in this implementation. Definition at line 406 of file Rain.cpp.
|
|
||||||||||||||||||||||||
|
Factory method for creating a new CRain object.
Definition at line 420 of file Rain.cpp. References ConstructL(). Referenced by CRain::AppInitL(). 00422 { 00423 /* Symbian 2-phase constructor. Calls both the default 00424 C++ constructor and Symbian ConstructL methods */ 00425 CRainfall* self = new (ELeave) CRainfall; 00426 CleanupStack::PushL( self ); 00427 self->ConstructL( aParticlesCount, aPosition, aWidth, aDepth, aGroundLevel); 00428 CleanupStack::Pop(); 00429 00430 return self; 00431 }
|
|
||||||||||||||||||||||||
|
Second phase contructor. Constructs the rain effect using the given parameters.
Definition at line 443 of file Rain.cpp. References iDepth, iGroundLevel, iSeed, and iWidth. Referenced by NewL(). 00445 { 00446 CParticleEngine::ConstructL(aParticlesCount, aPosition); 00447 00448 iWidth = aWidth; 00449 iDepth = aDepth; 00450 iGroundLevel = aGroundLevel; 00451 00452 TTime now; 00453 now.HomeTime(); 00454 iSeed = now.Int64(); 00455 00456 ResetEngine(); 00457 }
|
|
|
Returns a random float number.
Definition at line 531 of file Rain.cpp. References iSeed. Referenced by ResetParticle(). 00532 { 00533 return ((GLfloat)(Math::FRand(iSeed))); 00534 }
|
|
|
Implementation of CParticleEngine::ResetParticle() method Resets the given particle to the rain "start plane" and gives it random location inside the rain area (defined when creating this effect) and random downwards speed.
Definition at line 469 of file Rain.cpp. References iDepth, iSeed, iWidth, and Random(). Referenced by UpdateEngine(). 00470 { 00471 00472 TParticle & Particle = iParticles[aIndex]; 00473 00474 Particle.iPosition = TVector( iWidth * (Random() - 0.5f), 0, iDepth * (Random() - 0.5f)) + iPosition; 00475 Particle.iVelocity = TVector( 0, randrange( -40.f, -20.f, iSeed ), 0); 00476 }
|
|
|
Implementation of CParticleEngine::UpdateEngine() method. Moves all the particles according to their current velocity vector and resets all particles that have fallen beneath the ground level back to the beginning plain.
Definition at line 483 of file Rain.cpp. References iGroundLevel, and ResetParticle(). Referenced by CRain::AppCycle(). 00484 { 00485 for ( GLint i = 0; i < iParticlesCount; i++ ) 00486 { 00487 iParticles[i].iPosition += (iParticles[i].iVelocity * aDeltaTimeSecs); 00488 if ( iParticles[i].iPosition.iY < iGroundLevel ) 00489 { 00490 ResetParticle(i); 00491 } 00492 } 00493 }
|
|
|
Implementation of CParticleEngine::RenderEngine(). Renders each particle to the screen as simple lines. Definition at line 501 of file Rain.cpp. Referenced by CRain::AppCycle(). 00502 { 00503 glDisable( GL_TEXTURE_2D ); 00504 glEnable(GL_BLEND); 00505 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00506 glColor4f( 1.0f, 1.0f, 1.0f, 0.5f ); 00507 00508 TVector CameraPos = aCamera.GetPosition(); 00509 00510 glVertexPointer( 3, GL_BYTE, 0, rainVertices ); 00511 for ( GLint i = 0; i < iParticlesCount; i++ ) 00512 { 00513 glLoadIdentity(); 00514 glTranslatef( iParticles[i].iPosition.iX - CameraPos.iX, 00515 iParticles[i].iPosition.iY - CameraPos.iY, 00516 iParticles[i].iPosition.iZ - CameraPos.iZ ); 00517 00518 glDrawArrays( GL_LINES, 0, 2 ); 00519 } 00520 00521 glEnable( GL_TEXTURE_2D ); 00522 glDisable(GL_BLEND); 00523 }
|
|
|
Width of the particle source area. This defines the width of the area where the rain falls. Definition at line 268 of file Rain.h. Referenced by ConstructL(), and ResetParticle(). |
|
|
Depth of the particle source area. This defines the depth of the area where the rain falls. Definition at line 270 of file Rain.h. Referenced by ConstructL(), and ResetParticle(). |
|
|
Ground level that defines the plane after which the particles are reset back to the source plain. Definition at line 272 of file Rain.h. Referenced by ConstructL(), and UpdateEngine(). |
|
|
Seed for the random generator (the time when ConstructL was called). Definition at line 277 of file Rain.h. Referenced by ConstructL(), Random(), and ResetParticle(). |
|
© Nokia 2009 |