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 | |
---|
15 | /* FORWARD DECLARATION */ |
---|
16 | class Material; |
---|
17 | class Texture; |
---|
18 | |
---|
19 | //! A Class to handle a SkyBox |
---|
20 | class SkyBox : public WorldEntity |
---|
21 | { |
---|
22 | public: |
---|
23 | SkyBox(const char* fileName = NULL); |
---|
24 | SkyBox(const TiXmlElement* root); |
---|
25 | |
---|
26 | virtual ~SkyBox(); |
---|
27 | |
---|
28 | void init(); |
---|
29 | void preInit(); |
---|
30 | |
---|
31 | virtual void loadParams(const TiXmlElement* root); |
---|
32 | |
---|
33 | void postInit(); |
---|
34 | |
---|
35 | virtual void draw(); |
---|
36 | |
---|
37 | void setSize(float size); |
---|
38 | /** assumes jpg as input-format */ |
---|
39 | void setTexture(const char* name) { if (textureName) delete[] textureName; textureName = new char[strlen(name)+1]; strcpy(textureName, name); this->setTextureAndType (name, "jpg"); }; |
---|
40 | |
---|
41 | void setTextureAndType(const char* name, const char* extension); |
---|
42 | void setTextures(const char* top, const char* bottom, const char* left, |
---|
43 | const char* right, const char* front, const char* back); |
---|
44 | |
---|
45 | void loadCubeMapTextures(const char* top, const char* bottom, const char* left, |
---|
46 | const char* right, const char* front, const char* back); |
---|
47 | |
---|
48 | static void enableCubeMap(); |
---|
49 | static void disableCubeMap(); |
---|
50 | |
---|
51 | virtual int writeBytes(const byte* data, int length, int sender); |
---|
52 | virtual int readBytes(byte* data, int maxLength, int * reciever); |
---|
53 | virtual void writeDebug() const; |
---|
54 | virtual void readDebug() const; |
---|
55 | |
---|
56 | private: |
---|
57 | void rebuild(); |
---|
58 | |
---|
59 | Material* material[6]; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back |
---|
60 | Texture* cubeTexture[6]; //!< Textures for the CubeMap. |
---|
61 | |
---|
62 | float size; //!< Size of the SkyBox. This should match the frustum maximum range. |
---|
63 | float textureSize; //!< this is the length of a texture (assumes a square texture) |
---|
64 | char* textureName; //!< Name of the Texture |
---|
65 | |
---|
66 | }; |
---|
67 | |
---|
68 | #endif /* _SKYBOX_H */ |
---|
69 | |
---|
70 | |
---|
71 | |
---|