#ifndef __DEFAULT_MODEL_SCENE_CONTENT_H__ #define __DEFAULT_MODEL_SCENE_CONTENT_H__ // Includes system headers #include #include // Includes Projection Designer headers #include // Includes local headers #include "glm.h" /** * This class implements the contents to load a 3D scene from a OBJ file. * * A scene loaded from an OBJ file will be called a GLM scene. * */ class DefaultModelSceneContent: public SceneContent { public: /** * Default constructor * */ DefaultModelSceneContent (SceneInterface* plugin); /** * Copy constructor. * * Uses copy_from() to make the copy. * */ DefaultModelSceneContent (const DefaultModelSceneContent& data): SceneContent(data) {copy_from(data);} /** * Destructor. * */ ~DefaultModelSceneContent (); /** * Implements the copy from other contents. * * This method is used by the copy constructor. * * @param content The source content to copy from. * * @return true if the copy is ok, false otherwise. The copy can fail if * SceneContent is not a DefaultModelSceneContent. * * @seealso is_equal_to * */ bool copy_from(const SceneContent& data); /** * Implements the egality-test with other contents. * * This could be an operator==. * * @param content The content to compare with. * * @return true if the content are equal, false otherwise. The test can * fail if the contents have different parameters, but also it * SceneContent is not a DefaultModelSceneContent. * * @seealso copy_from * */ bool is_equal_to(const SceneContent& data) const; /** * Draws the GLM scene. * * @param glWidget The QGLWidget that own the OpenGL context. * @param cameraMatrix The camera matrix that must be use. * */ void draw(QGLWidget* glWidget, const float* cameraMatrix); /** * Resets the GLM scene. * * This is a pure virtual method of SceneContent. * This one does nothing. * */ void reset (void) {} /** * Gets the filename of the GLM scene. * * @return The filename of the GLM scene. * */ QString fileName() const {return m_fileName;} /** * Sets the filename of the GLM scene. * * @param filename The new filename of the GLM scene. * */ void setFileName(const QString& fileName=QString()); /** * Gets the backFaceCulling flag of the GLM scene. * * @return The backFaceCulling flag of the GLM scene. * */ bool backFaceCulling() const {return m_backFaceCulling;} /** * Sets the backFaceCulling flag of the GLM scene. * * @param bEnable The new backFaceCulling flag of the GLM scene. * */ void setBackFaceCulling(bool bEnable) {m_backFaceCulling=bEnable;} /** * Gets the smoothing flag of the GLM scene. * * @return The smoothing flag of the GLM scene. * */ bool smoothing() const {return m_smoothing;} /** * Sets the smoothing flag of the GLM scene. * * @param bEnable The new smoothing flag of the GLM scene. * */ void setSmoothing(bool bEnable) {m_smoothing=bEnable;} /** * Loads the GLM scene from a QDomElement. * * Only the contents are loaded. After this, the model is loaded from the * filename. The model is not in the QDomElement. * * @param element The QDomElement to read from. * */ void initFromDOMElement(const QDomElement& element); /** * Writes the contents in a QDomDocument. * * Only the contents are stored in the QDomElement. The model is not stored * in it. * * @param name The name of the element. * @param doc The document whom belongs the element. * * @return The QDomElement to add. * */ QDomElement domElement(const QString& name, QDomDocument& doc) const; /** * Gets the name of GLM scene type, stored in g_scene_name. * * @return The name of GLM scene type, stored in g_scene_name. * */ const QString& scene_name(void) const {return g_scene_name;} /// Public static const scene name for the GLM scene. static const QString g_scene_name; private: ///File name of the model. QString m_fileName; /// True to cull back face of the model. bool m_backFaceCulling; /// True to smooth surface of the model. bool m_smoothing; /// glm model data structure. GLMmodel* m_pModel; /// gml model display list index. GLuint m_modelIndex; }; #endif // __DEFAULT_MODEL_SCENE_CONTENT_H__