|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : PickSelect.h 00004 * Part of : OpenGLEx / PickSelect 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 // INCLUDES 00017 #include <e32base.h> // for CBase definition 00018 #include <GLES/gl.h> // OpenGL ES header file 00019 00020 // MACROS 00021 #define POLYGON_SELECTION 1 00022 #define OBJECT_SELECTION 2 00023 #define FRUSTUM_LEFT -1.f //left vertical clipping plane 00024 #define FRUSTUM_RIGHT 1.f //right vertical clipping plane 00025 #define FRUSTUM_BOTTOM -1.f //bottom horizontal clipping plane 00026 #define FRUSTUM_TOP 1.f //top horizontal clipping plane 00027 #define FRUSTUM_NEAR 3.f //near depth clipping plane 00028 #define FRUSTUM_FAR 1000.f //far depth clipping plane 00029 00030 00031 // CLASS DECLARATION 00032 00033 /** 00034 * Class that does the actual OpenGL ES rendering. 00035 */ 00036 class CPickSelect : public CBase 00037 { 00038 public: // Constructors and destructor 00039 00040 /** 00041 * Factory method for creating a new CPickSelect object. 00042 */ 00043 static CPickSelect* NewL( TUint aWidth, TUint aHeight); 00044 00045 /** 00046 * Destructor. Does nothing. 00047 */ 00048 virtual ~CPickSelect(); 00049 00050 public: // New functions 00051 00052 /** 00053 * Initializes OpenGL ES, sets the vertex and color 00054 * arrays and pointers etc. 00055 */ 00056 void AppInit( void ); 00057 00058 /** 00059 * Called upon application exit. Does nothing. 00060 */ 00061 void AppExit( void ); 00062 00063 /** 00064 * Renders one frame. 00065 * @param aFrame Number of the frame to be rendered. 00066 */ 00067 void AppCycle( TInt aFrame ); 00068 00069 /** 00070 * Updates cursor position. 00071 */ 00072 void UpdateCursorPosition( void ); 00073 00074 /** 00075 * Draws the cursor. 00076 */ 00077 void DrawCursor( void ); 00078 00079 /** 00080 * Draw a single cube and white lines around the selected polygon 00081 * if one is selected. 00082 * @param aFrame The number of the frame to be rendered. 00083 */ 00084 void DrawSingleBox( TInt aFrame ); 00085 00086 /** 00087 * Draw two rotating boxes. 00088 * The selected cube, if there is one, is draw in wireframe mode. 00089 * @param aFrame The number of the frame to be rendered. 00090 */ 00091 void DrawMultipleBoxes( TInt aFrame ); 00092 00093 00094 /** 00095 * Sets the move up flag to the given value. 00096 * @param move True if cursor should move upwards each frame. 00097 * False if cursor shouldn't move up. 00098 */ 00099 void MoveUp( TBool move ); 00100 00101 /** 00102 * Sets the move down flag to the given value. 00103 * @param move True if cursor should move downwards each frame. 00104 * False if cursor shouldn't move down. 00105 */ 00106 void MoveDown( TBool move ); 00107 00108 /** 00109 * Sets the move left flag to the given value. 00110 * @param move True if cursor should move left each frame. 00111 * False if cursor shouldn't move left. 00112 */ 00113 void MoveLeft( TBool move ); 00114 00115 /** 00116 * Sets the move right flag to the given value. 00117 * @param move True if cursor should move right each frame. 00118 * False if cursor shouldn't move right. 00119 */ 00120 void MoveRight( TBool move ); 00121 00122 /** 00123 * Tries to select the object currently under the cursor. 00124 * Uses the cursor position to get the current pixel's alpha value and stores 00125 * it to iSelectionIdx. The iSelectionIdx is then used to check if a polygon or 00126 * an object is chosen. 00127 */ 00128 void SelectObject( void ); 00129 00130 /** 00131 * Changes selection mode to polygon selection. 00132 */ 00133 void SetPolygonSelection( void ); 00134 00135 /** 00136 * Changes selection mode to object selection. 00137 */ 00138 void SetObjectSelection( void ); 00139 00140 /** 00141 * Notifies that the screen size has dynamically changed during execution of 00142 * this program. Resets the viewport to this new size. 00143 * @param aWidth New width of the screen. 00144 * @param aHeight New height of the screen. 00145 */ 00146 void SetScreenSize( TUint aWidth, TUint aHeight ); 00147 00148 protected: // New functions 00149 00150 /** 00151 * Standard constructor that must never Leave. 00152 * Stores the given screen width and height. 00153 * @param aWidth Width of the screen. 00154 * @param aHeight Height of the screen. 00155 */ 00156 CPickSelect( TUint aWidth, TUint aHeight ); 00157 00158 /** 00159 * Second phase contructor. Does nothing. 00160 */ 00161 void ConstructL( void ); 00162 00163 private: // Data 00164 00165 /** Width of the screen */ 00166 TUint iScreenWidth; 00167 00168 /** Height of the screen */ 00169 TUint iScreenHeight; 00170 00171 /** Current selection mode (either POLYGON_SELECTION or OBJECT_SELECTION). */ 00172 TInt iSelectionMode; 00173 00174 /** Whether cursor should move up every frame or not. */ 00175 TBool iMoveUp; 00176 00177 /** Whether cursor should move down every frame or not. */ 00178 TBool iMoveDown; 00179 00180 /** Whether cursor should move left every frame or not. */ 00181 TBool iMoveLeft; 00182 00183 /** Whether cursor should move right every frame or not. */ 00184 TBool iMoveRight; 00185 00186 /** Selection ID. */ 00187 TInt iSelectionIdx; 00188 00189 /** Current X axis rotation of the cube(s). */ 00190 GLfloat iCubeRotX; 00191 00192 /** Current Y axis rotation of the cube(s). */ 00193 GLfloat iCubeRotY; 00194 00195 /** Current X coordinate of the cursor. */ 00196 GLint iCursorPosX; 00197 00198 /** Current Y coordinate of the cursor. */ 00199 GLint iCursorPosY; 00200 00201 00202 /** Currently selected pelected polygon. */ 00203 GLbyte iSelectedPoly[3]; 00204 00205 /** Current screen aspect ratio (width/height). */ 00206 GLfloat iAspectRatio; 00207 };
|
© Nokia 2006 |