Nokia N97 SDK
Example Applications Guide

Firefly.h

00001 /*
00002  * ==============================================================================
00003  *  Name        : Firefly.h
00004  *  Part of     : OpenGLEx / Bumpmap
00005  *
00006  *  Copyright (c) 2005-2006 Nokia Corporation.
00007  *  This material, including documentation and any related
00008  *  computer programs, is protected by copyright controlled by
00009  *  Nokia Corporation.
00010  * ==============================================================================
00011  */
00012 
00013 #ifndef __FIREFLYH__
00014 #define __FIREFLYH__
00015 
00016 //  INCLUDES
00017 
00018 #include <e32base.h>  // for CBase definition
00019 #include <GLES\gl.h>  // OpenGL ES header file
00020 #include "Utils3d.h"
00021 
00022 /**
00023  * Class that represents the firefly that is light source for the bumpmapping.
00024  */
00025 class CFireFly
00026         {
00027         public: // Constructors and destructor
00028 
00029         /**
00030          * Factory method for creating a new FireFly object.
00031                  * Calls the hidden constructors.
00032          * @param aLeft Left boundary of the rectangular area where this firefly should move in.
00033          * @param aRight Right boundary of the rectangular area where this firefly should move in.
00034          * @param aBottom Bottom boundary of the rectangular area where this firefly should move in.
00035          * @param aTop Top boundary of the rectangular area where this firefly should move in.
00036                  * @param aMinZCoord Minimum Z-coordinate for the firefly.
00037                  * @param aMaxZCoord Maximum Z-coordinate for the firefly.
00038                  * @param aTexManager Texture manager that is used to load the required textures for the firefly.
00039          */
00040                 static CFireFly* NewL( GLfloat aLeft, GLfloat aRight, GLfloat aBottom, GLfloat aTop,
00041                                        GLfloat aMinZCoord, GLfloat aMaxZCoord, CTextureManager* aTexManager );
00042 
00043         /**
00044          * Destructor. Destroys the position, target and speed vectors.
00045          */
00046                 virtual ~CFireFly();
00047 
00048         protected: // Hidden constructors
00049 
00050         /**
00051          * Standard constructor that must never Leave.
00052          * Stores the given parameters to class attributes.
00053          * @param aLeft Left boundary of the rectangular area where this firefly should move in.
00054          * @param aRight Right boundary of the rectangular area where this firefly should move in.
00055          * @param aBottom Bottom boundary of the rectangular area where this firefly should move in.
00056          * @param aTop Top boundary of the rectangular area where this firefly should move in.
00057                  * @param aMinZCoord Minimum Z-coordinate for the firefly.
00058                  * @param aMaxZCoord Maximum Z-coordinate for the firefly.
00059          */
00060                 CFireFly( GLfloat aLeft, GLfloat aRight, GLfloat aBottom, GLfloat aTop, GLfloat aMinZCoord, GLfloat aMaxZCoord );
00061 
00062         /**
00063          * Second phase constructor that can call methods that may leave.
00064                  * @param aTexManager Texture manager that is used to load the required textures for the firefly.
00065          */
00066                 void ConstructL( CTextureManager* aTexManager );
00067 
00068         public: // New methods
00069 
00070                 /**
00071                  * Calculates the movement of the firefly.
00072          * @param aFrame Number of the frame to be rendered.
00073                  * @param aTimeSecs Seconds elapsed since the application started running.
00074                  * @param aDeltaTimeSecs Seconds elapsed since last call to AppCycle().
00075                  */
00076                 void DoMovement( GLuint aFrame, GLfloat aTimeSecs, GLfloat aDeltaTimeSecs );
00077 
00078                 /**
00079                  * Draws the firefly at it's current position.
00080                  */
00081                 void Draw();
00082 
00083         public: // Data
00084 
00085                 /** Current position of the firefly. Modified in doMovement() method and also read by the CBumpMap class. */
00086                 TVector iPosition;
00087 
00088         private: // Data
00089 
00090         /** Current target position of the firefly. */
00091         TVector iTarget;
00092                 /** Current speed vector of the firefly. Used in doMovement() method to move the firefly. */
00093                 TVector iSpeed;
00094                 /** Texture that is used to draw the "glow" around the firefly. */
00095                 TTexture iGlowTexture;
00096 
00097                 /** Left boundary of the rectangular area where this firefly moves in. */
00098         GLfloat iLeft;
00099                 /** Right boundary of the rectangular area where this firefly moves in. */
00100         GLfloat iRight;
00101                 /** Bottom boundary of the rectangular area where this firefly moves in. */
00102         GLfloat iBottom;
00103                 /** Top boundary of the rectangular area where this firefly moves in. */
00104         GLfloat iTop;
00105                 /** Minimum Z-coordinate of the firefly. */
00106         GLfloat iMinZ;
00107                 /** Maximum Z-coordinate of the firefly. */
00108         GLfloat iMaxZ;
00109                 /** Seed for the random generator (initially the time when ConstructL was called). */
00110                 TInt64 iSeed;
00111         };
00112 
00113 #endif
00114 
00115 // End of File

© Nokia 2009

Back to top