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