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