Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/importer/material.h @ 3184

Last change on this file since 3184 was 3184, checked in by bensch, 19 years ago

orxonox/trunk: osX-compatibility

File size: 2.8 KB
Line 
1/*!
2  \file material.h
3  \brief Contains the Material Class that handles Material for 3D-Objects.
4*/
5
6#ifndef _MATERIAL_H
7#define _MATERIAL_H
8
9extern int verbose; //!< will be obsolete soon.
10
11#include "stdincl.h"
12
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
22extern "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
31class 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
44//! Class to handle Materials.
45class Material
46{
47 public:
48  Material ();
49  Material (char* mtlName);
50  Material* addMaterial(char* mtlName);
51  ~Material ();
52  void init(void);
53
54  Material* search (char* mtlName);
55  bool select (void);
56
57  void setName (char* mtlName);
58  char* getName (void);
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);
67  void setShininess (float shini);
68  void setShininess (char* shini);
69  void setTransparency (float trans);
70  void setTransparency (char* trans);
71
72
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);
81
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  };
92
93
94  char* name;
95  int illumModel;
96  float diffuse [4];
97  float ambient [4];
98  float specular [4];
99  float shininess;
100  float transparency;
101
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
132};
133#endif
Note: See TracBrowser for help on using the repository browser.