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