Nokia N97 SDK
Example Applications Guide

Hierarchy.h

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

© Nokia 2009

Back to top