?? cgame.h
字號:
/*
============================================================================
* Name : CGame.h
* Part of : Example3D
* Description : Definition of CGame
* Copyright (c) 2007-2008 Nokia Corporation
============================================================================
*/
#ifndef __CGAME_H__
#define __CGAME_H__
// INCLUDES
#include <e32base.h>
#include "MGame.h"
#include "3dtypes.h"
#include "GLES/egl.h"
#include "GLES/gl.h"
#ifdef SENSOR_API_SUPPORT_ENABLED
#include "RRSensorApi.h"
#endif //SENSOR_API_SUPPORT_ENABLED
// FORWARD DECLARATIONS
class C3DBase;
class C3DRenderer;
class CPolygonObject;
class CFpsCounter;
class CSensorDataFilter;
// ENUMERATIONS
enum TCameraMode
{
ECameraBehind, // camera follows behind car
ECameraInCar, // in-car camera
ECameraSouth, // camera follows car and looks at car from south
ECameraTV1, // TV-cameras around the field
ECameraTV2,
ECameraTV3,
ECameraTV4,
ECameraNone // Null camera
};
// CLASS DECLARATION
/**
* CGame implemets MGame class
* MGame classes are used by CEngine
* Which calls Draw and Move functions
*/
class CGame
: public CBase
, public MGame
#ifdef SENSOR_API_SUPPORT_ENABLED
, public MRRSensorDataListener
#endif //SENSOR_API_SUPPORT_ENABLED
{
public:
/// Two-phased constructor
/// @param aDisplayMode display's color mode
/// @param aScreen bitmap to draw to
static CGame* NewL( TDisplayMode aDisplayMode );
/// Destructor
~CGame();
private:
/// Second-phase constructor
/// @param aScreen bitmap to draw to
void ConstructL();
/// Default constructor
CGame( TDisplayMode aDisplayMode );
public: // MGame
/// Called from CEngine
/// @param aScreen bitmap to draw to
void Draw( const TBitmap& aScreen );
/// Called from CEngine
/// @param aKey key table to read key press states
/// for example if( aKey[ '1' ] ) Pause();
void Move( TUint8* aKey );
/// Helper function to get polygon count
TInt PolygonCount();
/// Gets commands from engine
/// Engine gets these commands from application framework
/// @param aCommand command index
virtual void Command( TInt aCommand );
#ifdef SENSOR_API_SUPPORT_ENABLED
public: //From MRRSensorDataListener
/**
* From MRRSensorDataListener, HandleDataEventL
* Callback function for receiving sensor
* data events
*
* @param aSensor identifies sensor that created the event.
* @param aEvent contains data about created event.
*/
void HandleDataEventL( TRRSensorInfo aSensor, TRRSensorEvent aEvent );
#endif //SENSOR_API_SUPPORT_ENABLED
private: // New methods:
/// creates a wheel 3D-object with given parameters
/// with more points the wheel is more like a circle
/// @param aRadius wheel radius
/// @param aWidth wheel width
/// @param aNumPoints number of points used on wheel surface
CPolygonObject* CreateWheel( TInt aRadius, TInt aWidth, TInt aNumPoints );
/// creates a 3D-object from given data
/// @param aVertexData pointer to vertex data
/// @param aFaceData pointer to face data
/// @param aNumVertices number of vertices in vertex data
/// @param aNumFaces number of faces in face data
/// @param aTexOffset offset added to texture coordinates
/// @param aTexMul original texture coordinates are multiplied with this
CPolygonObject* CreateObject( const TInt* aVertexData, const TInt* aFaceData,
TInt aNumVertices, TInt aNumFaces,
const TPoint& aTexOffset, TInt aTexMul );
/// Draws text with polygons to polygon object
/// destroys all previous data from polygon object
/// supports newline ( '\n' )
/// @param aObject 3D-object to draw to
/// @param aStr, text to draw to object
void DrawText( CPolygonObject* aObject, const TDesC8& aStr );
#ifdef SENSOR_API_SUPPORT_ENABLED
/**
* Sets up sensor-related data, loads DLLs and registers sensor
* observers.
*/
void SetupSensors();
/**
* Registers the accelerometer observer and initializes the sensors.
*/
TBool RegisterSensor();
/**
* Unregisters the accelerometer observer.
*/
void UnregisterSensor();
/**
* Resets sensor-related data.
*/
void CleanupSensors();
#endif //SENSOR_API_SUPPORT_ENABLED
private: // data
TDisplayMode iDisplayMode; // color mode to use
TBitmap iScreen; // screen bitmap
TBitmap iTexture; // textures for car and road
TBitmap iTexture2; // textures for house
TBitmap iTextureFont; // texture for fonts
GLuint iGlTexture; // texture handles for OpenGL
GLuint iGlTexture2;
GLuint iGlTextureFont;
C3DBase* i3DBase; // base for all 3D
C3DRenderer* iRender; // 3D-renderer
CPolygonObject* i3dHouse; // house building
CPolygonObject* i3dRoad; // one tile of road
CPolygonObject* i3dGrass; // one tile of grass
CPolygonObject* i3dCar; // the car
CPolygonObject* i3dFrontWheel; // one piece of front wheels
CPolygonObject* i3dRearWheel; // one piece of rear wheels
CPolygonObject* i3dText; // text table for statistics
TInt iCarAngle; // car position and movemet parameters
TInt iCarAngleSpeed;
TInt iCarSpeed;
TInt iCarPos;
TVertex iCarPosition;
TVertex iCarPositionAdd;
TInt iCarTilt;
TInt iSpeed;
TInt iAngleSpeed;
TInt iSteerAngle;
TInt iThrottle;
TInt iCameraMode; // camera mode
TInt iCameraAngle;
TBool iSensorSteeringMode;
TBool iSensorThrottleMode;
#ifdef SENSOR_API_SUPPORT_ENABLED
CRRSensorApi* iSensor;
TBool iSensorsSupported;
#ifdef SENSOR_API_LOAD_DYNAMICALLY
RLibrary iSensorApi;
#endif //SENSOR_API_LOAD_DYNAMICALLY
TInt iSensorDataX;
TInt iSensorDataY;
TInt iSensorDataZ;
CSensorDataFilter* iSensorDataFilterX;
CSensorDataFilter* iSensorDataFilterY;
CSensorDataFilter* iSensorDataFilterZ;
#endif //SENSOR_API_SUPPORT_ENABLED
CFpsCounter* iFps; // current speed Frames / Second
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -