Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/importer/material.h @ 3272

Last change on this file since 3272 was 3196, checked in by bensch, 20 years ago

orxonox/trunk: moved importer into the Trunk, now no merging is needed anymore.

File size: 4.1 KB
RevLine 
[2842]1/*!
2  \file material.h
3  \brief Contains the Material Class that handles Material for 3D-Objects.
[3186]4  \todo free SDL-surface when deleting Material.
5  \todo delete imgNameWithPath after use creation.
[2842]6*/
7
[2776]8#ifndef _MATERIAL_H
9#define _MATERIAL_H
[2804]10
[3186]11
12
[2842]13extern int verbose; //!< will be obsolete soon.
[2804]14
[3196]15#include "../stdincl.h"
[2776]16
[3140]17#if HAVE_CONFIG_H
18#include <config.h> 
19#endif /* HAVE_CONFIG_H */
20
21#ifdef HAVE_SDL_SDL_IMAGE_H
22#include <SDL/SDL_image.h>
[3178]23#else
[3140]24// IMAGE LIBS //
25#ifdef HAVE_JPEGLIB_H
26extern "C"{         // This has to be done, because not a c++ lib
27#include <jpeglib.h>
28}
29#endif /* HAVE_JPEGLIB_H */
30#ifdef HAVE_PNG_H
31#include <png.h>
32#endif /* HAVE_PNG_H */
[3178]33#endif /* HAVE_SDL_SDL_IMAGE_H */
[3140]34
[3186]35//! Class to handle lists of paths.
36/**
37   \todo Ability to return Paths by itself.
38
39   It is simple to use, and good, for all PathList you want.
40   just create a new Pathlist, and add Paths.
41*/
[3140]42class PathList
43{
44 public:
45  PathList();
46  PathList(char* pName);
47
48  ~PathList();
49  void addPath (char* pName);
[3186]50  char* pathName;          //!< The Name of the current Path.
51  PathList* next;          //!< Pointer to the next Pathlist.
[3140]52};
53
54
[2842]55//! Class to handle Materials.
[2776]56class Material
57{
58 public:
59  Material ();
60  Material (char* mtlName);
[2778]61  Material* addMaterial(char* mtlName);
[3140]62  ~Material ();
[2776]63  void init(void);
[2778]64
[3140]65  Material* search (char* mtlName);
66  bool select (void);
[2778]67
[2776]68  void setName (char* mtlName);
[2778]69  char* getName (void);
[2776]70  void setIllum (int illum);
71  void setIllum (char* illum);
72  void setDiffuse (float r, float g, float b);
73  void setDiffuse (char* rgb);
74  void setAmbient (float r, float g, float b);
75  void setAmbient (char* rgb);
76  void setSpecular (float r, float g, float b);
77  void setSpecular (char* rgb);
[2836]78  void setShininess (float shini);
79  void setShininess (char* shini);
[2776]80  void setTransparency (float trans);
81  void setTransparency (char* trans);
82
[3140]83
84 
85  void addTexturePath(char* pathName);
86  char* searchTextureInPaths(char* texName) const;
87 // MAPPING //
[3070]88  void setDiffuseMap(char* dMap);
89  void setAmbientMap(char* aMap);
90  void setSpecularMap(char* sMap);
91  void setBump(char* bump);
92
[3140]93 private:
[3186]94  //! Struct to handle Infos about an Image
[3140]95  struct Image
96  {
[3186]97    int rowSpan;    //!< The count of the rows this Image has.
98    GLuint width;   //!< The width of the Image.
99    GLuint height;  //!< The height of the Image.
100    GLuint bpp;     //!< BitsPerPixel
101    GLuint type;    //!< Type of the Image.
102    GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data.
[3140]103  };
[3070]104
105
[3186]106  char* name;        //!< The Name of the Material.
107  int illumModel;    //!< The IlluminationModel is either flat or smooth.
108  float diffuse [4]; //!< The diffuse color of the Material.
109  float ambient [4]; //!< The ambient color of the Material.
110  float specular [4];//!< The specular color of the Material.
111  float shininess;   //!< The shininess of the Material.
112  float transparency;//!< The transperency of the Material.
[2776]113
[3186]114  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.
[3140]115 
[3186]116  GLuint diffuseTexture; //!< The diffuse texture of the Material.
117  GLuint ambientTexture; //!< The ambient texture of the Material.
118  GLuint specularTexture;//!< The specular texture of the Material.
[3140]119 
[3186]120  bool diffuseTextureSet; //!< Chekcs if the diffuse texture is Set.
121  bool ambientTextureSet; //!< Chekcs if the ambient texture is Set.
122  bool specularTextureSet;//!< Chekcs if the specular texture is Set.
[3140]123
124  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
125
126  // TEXTURING
127  bool loadTexToGL (Image* pImage, GLuint* texture);
128
129  bool loadImage(char* imageName, GLuint* texture);
[3178]130#ifndef HAVE_SDL_SDL_IMAGE_H
[3140]131
132  bool loadBMP (char* bmpName, GLuint* texture);
133
134  bool loadJPG (char* jpgName, GLuint* texture);
135
136  /// TGA ///
137
138  bool loadTGA(const char * tgaName, GLuint* texture);
139  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
140  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
141
142  bool loadPNG(const char* pngName, GLuint* texture);
143#endif
[2776]144};
145#endif
Note: See TracBrowser for help on using the repository browser.