1 | /*! |
---|
2 | \file material.h |
---|
3 | \brief Contains the Material Class that handles Material for 3D-Objects. |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _MATERIAL_H |
---|
7 | #define _MATERIAL_H |
---|
8 | |
---|
9 | extern int verbose; //!< will be obsolete soon. |
---|
10 | |
---|
11 | #include <GL/gl.h> |
---|
12 | #include <GL/glu.h> |
---|
13 | #include <SDL/SDL.h> |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include <config.h> |
---|
17 | #endif /* HAVE_CONFIG_H */ |
---|
18 | |
---|
19 | #ifdef HAVE_SDL_SDL_IMAGE_H |
---|
20 | #include <SDL/SDL_image.h> |
---|
21 | #else |
---|
22 | // IMAGE LIBS // |
---|
23 | #ifdef HAVE_JPEGLIB_H |
---|
24 | extern "C"{ // This has to be done, because not a c++ lib |
---|
25 | #include <jpeglib.h> |
---|
26 | } |
---|
27 | #endif /* HAVE_JPEGLIB_H */ |
---|
28 | #ifdef HAVE_PNG_H |
---|
29 | #include <png.h> |
---|
30 | #endif /* HAVE_PNG_H */ |
---|
31 | #endif /* HAVE_SDL_SDL_IMAGE_H */ |
---|
32 | |
---|
33 | class PathList |
---|
34 | { |
---|
35 | public: |
---|
36 | PathList(); |
---|
37 | PathList(char* pName); |
---|
38 | |
---|
39 | ~PathList(); |
---|
40 | void addPath (char* pName); |
---|
41 | char* pathName; |
---|
42 | PathList* next; |
---|
43 | }; |
---|
44 | |
---|
45 | |
---|
46 | //! Class to handle Materials. |
---|
47 | class Material |
---|
48 | { |
---|
49 | public: |
---|
50 | Material (); |
---|
51 | Material (char* mtlName); |
---|
52 | Material* addMaterial(char* mtlName); |
---|
53 | ~Material (); |
---|
54 | void init(void); |
---|
55 | |
---|
56 | Material* search (char* mtlName); |
---|
57 | bool select (void); |
---|
58 | |
---|
59 | void setName (char* mtlName); |
---|
60 | char* getName (void); |
---|
61 | void setIllum (int illum); |
---|
62 | void setIllum (char* illum); |
---|
63 | void setDiffuse (float r, float g, float b); |
---|
64 | void setDiffuse (char* rgb); |
---|
65 | void setAmbient (float r, float g, float b); |
---|
66 | void setAmbient (char* rgb); |
---|
67 | void setSpecular (float r, float g, float b); |
---|
68 | void setSpecular (char* rgb); |
---|
69 | void setShininess (float shini); |
---|
70 | void setShininess (char* shini); |
---|
71 | void setTransparency (float trans); |
---|
72 | void setTransparency (char* trans); |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | void addTexturePath(char* pathName); |
---|
77 | char* searchTextureInPaths(char* texName) const; |
---|
78 | // MAPPING // |
---|
79 | void setDiffuseMap(char* dMap); |
---|
80 | void setAmbientMap(char* aMap); |
---|
81 | void setSpecularMap(char* sMap); |
---|
82 | void setBump(char* bump); |
---|
83 | |
---|
84 | private: |
---|
85 | struct Image |
---|
86 | { |
---|
87 | int rowSpan; |
---|
88 | GLuint width; |
---|
89 | GLuint height; |
---|
90 | GLuint bpp; |
---|
91 | GLuint type; |
---|
92 | GLubyte *data; |
---|
93 | }; |
---|
94 | |
---|
95 | |
---|
96 | char* name; |
---|
97 | int illumModel; |
---|
98 | float diffuse [4]; |
---|
99 | float ambient [4]; |
---|
100 | float specular [4]; |
---|
101 | float shininess; |
---|
102 | float transparency; |
---|
103 | |
---|
104 | static PathList* pathList; |
---|
105 | |
---|
106 | GLuint diffuseTexture; |
---|
107 | GLuint ambientTexture; |
---|
108 | GLuint specularTexture; |
---|
109 | |
---|
110 | bool diffuseTextureSet; |
---|
111 | bool ambientTextureSet; |
---|
112 | bool specularTextureSet; |
---|
113 | |
---|
114 | Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. |
---|
115 | |
---|
116 | // TEXTURING |
---|
117 | bool loadTexToGL (Image* pImage, GLuint* texture); |
---|
118 | |
---|
119 | bool loadImage(char* imageName, GLuint* texture); |
---|
120 | #ifndef HAVE_SDL_SDL_IMAGE_H |
---|
121 | |
---|
122 | bool loadBMP (char* bmpName, GLuint* texture); |
---|
123 | |
---|
124 | bool loadJPG (char* jpgName, GLuint* texture); |
---|
125 | |
---|
126 | /// TGA /// |
---|
127 | |
---|
128 | bool loadTGA(const char * tgaName, GLuint* texture); |
---|
129 | bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
130 | bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
131 | |
---|
132 | bool loadPNG(const char* pngName, GLuint* texture); |
---|
133 | #endif |
---|
134 | }; |
---|
135 | #endif |
---|