[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 | |
---|
[2776] | 34 | void setName (char* mtlName); |
---|
[2778] | 35 | char* getName (void); |
---|
[2776] | 36 | void setIllum (int illum); |
---|
| 37 | void setIllum (char* illum); |
---|
| 38 | void setDiffuse (float r, float g, float b); |
---|
| 39 | void setDiffuse (char* rgb); |
---|
| 40 | void setAmbient (float r, float g, float b); |
---|
| 41 | void setAmbient (char* rgb); |
---|
| 42 | void setSpecular (float r, float g, float b); |
---|
| 43 | void setSpecular (char* rgb); |
---|
[2836] | 44 | void setShininess (float shini); |
---|
| 45 | void setShininess (char* shini); |
---|
[2776] | 46 | void setTransparency (float trans); |
---|
| 47 | void setTransparency (char* trans); |
---|
| 48 | |
---|
[3085] | 49 | |
---|
| 50 | |
---|
| 51 | |
---|
[3070] | 52 | // MAPPING // |
---|
| 53 | void setDiffuseMap(char* dMap); |
---|
| 54 | void setAmbientMap(char* aMap); |
---|
| 55 | void setSpecularMap(char* sMap); |
---|
| 56 | void setBump(char* bump); |
---|
| 57 | |
---|
| 58 | |
---|
[2776] | 59 | private: |
---|
[3090] | 60 | struct Image |
---|
[3086] | 61 | { |
---|
| 62 | int rowSpan; |
---|
[3094] | 63 | GLuint width; |
---|
| 64 | GLuint height; |
---|
| 65 | GLuint bpp; |
---|
| 66 | GLuint type; |
---|
[3089] | 67 | GLubyte *data; |
---|
[3086] | 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
[3069] | 71 | char* name; |
---|
[2776] | 72 | int illumModel; |
---|
[2780] | 73 | float diffuse [4]; |
---|
| 74 | float ambient [4]; |
---|
| 75 | float specular [4]; |
---|
[2836] | 76 | float shininess; |
---|
[2776] | 77 | float transparency; |
---|
[3093] | 78 | |
---|
| 79 | GLuint diffuseTexture; |
---|
| 80 | GLuint ambientTexture; |
---|
| 81 | GLuint specularTexture; |
---|
| 82 | |
---|
| 83 | bool diffuseTextureSet; |
---|
| 84 | bool ambientTextureSet; |
---|
| 85 | bool specularTextureSet; |
---|
| 86 | |
---|
[3085] | 87 | Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. |
---|
[2776] | 88 | |
---|
[3086] | 89 | // TEXTURING |
---|
[3094] | 90 | bool loadTexToGL (Image* pImage, GLuint* texture); |
---|
| 91 | |
---|
[3087] | 92 | bool loadImage(char* imageName, GLuint* texture); |
---|
| 93 | |
---|
[3086] | 94 | bool loadBMP (char* bmpName, GLuint* texture); |
---|
[3087] | 95 | |
---|
[3086] | 96 | bool loadJPG (char* jpgName, GLuint* texture); |
---|
[3089] | 97 | |
---|
[3094] | 98 | /// TGA /// |
---|
| 99 | |
---|
| 100 | bool loadTGA(const char * tgaName, GLuint* texture); |
---|
| 101 | bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
[3096] | 102 | bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); |
---|
[3094] | 103 | |
---|
[2776] | 104 | }; |
---|
| 105 | #endif |
---|