sl@0
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef MODEL_H_
|
sl@0
|
18 |
#define MODEL_H_
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "geometrystructs.h"
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <GLES/egl.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
class CSolidSphere;
|
sl@0
|
28 |
|
sl@0
|
29 |
/*
|
sl@0
|
30 |
The model class contains one or more shapes and some knowledge of how to
|
sl@0
|
31 |
arrange and light them to create a scene. It knows how to do two things:
|
sl@0
|
32 |
- change the resolution of the shapes in the scene, which involves
|
sl@0
|
33 |
recalculating their vertices.
|
sl@0
|
34 |
- draw the scene to a buffer by drawing, arranging and lighting the shapes
|
sl@0
|
35 |
using Open GL ES commands.
|
sl@0
|
36 |
|
sl@0
|
37 |
It understands that these two operations may be happening in different
|
sl@0
|
38 |
threads, so it serialises access to the model data (the vertices) with a mutex.
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
|
sl@0
|
41 |
class CModel : public CBase
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface, TPtrC aBackgroundColor);
|
sl@0
|
45 |
static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface);
|
sl@0
|
46 |
~CModel();
|
sl@0
|
47 |
void PrecalculateOrbitL(TInt aOrbitingDistance, RArray<Vertex3F>& aVertices, TInt aPositionCount, TReal aAngle);
|
sl@0
|
48 |
void SetResolutionL(TInt aResolution);
|
sl@0
|
49 |
void DrawToBuffer(TInt aTime) const;
|
sl@0
|
50 |
|
sl@0
|
51 |
enum {ERed = 0, EGreen, EBlue, EAlpha};
|
sl@0
|
52 |
|
sl@0
|
53 |
private:
|
sl@0
|
54 |
CModel(EGLDisplay aDisplay, EGLSurface aSurface);
|
sl@0
|
55 |
void ConstructL(TPtrC aBackgroundColor);
|
sl@0
|
56 |
void SetShapes(CSolidSphere* aSun, CSolidSphere* aPlanet, CSolidSphere* aSatellite);
|
sl@0
|
57 |
void InitialiseFrame() const;
|
sl@0
|
58 |
void DrawModelData(TInt aTime) const;
|
sl@0
|
59 |
|
sl@0
|
60 |
private:
|
sl@0
|
61 |
EGLDisplay iDisplay;
|
sl@0
|
62 |
EGLSurface iSurface;
|
sl@0
|
63 |
|
sl@0
|
64 |
CSolidSphere* iSun;
|
sl@0
|
65 |
CSolidSphere* iPlanet;
|
sl@0
|
66 |
CSolidSphere* iMoon;
|
sl@0
|
67 |
|
sl@0
|
68 |
RArray<Vertex3F> iSunPositions;
|
sl@0
|
69 |
RArray<Vertex3F> iMoonPositions;
|
sl@0
|
70 |
GLclampf iBackgroundColor[4];
|
sl@0
|
71 |
TInt iResolution;
|
sl@0
|
72 |
};
|
sl@0
|
73 |
|
sl@0
|
74 |
#endif /* MODEL_H_ */
|