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 | // IMAGE LIBS // |
---|
18 | extern "C"{ // This has to be done, because not a c++ lib |
---|
19 | #include <jpeglib.h> |
---|
20 | } |
---|
21 | //! Class to handle Materials. |
---|
22 | class Material |
---|
23 | { |
---|
24 | public: |
---|
25 | Material (); |
---|
26 | Material (char* mtlName); |
---|
27 | Material* addMaterial(char* mtlName); |
---|
28 | ~Material (); |
---|
29 | void init(void); |
---|
30 | |
---|
31 | Material* search (char* mtlName); |
---|
32 | bool select (void); |
---|
33 | |
---|
34 | GLuint diffuseTexture; |
---|
35 | GLuint ambientTexture; |
---|
36 | GLuint specularTexture; |
---|
37 | |
---|
38 | bool diffuseTextureSet; |
---|
39 | bool ambientTextureSet; |
---|
40 | bool specularTextureSet; |
---|
41 | |
---|
42 | void setName (char* mtlName); |
---|
43 | char* getName (void); |
---|
44 | void setIllum (int illum); |
---|
45 | void setIllum (char* illum); |
---|
46 | void setDiffuse (float r, float g, float b); |
---|
47 | void setDiffuse (char* rgb); |
---|
48 | void setAmbient (float r, float g, float b); |
---|
49 | void setAmbient (char* rgb); |
---|
50 | void setSpecular (float r, float g, float b); |
---|
51 | void setSpecular (char* rgb); |
---|
52 | void setShininess (float shini); |
---|
53 | void setShininess (char* shini); |
---|
54 | void setTransparency (float trans); |
---|
55 | void setTransparency (char* trans); |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | // MAPPING // |
---|
61 | void setDiffuseMap(char* dMap); |
---|
62 | void setAmbientMap(char* aMap); |
---|
63 | void setSpecularMap(char* sMap); |
---|
64 | void setBump(char* bump); |
---|
65 | |
---|
66 | |
---|
67 | private: |
---|
68 | struct tImageJPG |
---|
69 | { |
---|
70 | int rowSpan; |
---|
71 | int sizeX; |
---|
72 | int sizeY; |
---|
73 | unsigned char *data; |
---|
74 | }; |
---|
75 | |
---|
76 | |
---|
77 | char* name; |
---|
78 | int illumModel; |
---|
79 | float diffuse [4]; |
---|
80 | float ambient [4]; |
---|
81 | float specular [4]; |
---|
82 | float shininess; |
---|
83 | float transparency; |
---|
84 | Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. |
---|
85 | |
---|
86 | // TEXTURING |
---|
87 | bool loadBMP (char* bmpName, GLuint* texture); |
---|
88 | bool loadJPG (char* jpgName, GLuint* texture); |
---|
89 | void decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData); |
---|
90 | }; |
---|
91 | #endif |
---|