S60 3rd Edition SDK for Symbian OS
Example Applications Guide

Hierarchy.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : Hierarchy.h
00004 *  Part of     : OpenGLEx / Hierarchy
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #ifndef HIERARCHY_H
00017 #define HIERARCHY_H
00018 
00019 // INCLUDES
00020 #include <e32base.h> // for CBase definition
00021 #include <GLES/gl.h> // OpenGL ES header file
00022 
00023 // MACROS
00024 #define ROTATE_ELBOW   1        // Rotation mode for elbow rotation.
00025 #define ROTATE_FINGERS 2        // Rotation mode for finger rotation.
00026 
00027 #define FRUSTUM_LEFT   -1.f     //left vertical clipping plane
00028 #define FRUSTUM_RIGHT   1.f     //right vertical clipping plane
00029 #define FRUSTUM_BOTTOM -1.f     //bottom horizontal clipping plane
00030 #define FRUSTUM_TOP     1.f     //top horizontal clipping plane
00031 #define FRUSTUM_NEAR    3.f     //near depth clipping plane
00032 #define FRUSTUM_FAR  1000.f     //far depth clipping plane
00033 
00034 // CLASS DECLARATION
00035 
00036 /**
00037  * Class that does the actual OpenGL ES rendering.
00038  */
00039 class CHierarchy : public CBase
00040     {
00041     public:  // Constructors and destructor
00042       
00043         /**
00044          * Factory method for creating a new CSimpleCube object.
00045          */
00046         static CHierarchy* NewL( TUint aWidth, TUint aHeight);
00047         
00048         /**
00049          * Destructor. Does nothing.
00050          */
00051         virtual ~CHierarchy();
00052   
00053     public: // New functions
00054   
00055         /**
00056          * Initializes OpenGL ES, sets the vertex and color
00057          * arrays and pointers. Also selects the shading mode.
00058          */
00059         void AppInit( void );
00060         
00061         /**
00062          * Called upon application exit. Does nothing.
00063          */
00064         void AppExit( void );
00065         
00066         /**
00067          * Draws a 3D box.
00068          */
00069         void DrawBox( void );
00070         
00071         /**
00072          * Draw a coordinate system
00073          */
00074         void DrawCoordSystem( void );
00075         
00076         /**
00077          * Renders one frame.
00078          * @param aFrame Number of the frame to be rendered.
00079          */
00080         void AppCycle( TInt aFrame );
00081         
00082         /**
00083          * Toggle object "up" rotation on and off based on the given value.
00084          * @param aStart True if object should be rotated up every frame.
00085          *               False if object shouldn't be rotated up every frame.
00086          */
00087         void RotateObjectUp( TBool aStart );
00088         
00089         /**
00090          * Toggle object "down" rotation on and off based on the given value.
00091          * @param aStart True if object should be rotated down every frame.
00092          *               False if object shouldn't be rotated down every frame.
00093          */
00094         void RotateObjectDown( TBool aStart );
00095         
00096         /**
00097          * Toggles the rotation mode between rotating the arm or the fingers
00098          */
00099         void SwitchRotateMode( void );
00100         
00101         /**
00102          * Notifies that the screen size has dynamically changed during execution of
00103          * this program. Resets the viewport to this new size.
00104          * @param aWidth New width of the screen.
00105          * @param aHeight New height of the screen.
00106          */
00107         void SetScreenSize( TUint aWidth, TUint aHeight );
00108 
00109     protected:
00110 
00111         /**
00112          * Standard constructor that must never Leave.
00113          * Stores the given screen width and height.
00114          * @param aWidth Width of the screen.
00115          * @param aHeight Height of the screen.
00116          */
00117         CHierarchy( TUint aWidth, TUint aHeight);
00118 
00119         /**
00120          * Second phase contructor. Does nothing.
00121          */
00122         void ConstructL( void );
00123         
00124     private:  // Data
00125 
00126         /** Width of the screen */
00127         TUint iScreenWidth;
00128         
00129         /** Height of the screen */
00130         TUint iScreenHeight;
00131 
00132         /** The current rotation mode (ROTATE_ELBOW or ROTATE_FINGERS).  */
00133         TInt   iRotateMode;
00134 
00135         /** Whether object should be rotated up during each rendered frame or not. */
00136         TBool  iRotateUpEnabled;
00137         
00138         /** Whether object should be rotated down during each rendered frame or not. */
00139         TBool   iRotateDownEnabled;
00140 
00141         /** Current rotation angle of the elbow. */
00142         TReal32 iElbowRotAngle;
00143 
00144         /** Current rotation angle of the fingers. */
00145         TReal32 iFingersRotAngle;
00146     };
00147 
00148 #endif
00149 
00150 // End of File

© Nokia 2006

Back to top