Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TextureInfo Class Reference

#include <texmanager.h>

Inheritance diagram for TextureInfo:

Inheritance graph
Collaboration diagram for TextureInfo:

Collaboration graph
List of all members.

Public Types

enum  {
  WrapTexture = 0x1, CompressTexture = 0x2, NoMipMaps = 0x4, AutoMipMaps = 0x8,
  AllowSplitting = 0x10, BorderClamp = 0x20
}

Public Member Functions

virtual Textureload (const std::string &)
virtual std::string resolve (const std::string &)
 TextureInfo (const std::string _source, unsigned int _flags, unsigned int _resolution=medres)
 TextureInfo (const std::string _source, const std::string _path, float _bumpHeight, unsigned int _flags, unsigned int _resolution=medres)
 TextureInfo (const std::string _source, const std::string _path, unsigned int _flags, unsigned int _resolution=medres)

Public Attributes

float bumpHeight
unsigned int flags
std::string path
unsigned int resolution
std::string source

Member Enumeration Documentation

anonymous enum
 

Enumeration values:
WrapTexture 
CompressTexture 
NoMipMaps 
AutoMipMaps 
AllowSplitting 
BorderClamp 

Definition at line 29 of file texmanager.h.

00029          {
00030         WrapTexture      = 0x1,
00031         CompressTexture  = 0x2,
00032         NoMipMaps        = 0x4,
00033         AutoMipMaps      = 0x8,
00034         AllowSplitting   = 0x10,
00035         BorderClamp      = 0x20,
00036     };


Constructor & Destructor Documentation

TextureInfo::TextureInfo const std::string  _source,
const std::string  _path,
unsigned int  _flags,
unsigned int  _resolution = medres
[inline]
 

Definition at line 38 of file texmanager.h.

References bumpHeight, flags, path, resolution, and source.

00041                                                    :
00042         source(_source),
00043         path(_path),
00044         flags(_flags),
00045         bumpHeight(0.0f),
00046         resolution(_resolution) {};

TextureInfo::TextureInfo const std::string  _source,
const std::string  _path,
float  _bumpHeight,
unsigned int  _flags,
unsigned int  _resolution = medres
[inline]
 

Definition at line 48 of file texmanager.h.

References bumpHeight, flags, path, resolution, and source.

00052                                                    :
00053         source(_source),
00054         path(_path),
00055         flags(_flags),
00056         bumpHeight(_bumpHeight),
00057         resolution(_resolution) {};

TextureInfo::TextureInfo const std::string  _source,
unsigned int  _flags,
unsigned int  _resolution = medres
[inline]
 

Definition at line 59 of file texmanager.h.

References bumpHeight, flags, path, resolution, and source.

00061                                                    :
00062         source(_source),
00063         path(""),
00064         flags(_flags),
00065         bumpHeight(0.0f),
00066         resolution(_resolution) {};


Member Function Documentation

Texture * TextureInfo::load const std::string  )  [virtual]
 

Implements ResourceInfo< Texture >.

Definition at line 111 of file texmanager.cpp.

References AutoMipMaps, BorderClamp, bumpHeight, DPRINTF, flags, LoadHeightMapFromFile(), LoadTextureFromFile(), NoMipMaps, and WrapTexture.

00112 {
00113     Texture::AddressMode addressMode = Texture::EdgeClamp;
00114     Texture::MipMapMode mipMode = Texture::DefaultMipMaps;
00115 
00116     if (flags & WrapTexture)
00117         addressMode = Texture::Wrap;
00118     else if (flags & BorderClamp)
00119         addressMode = Texture::BorderClamp;
00120 
00121     if (flags & NoMipMaps)
00122         mipMode = Texture::NoMipMaps;
00123     else if (flags & AutoMipMaps)
00124         mipMode = Texture::AutoMipMaps;
00125 
00126     if (bumpHeight == 0.0f)
00127     {
00128         DPRINTF(0, "Loading texture: %s\n", name.c_str());
00129         // cout << "Loading texture: " << name << '\n';
00130 
00131         return LoadTextureFromFile(name, addressMode, mipMode);
00132     }
00133     else
00134     {
00135         DPRINTF(0, "Loading bump map: %s\n", name.c_str());
00136         // cout << "Loading texture: " << name << '\n';
00137 
00138         return LoadHeightMapFromFile(name, bumpHeight, addressMode);
00139     }
00140 
00141     return NULL;
00142 }

string TextureInfo::resolve const std::string  )  [virtual]
 

Implements ResourceInfo< Texture >.

Definition at line 71 of file texmanager.cpp.

References directories, path, resolution, resolveWildcard(), and source.

00072 {
00073     bool wildcard = false;
00074     if (!source.empty() && source.at(source.length() - 1) == '*')
00075         wildcard = true;
00076 
00077     if (!path.empty())
00078     {
00079         string filename = path + "/textures" + directories[resolution] + source;
00080         // cout << "Resolve: testing [" << filename << "]\n";
00081         if (wildcard)
00082         {
00083             filename = resolveWildcard(filename);
00084             if (!filename.empty())
00085                 return filename;
00086         }
00087         else
00088         {
00089             ifstream in(filename.c_str());
00090             if (in.good())
00091                 return filename;
00092         }
00093     }
00094 
00095     string filename = baseDir + directories[resolution] + source;
00096     if (wildcard)
00097     {
00098         string matched = resolveWildcard(filename);
00099         if (matched.empty())
00100             return filename; // . . . for lack of any better way to handle it.
00101         else
00102             return matched;
00103     }
00104     else
00105     {
00106         return filename;
00107     }
00108 }


Member Data Documentation

float TextureInfo::bumpHeight
 

Definition at line 26 of file texmanager.h.

Referenced by load(), and TextureInfo().

unsigned int TextureInfo::flags
 

Definition at line 25 of file texmanager.h.

Referenced by load(), and TextureInfo().

std::string TextureInfo::path
 

Definition at line 24 of file texmanager.h.

Referenced by resolve(), and TextureInfo().

unsigned int TextureInfo::resolution
 

Definition at line 27 of file texmanager.h.

Referenced by resolve(), and TextureInfo().

std::string TextureInfo::source
 

Definition at line 23 of file texmanager.h.

Referenced by resolve(), TextureInfo(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:39 2006 for Celestia by  doxygen 1.4.1