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 | #include <stdlib.h> |
---|
15 | #include <fstream> |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include <config.h> |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifdef HAVE_SDL_SDL_IMAGE_H |
---|
22 | #include <SDL/SDL_image.h> |
---|
23 | #else |
---|
24 | // IMAGE LIBS // |
---|
25 | extern "C"{ // This has to be done, because not a c++ lib |
---|
26 | #include <jpeglib.h> |
---|
27 | } |
---|
28 | #include <png.h> |
---|
29 | #endif |
---|
30 | |
---|
31 | //! Class to handle Materials. |
---|
32 | class Material |
---|
33 | { |
---|
34 | public: |
---|
35 | Material (); |
---|
36 | Material (char* mtlName); |
---|
37 | Material* addMaterial(char* mtlName); |
---|
38 | ~Material (); |
---|
39 | void init(void); |
---|
40 | |
---|
41 | Material* search (char* mtlName); |
---|
42 | bool select (void); |
---|
43 | |
---|
44 | void setName (char* mtlName); |
---|
45 | char* getName (void); |
---|
46 | void setIllum (int illum); |
---|
47 | void setIllum (char* illum); |
---|
48 | void setDiffuse (float r, float g, float b); |
---|
49 | void setDiffuse (char* rgb); |
---|
50 | void setAmbient (float r, float g, float b); |
---|
51 | void setAmbient (char* rgb); |
---|
52 | void setSpecular (float r, float g, float b); |
---|
53 | void setSpecular (char* rgb); |
---|
54 | void setShininess (float shini); |
---|
55 | void setShininess (char* shini); |
---|
56 | void setTransparency (float trans); |
---|
57 | void setTransparency (char* trans); |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | // MAPPING // |
---|
63 | void setDiffuseMap(char* dMap); |
---|
64 | void setAmbientMap(char* aMap); |
---|
65 | void setSpecularMap(char* sMap); |
---|
66 | void setBump(char* bump); |
---|
67 | |
---|
68 | |
---|
69 | private: |
---|
70 | struct Image |
---|
71 | { |
---|
72 | int rowSpan; |
---|
73 | GLuint width; |
---|
74 | GLuint height; |
---|
75 | GLuint bpp; |
---|
76 | GLuint type; |
---|
77 | GLubyte *data; |
---|
78 | }; |
---|
79 | |
---|
80 | |
---|
81 | char* name; |
---|
82 | int illumModel; |
---|
83 | float diffuse [4]; |
---|
84 | float ambient [4]; |
---|
85 | float specular [4]; |
---|
86 | float shininess; |
---|
87 | float transparency; |
---|
88 | |
---|
89 | GLuint diffuseTexture; |
---|
90 | GLuint ambientTexture; |
---|
91 | GLuint specularTexture; |
---|
92 | |
---|
93 | bool diffuseTextureSet; |
---|
94 | bool ambientTextureSet; |
---|
95 | bool specularTextureSet; |
---|
96 | |
---|
97 | Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. |
---|
98 | |
---|
99 | // TEXTURING |
---|
100 | bool loadTexToGL (Image* pImage, GLuint* texture); |
---|
101 | |
---|
102 | bool loadImage(char* imageName, GLuint* texture); |
---|
103 | #ifndef HAVE_SDL_SDL_IMAGE_H |
---|
104 | |
---|
105 | bool loadBMP (char* bmpName, GLuint* texture); |
---|
106 | |
---|
107 | bool loadJPG (char* jpgName, GLuint* texture); |
---|
108 | |
---|
109 | /// TGA /// |
---|
110 | |
---|
111 | bool loadTGA(const char * tgaName, GLuint* texture); |
---|
112 | bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
113 | bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
114 | |
---|
115 | bool loadPNG(const char* pngName, GLuint* texture); |
---|
116 | #endif |
---|
117 | }; |
---|
118 | #endif |
---|