Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/images/importer/material.h @ 3121

Last change on this file since 3121 was 3110, checked in by bensch, 20 years ago

orxonox/branches/images: test for jpeg and png libs in configure.ac and material.cc/h

File size: 2.6 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#include <stdlib.h>
15#include <fstream>
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 Materials.
36class Material
37{
38 public:
39  Material ();
40  Material (char* mtlName);
41  Material* addMaterial(char* mtlName);
42  ~Material ();
43  void init(void);
44
45  Material* search (char* mtlName);
46  bool select (void);
47
48  void setName (char* mtlName);
49  char* getName (void);
50  void setIllum (int illum);
51  void setIllum (char* illum);
52  void setDiffuse (float r, float g, float b);
53  void setDiffuse (char* rgb);
54  void setAmbient (float r, float g, float b);
55  void setAmbient (char* rgb);
56  void setSpecular (float r, float g, float b);
57  void setSpecular (char* rgb);
58  void setShininess (float shini);
59  void setShininess (char* shini);
60  void setTransparency (float trans);
61  void setTransparency (char* trans);
62
63
64
65
66  // MAPPING //
67  void setDiffuseMap(char* dMap);
68  void setAmbientMap(char* aMap);
69  void setSpecularMap(char* sMap);
70  void setBump(char* bump);
71
72
73 private:
74  struct Image
75  {
76    int rowSpan;
77    GLuint width;
78    GLuint height;
79    GLuint bpp;
80    GLuint type;
81    GLubyte *data;
82  };
83
84
85  char* name;
86  int illumModel;
87  float diffuse [4];
88  float ambient [4];
89  float specular [4];
90  float shininess;
91  float transparency;
92
93  GLuint diffuseTexture;
94  GLuint ambientTexture;
95  GLuint specularTexture;
96 
97  bool diffuseTextureSet;
98  bool ambientTextureSet;
99  bool specularTextureSet;
100
101  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
102
103  // TEXTURING
104  bool loadTexToGL (Image* pImage, GLuint* texture);
105
106  bool loadImage(char* imageName, GLuint* texture);
107#ifndef HAVE_SDL_SDL_IMAGE_H
108
109  bool loadBMP (char* bmpName, GLuint* texture);
110
111  bool loadJPG (char* jpgName, GLuint* texture);
112
113  /// TGA ///
114
115  bool loadTGA(const char * tgaName, GLuint* texture);
116  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
117  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
118
119  bool loadPNG(const char* pngName, GLuint* texture);
120#endif
121};
122#endif
Note: See TracBrowser for help on using the repository browser.