#ifndef __DEFAULT_CUBEMAP_SCENE_CONTENT_H__ #define __DEFAULT_CUBEMAP_SCENE_CONTENT_H__ // Includes system headers #include #include #include // Includes Projection Designer headers #include // Some defines, first... #define SIZE 1.0f #define TEXCOORD_MIN 0.001f #define TEXCOORD_MAX 0.999f //! Cube map faces. enum CUBEMAP_FACE { CUBEMAP_FACE_FRONT=0, //!< Front face. CUBEMAP_FACE_BACK, //!< Back face. CUBEMAP_FACE_LEFT, //!< Left face. CUBEMAP_FACE_RIGHT, //!< Right face. CUBEMAP_FACE_TOP, //!< Top face. CUBEMAP_FACE_BOTTOM //!< Bottom face. }; /** * Implementation of the class. * * The purpose of the cubemap scene is to create a environment using images all * around the scene. * */ class DefaultCubemapSceneContent: public SceneContent { public: /** * Default constructor * */ DefaultCubemapSceneContent (SceneInterface* plugin); /** * Copy constructor. * * Uses copy_from() to make the copy. * */ DefaultCubemapSceneContent (const DefaultCubemapSceneContent& data): SceneContent(data) {copy_from(data);} /** * Destructor. * */ ~DefaultCubemapSceneContent (); /** * 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 DefaultCubemapSceneContent. * * @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 DefaultCubemapSceneContent. * * @seealso copy_from * */ bool is_equal_to(const SceneContent& data) const; /** * Draws the cubemap. * * @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 cubemap. * * This is a pure virtual method of SceneContent. * */ void reset (void) {} /** * Sets the name of the texture for a face of the cubemap. * * @param face The face of which we want to set the name of the texture. * @param fileName The new name of the texture. * */ void setTexture(CUBEMAP_FACE face, const QString& fileName); /** * Gets the name of the texture for a face. * * @param face The face of which we want to know the name of the texture. * * @return A QString with the name of the texture. * */ QString getTexture(CUBEMAP_FACE face) const; /** * Loads the cubemap from a QDomElement. * * @param element The QDomElement to read from. * */ void initFromDOMElement(const QDomElement& element); /** * Writes the cubemap in a QDomDocument. * * @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 cubemap scene type, stored in g_scene_name. * * @return The name of cubemap scene type, stored in g_scene_name. * */ const QString& scene_name(void) const {return g_scene_name;} /// Public static const scene name. static const QString g_scene_name; private: /// The 6 textures names. /// One for each face. /// Indices are defined by the enum CUBEMAP_FACE. QString m_textureFileNames[6]; /// The 6 textures indices (one for each face). unsigned int m_textureIndex[6]; }; #endif // __DEFAULT_CUBEMAP_SCENE_CONTENT_H__