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