/*! \file material.h \brief Contains the Material Class that handles Material for 3D-Objects. \todo free SDL-surface when deleting Material. \todo delete imgNameWithPath after use creation. */ #ifndef _MATERIAL_H #define _MATERIAL_H extern int verbose; //!< will be obsolete soon. #include "../stdincl.h" #if HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #ifdef HAVE_SDL_SDL_IMAGE_H #include #else // IMAGE LIBS // #ifdef HAVE_JPEGLIB_H extern "C"{ // This has to be done, because not a c++ lib #include } #endif /* HAVE_JPEGLIB_H */ #ifdef HAVE_PNG_H #include #endif /* HAVE_PNG_H */ #endif /* HAVE_SDL_SDL_IMAGE_H */ //! Class to handle lists of paths. /** \todo Ability to return Paths by itself. It is simple to use, and good, for all PathList you want. just create a new Pathlist, and add Paths. */ class PathList { public: PathList(); PathList(char* pName); ~PathList(); void addPath (char* pName); char* pathName; //!< The Name of the current Path. PathList* next; //!< Pointer to the next Pathlist. }; //! Class to handle Materials. class Material { public: Material (); Material (char* mtlName); Material* addMaterial(char* mtlName); ~Material (); void init(void); Material* search (char* mtlName); bool select (void); void setName (char* mtlName); char* getName (void); void setIllum (int illum); void setIllum (char* illum); void setDiffuse (float r, float g, float b); void setDiffuse (char* rgb); void setAmbient (float r, float g, float b); void setAmbient (char* rgb); void setSpecular (float r, float g, float b); void setSpecular (char* rgb); void setShininess (float shini); void setShininess (char* shini); void setTransparency (float trans); void setTransparency (char* trans); void addTexturePath(char* pathName); char* searchTextureInPaths(char* texName) const; // MAPPING // void setDiffuseMap(char* dMap); void setAmbientMap(char* aMap); void setSpecularMap(char* sMap); void setBump(char* bump); private: //! Struct to handle Infos about an Image struct Image { int rowSpan; //!< The count of the rows this Image has. GLuint width; //!< The width of the Image. GLuint height; //!< The height of the Image. GLuint bpp; //!< BitsPerPixel GLuint type; //!< Type of the Image. GLubyte *data; //!< The Image Data comes here! DANGER: uncompressed data. }; char* name; //!< The Name of the Material. int illumModel; //!< The IlluminationModel is either flat or smooth. float diffuse [4]; //!< The diffuse color of the Material. float ambient [4]; //!< The ambient color of the Material. float specular [4];//!< The specular color of the Material. float shininess; //!< The shininess of the Material. float transparency;//!< The transperency of the Material. static PathList* pathList; //!< A pointer to the first element of Pathlist. This is static, because pathlists are global \todo copy this to the Globals.h or DataTank for deletion at the end. GLuint diffuseTexture; //!< The diffuse texture of the Material. GLuint ambientTexture; //!< The ambient texture of the Material. GLuint specularTexture;//!< The specular texture of the Material. bool diffuseTextureSet; //!< Chekcs if the diffuse texture is Set. bool ambientTextureSet; //!< Chekcs if the ambient texture is Set. bool specularTextureSet;//!< Chekcs if the specular texture is Set. Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. // TEXTURING bool loadTexToGL (Image* pImage, GLuint* texture); bool loadImage(char* imageName, GLuint* texture); #ifndef HAVE_SDL_SDL_IMAGE_H bool loadBMP (char* bmpName, GLuint* texture); bool loadJPG (char* jpgName, GLuint* texture); /// TGA /// bool loadTGA(const char * tgaName, GLuint* texture); bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); bool loadPNG(const char* pngName, GLuint* texture); #endif }; #endif