Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/images: libPNG included, and also a routine to read it, but this one is not the best i Could find.

File size: 2.3 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// IMAGE LIBS //
18extern "C"{         // This has to be done, because not a c++ lib
19#include <jpeglib.h>
20}
21#include <png.h>
22//! Class to handle Materials.
23class Material
24{
25 public:
26  Material ();
27  Material (char* mtlName);
28  Material* addMaterial(char* mtlName);
29  ~Material ();
30  void init(void);
31
32  Material* search (char* mtlName);
33  bool select (void);
34
35  void setName (char* mtlName);
36  char* getName (void);
37  void setIllum (int illum);
38  void setIllum (char* illum);
39  void setDiffuse (float r, float g, float b);
40  void setDiffuse (char* rgb);
41  void setAmbient (float r, float g, float b);
42  void setAmbient (char* rgb);
43  void setSpecular (float r, float g, float b);
44  void setSpecular (char* rgb);
45  void setShininess (float shini);
46  void setShininess (char* shini);
47  void setTransparency (float trans);
48  void setTransparency (char* trans);
49
50
51
52
53  // MAPPING //
54  void setDiffuseMap(char* dMap);
55  void setAmbientMap(char* aMap);
56  void setSpecularMap(char* sMap);
57  void setBump(char* bump);
58
59
60 private:
61  struct Image
62  {
63    int rowSpan;
64    GLuint width;
65    GLuint height;
66    GLuint bpp;
67    GLuint type;
68    GLubyte *data;
69  };
70
71
72  char* name;
73  int illumModel;
74  float diffuse [4];
75  float ambient [4];
76  float specular [4];
77  float shininess;
78  float transparency;
79
80  GLuint diffuseTexture;
81  GLuint ambientTexture;
82  GLuint specularTexture;
83 
84  bool diffuseTextureSet;
85  bool ambientTextureSet;
86  bool specularTextureSet;
87
88  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
89
90  // TEXTURING
91  bool loadTexToGL (Image* pImage, GLuint* texture);
92
93  bool loadImage(char* imageName, GLuint* texture);
94
95  bool loadBMP (char* bmpName, GLuint* texture);
96
97  bool loadJPG (char* jpgName, GLuint* texture);
98
99  /// TGA ///
100
101  bool loadTGA(const char * tgaName, GLuint* texture);
102  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
103  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
104
105  bool loadPNG(const char* pngName, GLuint* texture);
106};
107#endif
Note: See TracBrowser for help on using the repository browser.