source: projectionDesigner/trunk/projdesignerplugins/defaultplugin/DefaultModelSceneContent.h @ 108

Last change on this file since 108 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 4.7 KB
RevLine 
[4]1#ifndef __DEFAULT_MODEL_SCENE_CONTENT_H__
2#define __DEFAULT_MODEL_SCENE_CONTENT_H__
3
4// Includes system headers
5#include <stdlib.h>
6#include <GL/glut.h>
7
8// Includes Projection Designer headers
9#include <projdesigner/include/interfaces.h>
10
11// Includes local headers
12#include "glm.h"
13
14
15/**
16 * This class implements the contents to load a 3D scene from a OBJ file.
17 *
18 * A scene loaded from an OBJ file will be called a GLM scene.
19 *
20 */
21class DefaultModelSceneContent: public SceneContent
22{
23
24
25public:
26
27
28    /**
29     * Default constructor
30     *
31     */
32    DefaultModelSceneContent (SceneInterface* plugin);
33
34
35    /**
36     * Copy constructor.
37     *
38     * Uses copy_from() to make the copy.
39     *
40     */
41    DefaultModelSceneContent (const DefaultModelSceneContent& data): SceneContent(data) {copy_from(data);}
42
43
44    /**
45     * Destructor.
46     *
47     */
48    ~DefaultModelSceneContent ();
49
50
51    /**
52     * Implements the copy from other contents.
53     *
54     * This method is used by the copy constructor.
55     *
56     * @param content The source content to copy from.
57     *
58     * @return true if the copy is ok, false otherwise. The copy can fail if
59     *         SceneContent is not a DefaultModelSceneContent.
60     *
61     * @seealso is_equal_to
62     *
63     */
64    bool copy_from(const SceneContent& data);
65
66
67    /**
68     * Implements the egality-test with other contents.
69     *
70     * This could be an operator==.
71     *
72     * @param content The content to compare with.
73     *
74     * @return true if the content are equal, false otherwise. The test can
75     *         fail if the contents have different parameters, but also it
76     *         SceneContent is not a DefaultModelSceneContent.
77     *
78     * @seealso copy_from
79     *
80     */
81    bool is_equal_to(const SceneContent& data) const;
82
83
84    /**
85     * Draws the GLM scene.
86     *
87     * @param glWidget The QGLWidget that own the OpenGL context.
88     * @param cameraMatrix The camera matrix that must be use.
89     *
90     */
91    void draw(QGLWidget* glWidget, const float* cameraMatrix);
92
93
94    /**
95     * Resets the GLM scene.
96     *
97     * This is a pure virtual method of SceneContent.
98     * This one does nothing.
99     *
100     */
101    void reset (void) {}
102
103
104    /**
105     * Gets the filename of the GLM scene.
106     *
107     * @return The filename of the GLM scene.
108     *
109     */
110    QString fileName() const {return m_fileName;}
111
112
113    /**
114     * Sets the filename of the GLM scene.
115     *
116     * @param filename The new filename of the GLM scene.
117     *
118     */
119    void setFileName(const QString& fileName=QString());
120
121
122    /**
123     * Gets the backFaceCulling flag of the GLM scene.
124     *
125     * @return The backFaceCulling flag of the GLM scene.
126     *
127     */
128    bool backFaceCulling() const {return m_backFaceCulling;}
129
130
131    /**
132     * Sets the backFaceCulling flag of the GLM scene.
133     *
134     * @param bEnable The new backFaceCulling flag of the GLM scene.
135     *
136     */
137    void setBackFaceCulling(bool bEnable) {m_backFaceCulling=bEnable;}
138
139
140    /**
141     * Gets the smoothing flag of the GLM scene.
142     *
143     * @return The smoothing flag of the GLM scene.
144     *
145     */
146    bool smoothing() const {return m_smoothing;}
147
148
149    /**
150     * Sets the smoothing flag of the GLM scene.
151     *
152     * @param bEnable The new smoothing flag of the GLM scene.
153     *
154     */
155    void setSmoothing(bool bEnable) {m_smoothing=bEnable;}
156
157
158    /**
159     * Loads the GLM scene from a QDomElement.
160     *
161     * Only the contents are loaded. After this, the model is loaded from the
162     * filename. The model is not in the QDomElement.
163     *
164     * @param element The QDomElement to read from.
165     *
166     */
167    void initFromDOMElement(const QDomElement& element);
168
169
170    /**
171     * Writes the contents in a QDomDocument.
172     *
173     * Only the contents are stored in the QDomElement. The model is not stored
174     * in it.
175     *
176     * @param name The name of the element.
177     * @param doc The document whom belongs the element.
178     *
179     * @return The QDomElement to add.
180     *
181     */
182    QDomElement domElement(const QString& name, QDomDocument& doc) const;
183
184
185    /**
186     * Gets the name of GLM scene type, stored in g_scene_name.
187     *
188     * @return The name of GLM scene type, stored in g_scene_name.
189     *
190     */
191    const QString& scene_name(void) const {return g_scene_name;}
192
193
194    /// Public static const scene name for the GLM scene.
195    static const QString g_scene_name;
196
197
198private:
199
200
201    ///File name of the model.
202    QString m_fileName;
203
204
205    /// True to cull back face of the model.
206    bool m_backFaceCulling;
207
208
209    /// True to smooth surface of the model.
210    bool m_smoothing;
211
212
213    /// glm model data structure.
214    GLMmodel* m_pModel;
215
216
217    /// gml model display list index.
218    GLuint m_modelIndex;
219
220
221};
222
223
224#endif // __DEFAULT_MODEL_SCENE_CONTENT_H__
Note: See TracBrowser for help on using the repository browser.