Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3128 was 3127, checked in by bensch, 20 years ago

orxonox/branches/images: Implemented a Way to read in the Files from any Directory.

  1. New Class created: PathList, handles lists of Paths (patrick… i really think this list is so small, that it does not make sense to use the list.h instead)
  2. Implemented it so it works. (windows-users should now be able to drag a file onto the importer, and it displays the file with all the maps and textures on it, if they are in the same directory as the obj-file)
File size: 2.8 KB
RevLine 
[2842]1/*!
2  \file material.h
3  \brief Contains the Material Class that handles Material for 3D-Objects.
4*/
5
[2776]6#ifndef _MATERIAL_H
7#define _MATERIAL_H
[2804]8
[2842]9extern int verbose; //!< will be obsolete soon.
[2804]10
[2776]11#include <GL/gl.h>
12#include <GL/glu.h>
[3070]13#include <SDL/SDL.h>
[2776]14
[3103]15#if HAVE_CONFIG_H
16#include <config.h> 
[3110]17#endif /* HAVE_CONFIG_H */
[3103]18
19#ifdef HAVE_SDL_SDL_IMAGE_H
20#include <SDL/SDL_image.h>
[3104]21#else
[3085]22// IMAGE LIBS //
[3110]23#ifdef HAVE_JPEGLIB_H
[3086]24extern "C"{         // This has to be done, because not a c++ lib
[3085]25#include <jpeglib.h>
[3086]26}
[3110]27#endif /* HAVE_JPEGLIB_H */
28#ifdef HAVE_PNG_H
[3098]29#include <png.h>
[3110]30#endif /* HAVE_PNG_H */
31#endif /* HAVE_SDL_SDL_IMAGE_H */
[3104]32
[3127]33class PathList
34{
35 public:
36  PathList();
37  PathList(char* pName);
38
39  ~PathList();
40  void addPath (char* pName);
41  char* pathName;
42  PathList* next;
43};
44
45
[2842]46//! Class to handle Materials.
[2776]47class Material
48{
49 public:
50  Material ();
51  Material (char* mtlName);
[2778]52  Material* addMaterial(char* mtlName);
[3085]53  ~Material ();
[2776]54  void init(void);
[2778]55
[3085]56  Material* search (char* mtlName);
57  bool select (void);
58
[2776]59  void setName (char* mtlName);
[2778]60  char* getName (void);
[2776]61  void setIllum (int illum);
62  void setIllum (char* illum);
63  void setDiffuse (float r, float g, float b);
64  void setDiffuse (char* rgb);
65  void setAmbient (float r, float g, float b);
66  void setAmbient (char* rgb);
67  void setSpecular (float r, float g, float b);
68  void setSpecular (char* rgb);
[2836]69  void setShininess (float shini);
70  void setShininess (char* shini);
[2776]71  void setTransparency (float trans);
72  void setTransparency (char* trans);
73
[3085]74
[3127]75 
76  void addTexturePath(char* pathName);
77  char* searchTextureInPaths(char* texName) const;
78 // MAPPING //
[3070]79  void setDiffuseMap(char* dMap);
80  void setAmbientMap(char* aMap);
81  void setSpecularMap(char* sMap);
82  void setBump(char* bump);
83
[2776]84 private:
[3090]85  struct Image
[3086]86  {
87    int rowSpan;
[3094]88    GLuint width;
89    GLuint height;
90    GLuint bpp;
91    GLuint type;
[3089]92    GLubyte *data;
[3086]93  };
94
95
[3069]96  char* name;
[2776]97  int illumModel;
[2780]98  float diffuse [4];
99  float ambient [4];
100  float specular [4];
[2836]101  float shininess;
[2776]102  float transparency;
[3093]103
[3127]104  static PathList* pathList;
105 
[3093]106  GLuint diffuseTexture;
107  GLuint ambientTexture;
108  GLuint specularTexture;
109 
110  bool diffuseTextureSet;
111  bool ambientTextureSet;
112  bool specularTextureSet;
113
[3085]114  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
[2776]115
[3086]116  // TEXTURING
[3094]117  bool loadTexToGL (Image* pImage, GLuint* texture);
118
[3087]119  bool loadImage(char* imageName, GLuint* texture);
[3103]120#ifndef HAVE_SDL_SDL_IMAGE_H
[3087]121
[3086]122  bool loadBMP (char* bmpName, GLuint* texture);
[3087]123
[3086]124  bool loadJPG (char* jpgName, GLuint* texture);
[3089]125
[3094]126  /// TGA ///
127
128  bool loadTGA(const char * tgaName, GLuint* texture);
129  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
[3096]130  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
[3094]131
[3098]132  bool loadPNG(const char* pngName, GLuint* texture);
[3103]133#endif
[2776]134};
135#endif
Note: See TracBrowser for help on using the repository browser.