Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/updater/src/importer/material.h @ 3303

Last change on this file since 3303 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
Line 
1/*!
2  \file material.h
3  \brief Contains the Material Class that handles Material for 3D-Objects.
4  \todo free SDL-surface when deleting Material.
5  \todo delete imgNameWithPath after use creation.
6*/
7
8#ifndef _MATERIAL_H
9#define _MATERIAL_H
10
11
12
13extern int verbose; //!< will be obsolete soon.
14
15#include "../stdincl.h"
16
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>
23#else
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 */
33#endif /* HAVE_SDL_SDL_IMAGE_H */
34
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*/
42class PathList
43{
44 public:
45  PathList();
46  PathList(char* pName);
47
48  ~PathList();
49  void addPath (char* pName);
50  char* pathName;          //!< The Name of the current Path.
51  PathList* next;          //!< Pointer to the next Pathlist.
52};
53
54
55//! Class to handle Materials.
56class Material
57{
58 public:
59  Material ();
60  Material (char* mtlName);
61  Material* addMaterial(char* mtlName);
62  ~Material ();
63  void init(void);
64
65  Material* search (char* mtlName);
66  bool select (void);
67
68  void setName (char* mtlName);
69  char* getName (void);
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);
78  void setShininess (float shini);
79  void setShininess (char* shini);
80  void setTransparency (float trans);
81  void setTransparency (char* trans);
82
83
84 
85  void addTexturePath(char* pathName);
86  char* searchTextureInPaths(char* texName) const;
87 // MAPPING //
88  void setDiffuseMap(char* dMap);
89  void setAmbientMap(char* aMap);
90  void setSpecularMap(char* sMap);
91  void setBump(char* bump);
92
93 private:
94  //! Struct to handle Infos about an Image
95  struct Image
96  {
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.
103  };
104
105
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.
113
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.
115 
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.
119 
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.
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);
130#ifndef HAVE_SDL_SDL_IMAGE_H
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
144};
145#endif
Note: See TracBrowser for help on using the repository browser.