| 1 | /*! |
|---|
| 2 | * @file skybox.h |
|---|
| 3 | * Definition of the SkyBox, that handles the Display of an atmosphere for orxonox. |
|---|
| 4 | * |
|---|
| 5 | * A SkyBox is always centered at the current working Camera, and will only obey the cameras |
|---|
| 6 | * movment but not its rotation. |
|---|
| 7 | */ |
|---|
| 8 | |
|---|
| 9 | #ifndef _SKYBOX_H |
|---|
| 10 | #define _SKYBOX_H |
|---|
| 11 | |
|---|
| 12 | /* INCLUDES */ |
|---|
| 13 | #include "world_entity.h" |
|---|
| 14 | #include "material.h" |
|---|
| 15 | |
|---|
| 16 | enum SKY_SIDE |
|---|
| 17 | { |
|---|
| 18 | SKY_BACK = 0, |
|---|
| 19 | SKY_FRONT, |
|---|
| 20 | SKY_BOTTOM, |
|---|
| 21 | SKY_TOP, |
|---|
| 22 | SKY_LEFT, |
|---|
| 23 | SKY_RIGHT, |
|---|
| 24 | }; |
|---|
| 25 | |
|---|
| 26 | //! A Class to handle a SkyBox |
|---|
| 27 | class SkyBox : public WorldEntity |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | SkyBox(const std::string& fileName = ""); |
|---|
| 31 | SkyBox(const TiXmlElement* root); |
|---|
| 32 | |
|---|
| 33 | virtual ~SkyBox(); |
|---|
| 34 | |
|---|
| 35 | void init(); |
|---|
| 36 | void preInit(); |
|---|
| 37 | |
|---|
| 38 | virtual void loadParams(const TiXmlElement* root); |
|---|
| 39 | |
|---|
| 40 | void postInit(); |
|---|
| 41 | |
|---|
| 42 | virtual void draw(); |
|---|
| 43 | |
|---|
| 44 | void setSize(float size); |
|---|
| 45 | /** assumes jpg as input-format */ |
|---|
| 46 | void setTexture(const std::string& name); |
|---|
| 47 | |
|---|
| 48 | void setTextureAndType(const std::string& name, const std::string& extension); |
|---|
| 49 | void setTextures(const std::string& negX, const std::string& posX, const std::string& negY, |
|---|
| 50 | const std::string& posY, const std::string& negZ, const std::string& posZ); |
|---|
| 51 | |
|---|
| 52 | void loadCubeMapTextures(const std::string& negX, const std::string& posX, const std::string& negY, |
|---|
| 53 | const std::string& posY, const std::string& negZ, const std::string& posZ); |
|---|
| 54 | |
|---|
| 55 | GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->getDiffuseTexture(): 0; }; |
|---|
| 56 | |
|---|
| 57 | static void enableCubeMap(); |
|---|
| 58 | static void disableCubeMap(); |
|---|
| 59 | |
|---|
| 60 | virtual int writeBytes(const byte* data, int length, int sender); |
|---|
| 61 | virtual int readBytes(byte* data, int maxLength, int * reciever); |
|---|
| 62 | virtual void writeDebug() const; |
|---|
| 63 | virtual void readDebug() const; |
|---|
| 64 | |
|---|
| 65 | private: |
|---|
| 66 | void rebuild(); |
|---|
| 67 | |
|---|
| 68 | Material* material[6]; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back |
|---|
| 69 | Texture* cubeTexture[6]; //!< Textures for the CubeMap. |
|---|
| 70 | |
|---|
| 71 | float size; //!< Size of the SkyBox. This should match the frustum maximum range. |
|---|
| 72 | float textureSize; //!< this is the length of a texture (assumes a square texture) |
|---|
| 73 | std::string textureName; //!< Name of the Texture |
|---|
| 74 | |
|---|
| 75 | }; |
|---|
| 76 | |
|---|
| 77 | #endif /* _SKYBOX_H */ |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|