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