Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: finding sdl-image more flexible.

File size: 2.9 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 <GL/gl.h>
12#include <GL/glu.h>
13#include <SDL/SDL.h>
14
15#if HAVE_CONFIG_H
16#include <config.h> 
17#endif /* HAVE_CONFIG_H */
18
19#ifdef HAVE_SDL_SDL_IMAGE_H
20#include <SDL/SDL_image.h>
21#endif
22#ifdef HAVE_SDL_IMAGE_H
23#include <SDL_image.h>
24#endif
25
26#ifndef HAVE_SDL_IMAGE
27// IMAGE LIBS //
28#ifdef HAVE_JPEGLIB_H
29extern "C"{         // This has to be done, because not a c++ lib
30#include <jpeglib.h>
31}
32#endif /* HAVE_JPEGLIB_H */
33#ifdef HAVE_PNG_H
34#include <png.h>
35#endif /* HAVE_PNG_H */
36#endif /* HAVE_SDL_IMAGE */
37
38class PathList
39{
40 public:
41  PathList();
42  PathList(char* pName);
43
44  ~PathList();
45  void addPath (char* pName);
46  char* pathName;
47  PathList* next;
48};
49
50
51//! Class to handle Materials.
52class Material
53{
54 public:
55  Material ();
56  Material (char* mtlName);
57  Material* addMaterial(char* mtlName);
58  ~Material ();
59  void init(void);
60
61  Material* search (char* mtlName);
62  bool select (void);
63
64  void setName (char* mtlName);
65  char* getName (void);
66  void setIllum (int illum);
67  void setIllum (char* illum);
68  void setDiffuse (float r, float g, float b);
69  void setDiffuse (char* rgb);
70  void setAmbient (float r, float g, float b);
71  void setAmbient (char* rgb);
72  void setSpecular (float r, float g, float b);
73  void setSpecular (char* rgb);
74  void setShininess (float shini);
75  void setShininess (char* shini);
76  void setTransparency (float trans);
77  void setTransparency (char* trans);
78
79
80 
81  void addTexturePath(char* pathName);
82  char* searchTextureInPaths(char* texName) const;
83 // MAPPING //
84  void setDiffuseMap(char* dMap);
85  void setAmbientMap(char* aMap);
86  void setSpecularMap(char* sMap);
87  void setBump(char* bump);
88
89 private:
90  struct Image
91  {
92    int rowSpan;
93    GLuint width;
94    GLuint height;
95    GLuint bpp;
96    GLuint type;
97    GLubyte *data;
98  };
99
100
101  char* name;
102  int illumModel;
103  float diffuse [4];
104  float ambient [4];
105  float specular [4];
106  float shininess;
107  float transparency;
108
109  static PathList* pathList;
110 
111  GLuint diffuseTexture;
112  GLuint ambientTexture;
113  GLuint specularTexture;
114 
115  bool diffuseTextureSet;
116  bool ambientTextureSet;
117  bool specularTextureSet;
118
119  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
120
121  // TEXTURING
122  bool loadTexToGL (Image* pImage, GLuint* texture);
123
124  bool loadImage(char* imageName, GLuint* texture);
125#ifndef HAVE_SDL_IMAGE
126
127  bool loadBMP (char* bmpName, GLuint* texture);
128
129  bool loadJPG (char* jpgName, GLuint* texture);
130
131  /// TGA ///
132
133  bool loadTGA(const char * tgaName, GLuint* texture);
134  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
135  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
136
137  bool loadPNG(const char* pngName, GLuint* texture);
138#endif
139};
140#endif
Note: See TracBrowser for help on using the repository browser.