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

Definition at line 193 of file Snow.h.
Public Member Functions |
|
| virtual | ~CSnowfall () |
| void | ResetParticle (GLint aIndex) |
| void | UpdateEngine (GLfloat aElapsedTime) |
| void | RenderEngine (TCamera &aCamera) |
Static Public Member Functions |
|
| static CSnowfall * | NewL (GLint aParticlesCount, TVector aPosition, GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel, CTextureManager *aTextureManager) |
Public Attributes |
|
| GLfloat | iWidth |
| GLfloat | iDepth |
| GLfloat | iGroundLevel |
Protected Member Functions |
|
| CSnowfall () | |
| void | ConstructL (GLint aParticlesCount, TVector aPosition, GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel, CTextureManager *aTextureManager) |
Protected Attributes |
|
| TInt64 | iSeed |
| TTexture | iTexture |
|
|
Destructor. Does nothing in this implementation. Definition at line 515 of file Snow.cpp.
|
|
|
Standard constructor that must never Leave. Does nothing in this implementation. Definition at line 453 of file Snow.cpp.
|
|
||||||||||||||||||||||||||||
|
Factory method for creating a new CSnowfall object.
Definition at line 469 of file Snow.cpp. References ConstructL(). Referenced by CSnow::AppInitL(). 00472 { 00473 /* Symbian 2-phase constructor. Calls both the default 00474 C++ constructor and Symbian ConstructL methods */ 00475 CSnowfall* self = new (ELeave) CSnowfall; 00476 CleanupStack::PushL( self ); 00477 self->ConstructL( aParticlesCount, aPosition, aWidth, aDepth, aGroundLevel, aTextureManager); 00478 CleanupStack::Pop(); 00479 00480 return self; 00481 }
|
|
||||||||||||||||||||||||||||
|
Second phase contructor. Constructs the snow effect using the given parameters.
Definition at line 493 of file Snow.cpp. References iDepth, iGroundLevel, iSeed, iTexture, and iWidth. Referenced by NewL(). 00496 { 00497 CParticleEngine::ConstructL(aParticlesCount, aPosition); 00498 00499 iWidth = aWidth; 00500 iDepth = aDepth; 00501 iGroundLevel = aGroundLevel; 00502 00503 TTime now; 00504 now.HomeTime(); 00505 iSeed = now.Int64(); 00506 00507 ResetEngine(); 00508 00509 _LIT(KSnowName, "snow.jpg"); 00510 aTextureManager->RequestToLoad(KSnowName, &iTexture ); 00511 }
|
|
|
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 524 of file Snow.cpp. References iDepth, iSeed, and iWidth. Referenced by UpdateEngine(). 00525 { 00526 TParticle& Particle = iParticles[aIndex]; 00527 00528 Particle.iPosition = TVector( 00529 randrange( -iWidth / 0.5f, iWidth / 0.5f, iSeed ), 00530 0, 00531 randrange( -iDepth / 0.5f, iDepth / 0.5f, iSeed ) ) + iPosition; 00532 00533 Particle.iVelocity = TVector( 00534 randrange( -0.2f, 0.2f, iSeed ), 00535 randrange( -20.f, -10.f, iSeed ), 00536 randrange( -0.2f, 0.2f, iSeed ) ); 00537 }
|
|
|
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 544 of file Snow.cpp. References iGroundLevel, and ResetParticle(). Referenced by CSnow::AppCycle(). 00545 { 00546 for ( GLint i = 0; i < iParticlesCount; i++ ) 00547 { 00548 iParticles[i].iPosition += (iParticles[i].iVelocity * aDeltaTimeSecs); 00549 if ( iParticles[i].iPosition.iY < iGroundLevel ) 00550 { 00551 ResetParticle(i); 00552 } 00553 } 00554 }
|
|
|
Implementation of CParticleEngine::RenderEngine(). Renders each particle to the screen as texture mapped polygon that uses the iTexture as texture. Definition at line 561 of file Snow.cpp. References iTexture. Referenced by CSnow::AppCycle(). 00562 { 00563 glEnable(GL_BLEND); 00564 glBlendFunc(GL_ONE, GL_ONE); 00565 00566 TVector CameraPos = aCamera.GetPosition(); 00567 00568 glBindTexture( GL_TEXTURE_2D, iTexture.iID ); 00569 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); 00570 glVertexPointer( 3, GL_BYTE, 0, snowVertices ); 00571 glTexCoordPointer( 2, GL_BYTE, 0, snowTextureCoords ); 00572 00573 for ( GLint i = 0; i < iParticlesCount; i++ ) 00574 { 00575 glLoadIdentity(); 00576 glTranslatef(iParticles[i].iPosition.iX-CameraPos.iX, 00577 iParticles[i].iPosition.iY-CameraPos.iY, 00578 iParticles[i].iPosition.iZ-CameraPos.iZ); 00579 00580 glDrawElements( GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, snowTriangles ); 00581 } 00582 00583 glDisable(GL_BLEND); 00584 }
|
|
|
Width of the particle source area. This defines the width of the area where the snow falls. Definition at line 261 of file Snow.h. Referenced by ConstructL(), and ResetParticle(). |
|
|
Depth of the particle source area. This defines the depth of the area where the snow falls. Definition at line 263 of file Snow.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 265 of file Snow.h. Referenced by ConstructL(), and UpdateEngine(). |
|
|
Seed for the random generator (the time when ConstructL was called). Definition at line 271 of file Snow.h. Referenced by ConstructL(), and ResetParticle(). |
|
|
Snowflake texture. Definition at line 273 of file Snow.h. Referenced by ConstructL(), and RenderEngine(). |
|
© Nokia 2009 |