[2842] | 1 | /*! |
---|
| 2 | \file material.h |
---|
| 3 | \brief Contains the Material Class that handles Material for 3D-Objects. |
---|
| 4 | */ |
---|
| 5 | |
---|
[2776] | 6 | #ifndef _MATERIAL_H |
---|
| 7 | #define _MATERIAL_H |
---|
[2804] | 8 | |
---|
[2842] | 9 | extern int verbose; //!< will be obsolete soon. |
---|
[2804] | 10 | |
---|
[2776] | 11 | #include <GL/gl.h> |
---|
| 12 | #include <GL/glu.h> |
---|
[3070] | 13 | #include <SDL/SDL.h> |
---|
[2776] | 14 | #include <stdlib.h> |
---|
[2823] | 15 | #include <fstream> |
---|
[2776] | 16 | |
---|
[3085] | 17 | // IMAGE LIBS // |
---|
[3086] | 18 | extern "C"{ // This has to be done, because not a c++ lib |
---|
[3085] | 19 | #include <jpeglib.h> |
---|
[3086] | 20 | } |
---|
[2842] | 21 | //! Class to handle Materials. |
---|
[2776] | 22 | class Material |
---|
| 23 | { |
---|
| 24 | public: |
---|
| 25 | Material (); |
---|
| 26 | Material (char* mtlName); |
---|
[2778] | 27 | Material* addMaterial(char* mtlName); |
---|
[3085] | 28 | ~Material (); |
---|
[2776] | 29 | void init(void); |
---|
[2778] | 30 | |
---|
[3085] | 31 | Material* search (char* mtlName); |
---|
| 32 | bool select (void); |
---|
| 33 | |
---|
[3070] | 34 | GLuint diffuseTexture; |
---|
| 35 | GLuint ambientTexture; |
---|
| 36 | GLuint specularTexture; |
---|
| 37 | |
---|
| 38 | bool diffuseTextureSet; |
---|
| 39 | bool ambientTextureSet; |
---|
| 40 | bool specularTextureSet; |
---|
[2778] | 41 | |
---|
[2776] | 42 | void setName (char* mtlName); |
---|
[2778] | 43 | char* getName (void); |
---|
[2776] | 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); |
---|
[2836] | 52 | void setShininess (float shini); |
---|
| 53 | void setShininess (char* shini); |
---|
[2776] | 54 | void setTransparency (float trans); |
---|
| 55 | void setTransparency (char* trans); |
---|
| 56 | |
---|
[3085] | 57 | |
---|
| 58 | |
---|
| 59 | |
---|
[3070] | 60 | // MAPPING // |
---|
| 61 | void setDiffuseMap(char* dMap); |
---|
| 62 | void setAmbientMap(char* aMap); |
---|
| 63 | void setSpecularMap(char* sMap); |
---|
| 64 | void setBump(char* bump); |
---|
| 65 | |
---|
| 66 | |
---|
[2776] | 67 | private: |
---|
[3086] | 68 | struct tImageJPG |
---|
| 69 | { |
---|
| 70 | int rowSpan; |
---|
| 71 | int sizeX; |
---|
| 72 | int sizeY; |
---|
| 73 | unsigned char *data; |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | |
---|
[3069] | 77 | char* name; |
---|
[2776] | 78 | int illumModel; |
---|
[2780] | 79 | float diffuse [4]; |
---|
| 80 | float ambient [4]; |
---|
| 81 | float specular [4]; |
---|
[2836] | 82 | float shininess; |
---|
[2776] | 83 | float transparency; |
---|
[3085] | 84 | Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. |
---|
[2776] | 85 | |
---|
[3086] | 86 | // TEXTURING |
---|
[3087] | 87 | bool loadImage(char* imageName, GLuint* texture); |
---|
| 88 | |
---|
[3086] | 89 | bool loadBMP (char* bmpName, GLuint* texture); |
---|
[3087] | 90 | |
---|
[3086] | 91 | bool loadJPG (char* jpgName, GLuint* texture); |
---|
| 92 | void decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData); |
---|
[2776] | 93 | }; |
---|
| 94 | #endif |
---|