|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <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 |
Definition at line 221 of file Snow.h.
|
|
Destructor. Does nothing in this implementation. Definition at line 565 of file Snow.cpp.
|
|
|
Standard constructor that must never Leave. Does nothing in this implementation. Definition at line 503 of file Snow.cpp.
|
|
||||||||||||||||||||||||||||
|
Factory method for creating a new CSnowfall object.
Definition at line 519 of file Snow.cpp. References ConstructL(). 00522 { 00523 /* Symbian 2-phase constructor. Calls both the default 00524 C++ constructor and Symbian ConstructL methods */ 00525 CSnowfall* self = new (ELeave) CSnowfall; 00526 CleanupStack::PushL( self ); 00527 self->ConstructL( aParticlesCount, aPosition, aWidth, aDepth, aGroundLevel, aTextureManager); 00528 CleanupStack::Pop(); 00529 00530 return self; 00531 }
|
|
||||||||||||||||||||||||||||
|
Second phase contructor. Constructs the snow effect using the given parameters.
Definition at line 543 of file Snow.cpp. References iDepth, iGroundLevel, iSeed, iTexture, and iWidth. 00546 { 00547 CParticleEngine::ConstructL(aParticlesCount, aPosition); 00548 00549 iWidth = aWidth; 00550 iDepth = aDepth; 00551 iGroundLevel = aGroundLevel; 00552 00553 TTime now; 00554 now.HomeTime(); 00555 iSeed = now.Int64(); 00556 00557 ResetEngine(); 00558 00559 _LIT(KSnowName, "snow.jpg"); 00560 aTextureManager->RequestToLoad(KSnowName, &iTexture ); 00561 }
|
|
|
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 574 of file Snow.cpp. References iDepth, iSeed, and iWidth. 00575 { 00576 TParticle& Particle = iParticles[aIndex]; 00577 00578 Particle.iPosition = TVector( iWidth * ((float)(Math::FRand(iSeed)) - 0.5f), 00579 0, 00580 iDepth * ((float)(Math::FRand(iSeed)) - 0.5f)) + iPosition; 00581 00582 Particle.iVelocity = TVector( (float)(Math::FRand(iSeed)) * 4.0f - 2.0f, 00583 -((float)(Math::FRand(iSeed)) * 20.0f + 20.0f), 00584 (float)(Math::FRand(iSeed)) * 4.0f - 2.0f); 00585 }
|
|
|
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 592 of file Snow.cpp. References iGroundLevel, and ResetParticle(). 00593 { 00594 for ( GLint i = 0; i < iParticlesCount; i++ ) 00595 { 00596 iParticles[i].iPosition += (iParticles[i].iVelocity * aElapsedTime); 00597 if ( iParticles[i].iPosition.iY < iGroundLevel ) 00598 { 00599 ResetParticle(i); 00600 } 00601 } 00602 }
|
|
|
Implementation of CParticleEngine::RenderEngine(). Renders each particle to the screen as texture mapped polygon that uses the iTexture as texture. Definition at line 609 of file Snow.cpp. References iTexture. 00610 { 00611 glEnable(GL_BLEND); 00612 glBlendFunc(GL_ONE, GL_ONE); 00613 00614 TVector CameraPos = aCamera.GetPosition(); 00615 00616 glBindTexture( GL_TEXTURE_2D, iTexture.iID ); 00617 glVertexPointer( 3, GL_BYTE, 0, snowVertices ); 00618 glTexCoordPointer( 2, GL_BYTE, 0, snowTextureCoords ); 00619 00620 for ( GLint i = 0; i < iParticlesCount; i++ ) 00621 { 00622 glLoadIdentity(); 00623 glTranslatef(iParticles[i].iPosition.iX-CameraPos.iX, 00624 iParticles[i].iPosition.iY-CameraPos.iY, 00625 iParticles[i].iPosition.iZ-CameraPos.iZ); 00626 00627 glDrawElements( GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, snowTriangles ); 00628 } 00629 00630 glDisable(GL_BLEND); 00631 }
|
|
|
Width of the particle source area. This defines the width of the area where the snow falls. |
|
|
Depth of the particle source area. This defines the depth of the area where the snow 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). |
|
|
Snowflake texture. |
|
© Nokia 2006 |