|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <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 |
Definition at line 221 of file Rain.h.
|
|
Destructor. Does nothing in this implementation. Definition at line 539 of file Rain.cpp.
|
|
|
Standard constructor that must never Leave. Does nothing in this implementation. Definition at line 485 of file Rain.cpp.
|
|
||||||||||||||||||||||||
|
Factory method for creating a new CRain object.
Definition at line 499 of file Rain.cpp. References ConstructL(). 00501 { 00502 /* Symbian 2-phase constructor. Calls both the default 00503 C++ constructor and Symbian ConstructL methods */ 00504 CRainfall* self = new (ELeave) CRainfall; 00505 CleanupStack::PushL( self ); 00506 self->ConstructL( aParticlesCount, aPosition, aWidth, aDepth, aGroundLevel); 00507 CleanupStack::Pop(); 00508 00509 return self; 00510 }
|
|
||||||||||||||||||||||||
|
Second phase contructor. Constructs the rain effect using the given parameters.
Definition at line 522 of file Rain.cpp. References iDepth, iGroundLevel, iSeed, and iWidth. 00524 { 00525 CParticleEngine::ConstructL(aParticlesCount, aPosition); 00526 00527 iWidth = aWidth; 00528 iDepth = aDepth; 00529 iGroundLevel = aGroundLevel; 00530 00531 TTime now; 00532 now.HomeTime(); 00533 iSeed = now.Int64(); 00534 00535 ResetEngine(); 00536 }
|
|
|
Returns a random float number.
Definition at line 611 of file Rain.cpp. References iSeed. 00612 { 00613 return ((GLfloat)(Math::FRand(iSeed))); 00614 }
|
|
|
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 548 of file Rain.cpp. References iDepth, iWidth, and Random(). 00549 { 00550 00551 TParticle & Particle = iParticles[aIndex]; 00552 00553 Particle.iPosition = TVector( iWidth * (Random() - 0.5f), 0, iDepth * (Random() - 0.5f)) + iPosition; 00554 Particle.iVelocity = TVector( 0, (GLfloat)(-(Random()*20.0f+20.0f)), 0); 00555 }
|
|
|
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 562 of file Rain.cpp. References iGroundLevel, and ResetParticle(). 00563 { 00564 for ( GLint i = 0; i < iParticlesCount; i++ ) 00565 { 00566 iParticles[i].iPosition += (iParticles[i].iVelocity * aElapsedTime); 00567 if ( iParticles[i].iPosition.iY < iGroundLevel ) 00568 { 00569 ResetParticle(i); 00570 } 00571 } 00572 }
|
|
|
Implementation of CParticleEngine::RenderEngine(). Renders each particle to the screen as simple lines. Definition at line 580 of file Rain.cpp. 00581 { 00582 glDisable( GL_TEXTURE_2D ); 00583 glEnable(GL_BLEND); 00584 00585 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00586 glColor4f( 1.0f, 1.0f, 1.0f, 0.5f ); 00587 00588 TVector CameraPos = aCamera.GetPosition(); 00589 00590 glVertexPointer( 3, GL_BYTE, 0, rainVertices ); 00591 for ( GLint i = 0; i < iParticlesCount; i++ ) 00592 { 00593 glLoadIdentity(); 00594 glTranslatef(iParticles[i].iPosition.iX-CameraPos.iX, 00595 iParticles[i].iPosition.iY-CameraPos.iY, 00596 iParticles[i].iPosition.iZ-CameraPos.iZ); 00597 00598 glDrawArrays( GL_LINES, 0, 2 ); 00599 } 00600 00601 glEnable( GL_TEXTURE_2D ); 00602 glDisable(GL_BLEND); 00603 }
|
|
|
Width of the particle source area. This defines the width of the area where the rain falls. |
|
|
Depth of the particle source area. This defines the depth of the area where the rain falls. |
|
|
Ground level that defines the plane after which the particles are reset back to the source plain. |
|
|
Seed for the random generator (the time when ConstructL was called). |
|
© Nokia 2006 |