📄 snow.h
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */
#ifndef __SNOWH__
#define __SNOWH__
// INCLUDES
#include <e32base.h> // for CBase definition
#include <GLES\gl.h> // OpenGL ES header file
#include "utils.h"
// MACROS
#define FRUSTUM_LEFT -1.f //left vertical clipping plane
#define FRUSTUM_RIGHT +1.f //right vertical clipping plane
#define FRUSTUM_BOTTOM -1.f //bottom horizontal clipping plane
#define FRUSTUM_TOP +1.f //top horizontal clipping plane
#define FRUSTUM_NEAR +3.f //near depth clipping plane
#define FRUSTUM_FAR +1000.f //far depth clipping plane
// FORWARD DECLARATIONS
class CSnowfall;
/**
* Snow effect core class
*/
class CSnow
: public CFiniteStateMachine, public MTextureLoadingListener
{
public: // Constructors and destructor
static CSnow* NewL( TUint aWidth, TUint aHeight );
virtual ~CSnow();
public: // New functions.
enum
{
ELoadingTextures,
ERunning
}; //application states:
// ELoadingTextures - indicates that the app. is loading textures
// ERunning - indicates that the app. is running
/**
* Application initialization
*/
void AppInitL( void );
/**
* Application exit cleanup
*/
void AppExit( void );
/**
* Drawing the ground plane
*/
void DrawPlane();
/**
* Draw a tree
*/
void DrawTree( GLfloat aX, GLfloat aZ );
/**
* Draw clouds
*/
void DrawCloud();
/**
* Animation step. Draw and animate objects
*/
void AppCycle( TInt aFrame );
/**
* State machine handler
* @param aState State entered
*/
void OnEnterStateL( TInt aState );
// MTextureLoadingListener interface implemetations:
/**
* Method called on loading textures
*/
void OnStartLoadingTexturesL();
/**
* Method called when texture loaded
*/
void OnEndLoadingTexturesL();
/**
* Texture-manager setup
* @param aTextureManager Pointer to a texture manager
*/
void SetTextureManager( CTextureManager * aTextureManager );
/**
* Get pointer to the particle-engine effect
* @return Effect
*/
CSnowfall* GetSnowfall();
/**
* Ticker-timer get
* @return The system time
*/
TTime GetTimeTick();
/**
* Total time get
* @return The elapsed time (in sec.) between the current and the previous frame
*/
GLfloat GetElapsedTime();
/**
* Frames-per-second count.
* @return Current frames per second
*/
GLfloat GetFPSCount();
protected:
/**
* C++ default constructor.
*/
CSnow( TUint aWidth, TUint aHeight );
/**
* Symbian 2nd phase constructor.
*/
void ConstructL( void );
private: // Data
// Screen width
TUint iScreenWidth;
// Screen height
TUint iScreenHeight;
// Owns: Texture manager
CTextureManager* iTextureManager;
// Tree texture
TTexture iTreeTexture;
// Ground texture
TTexture iGroundTexture;
// Cloud texture
TTexture iCloudTexture;
// Cloud texture coordinates
GLfloat iCloudTextureCoords[8];
// Texture offset
GLfloat iTextureOffset;
// Owns: Pointer to snowfall-effect
CSnowfall* iSnowfall;
// Camera
TCamera iCamera;
// Reference time
TTime iT0;
// Reference time + time delta
TTime iT1;
// Elapsed time = iT1 - iT0
GLfloat iElapsedTime;
// Current frames per second
GLfloat iFPSCount;
};
/**
* Snowfall particle effect class
*/
class CSnowfall: public CParticleEngine
{
public: // Constructors and destructor
// Creates and initializes a CSnowfall object.
static CSnowfall* NewL(GLint aParticlesCount, TVector aPosition,
GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel,
CTextureManager* aTextureManager);
// Destructor
virtual ~CSnowfall();
protected:
CSnowfall::CSnowfall();
void ConstructL(GLint aParticlesCount, TVector aPosition,
GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel,
CTextureManager * aTextureManager);
public: // Functions from base classes
// implementation of CParticleEngine::ResetParticle(GLint)
void ResetParticle(GLint aIndex);
// implementation of CParticleEngine::UpdateEngine(GLfloat aElapsedTime)
void UpdateEngine(GLfloat aElapsedTime);
// implementation of CParticleEngine::RenderEngine(TCamera &)
void RenderEngine(TCamera& aCamera);
public: // Data
// Width
GLfloat iWidth;
// Depth
GLfloat iDepth;
// Ground level
GLfloat iGroundLevel;
/*
snowflakes are released from within
the rectangle (CParticleEngine::iPosition.iX-iWidth/2, CParticleEngine::iPosition.iY, iPosition.iX-iWidth/2)
(CParticleEngine::iPosition.iX+iWidth/2, CParticleEngine::iPosition.iY, iPosition.iX+iWidth/2).
Once their height is < iGroundLevel, they are reset.
*/
protected: // Data
// Seed for the random generator.
TInt64 iSeed;
// Snowflake texture
TTexture iTexture;
};
#endif
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -