source: projectionDesigner/tag/ProjectionDesigner_1.1.5/projdesignerplugins/defaultplugin/DefaultCubemapSceneContent.h @ 2

Last change on this file since 2 was 2, checked in by Torben Dannhauer, 10 years ago
File size: 4.3 KB
Line 
1#ifndef __DEFAULT_CUBEMAP_SCENE_CONTENT_H__
2#define __DEFAULT_CUBEMAP_SCENE_CONTENT_H__
3
4
5// Includes system headers
6#include <QtOpenGL>
7#include <stdlib.h>
8#include <GL/glut.h>
9
10// Includes Projection Designer headers
11#include <projdesigner/include/interfaces.h>
12
13// Some defines, first...
14#define SIZE 1.0f
15#define TEXCOORD_MIN 0.001f
16#define TEXCOORD_MAX 0.999f
17
18//! Cube map faces.
19enum CUBEMAP_FACE
20{
21    CUBEMAP_FACE_FRONT=0,   //!< Front face.
22    CUBEMAP_FACE_BACK,      //!< Back face.
23    CUBEMAP_FACE_LEFT,      //!< Left face.
24    CUBEMAP_FACE_RIGHT,     //!< Right face.
25    CUBEMAP_FACE_TOP,       //!< Top face.
26    CUBEMAP_FACE_BOTTOM     //!< Bottom face.
27};
28
29
30/**
31 * Implementation of the class.
32 *
33 * The purpose of the cubemap scene is to create a environment using images all
34 * around the scene.
35 *
36 */
37class DefaultCubemapSceneContent: public SceneContent
38{
39
40public:
41
42
43    /**
44     * Default constructor
45     *
46     */
47    DefaultCubemapSceneContent (SceneInterface* plugin);
48
49
50    /**
51     * Copy constructor.
52     *
53     * Uses copy_from() to make the copy.
54     *
55     */
56    DefaultCubemapSceneContent (const DefaultCubemapSceneContent& data): SceneContent(data) {copy_from(data);}
57
58
59    /**
60     * Destructor.
61     *
62     */
63    ~DefaultCubemapSceneContent ();
64
65
66    /**
67     * Implements the copy from other contents.
68     *
69     * This method is used by the copy constructor.
70     *
71     * @param content The source content to copy from.
72     *
73     * @return true if the copy is ok, false otherwise. The copy can fail if
74     *         SceneContent is not a DefaultCubemapSceneContent.
75     *
76     * @seealso is_equal_to
77     *
78     */
79    bool copy_from(const SceneContent& data);
80
81
82    /**
83     * Implements the egality-test with other contents.
84     *
85     * This could be an operator==.
86     *
87     * @param content The content to compare with.
88     *
89     * @return true if the content are equal, false otherwise. The test can
90     *         fail if the contents have different parameters, but also it
91     *         SceneContent is not a DefaultCubemapSceneContent.
92     *
93     * @seealso copy_from
94     *
95     */
96    bool is_equal_to(const SceneContent& data) const;
97
98
99    /**
100     * Draws the cubemap.
101     *
102     * @param glWidget The QGLWidget that own the OpenGL context.
103     * @param cameraMatrix The camera matrix that must be use.
104     *
105     */
106    void draw(QGLWidget* glWidget, const float* cameraMatrix);
107
108    /**
109     * Resets the cubemap.
110     *
111     * This is a pure virtual method of SceneContent.
112     *
113     */
114    void reset (void) {}
115
116
117    /**
118     * Sets the name of the texture for a face of the cubemap.
119     *
120     * @param face The face of which we want to set the name of the texture.
121     * @param fileName The new name of the texture.
122     *
123     */
124    void setTexture(CUBEMAP_FACE face, const QString& fileName);
125
126
127    /**
128     * Gets the name of the texture for a face.
129     *
130     * @param face The face of which we want to know the name of the texture.
131     *
132     * @return A QString with the name of the texture.
133     *
134     */
135    QString getTexture(CUBEMAP_FACE face) const;
136
137
138    /**
139     * Loads the cubemap from a QDomElement.
140     *
141     * @param element The QDomElement to read from.
142     *
143     */
144    void initFromDOMElement(const QDomElement& element);
145
146
147    /**
148     * Writes the cubemap in a QDomDocument.
149     *
150     * @param name The name of the element.
151     * @param doc The document whom belongs the element.
152     *
153     * @return The QDomElement to add.
154     *
155     */
156    QDomElement domElement(const QString& name, QDomDocument& doc) const;
157
158
159    /**
160     * Gets the name of cubemap scene type, stored in g_scene_name.
161     *
162     * @return The name of cubemap scene type, stored in g_scene_name.
163     *
164     */
165    const QString& scene_name(void) const {return g_scene_name;}
166
167
168    /// Public static const scene name.
169    static const QString g_scene_name;
170
171
172private:
173
174
175    /// The 6 textures names.
176    /// One for each face.
177    /// Indices are defined by the enum CUBEMAP_FACE.
178    QString m_textureFileNames[6];
179
180
181    /// The 6 textures indices (one for each face).
182    unsigned int m_textureIndex[6];
183
184};
185
186
187#endif // __DEFAULT_CUBEMAP_SCENE_CONTENT_H__
Note: See TracBrowser for help on using the repository browser.