Modified Files:

simgear/scene/material/mat.cxx simgear/scene/material/mat.hxx:
	Olaf Flebbe: make anisotroüpic filtering configurable.
This commit is contained in:
frohlich
2007-04-21 12:13:16 +00:00
parent 436539a700
commit 784cca2233
2 changed files with 10 additions and 4 deletions
+6 -3
View File
@@ -141,6 +141,7 @@ SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props
wrapu = props->getBoolValue("wrapu", true); wrapu = props->getBoolValue("wrapu", true);
wrapv = props->getBoolValue("wrapv", true); wrapv = props->getBoolValue("wrapv", true);
mipmap = props->getBoolValue("mipmap", true); mipmap = props->getBoolValue("mipmap", true);
filtering = props->getDoubleValue("filtering", 1.0);
light_coverage = props->getDoubleValue("light-coverage", 0.0); light_coverage = props->getDoubleValue("light-coverage", 0.0);
// surface values for use with ground reactions // surface values for use with ground reactions
@@ -204,6 +205,7 @@ SGMaterial::init ()
wrapv = true; wrapv = true;
mipmap = true; mipmap = true;
filtering = 1.0f;
light_coverage = 0.0; light_coverage = 0.0;
solid = true; solid = true;
@@ -233,7 +235,7 @@ SGMaterial::load_texture ( int n )
SG_LOG( SG_GENERAL, SG_INFO, "Loading deferred texture " SG_LOG( SG_GENERAL, SG_INFO, "Loading deferred texture "
<< _status[i].texture_path ); << _status[i].texture_path );
assignTexture(_status[i].state.get(), _status[i].texture_path, assignTexture(_status[i].state.get(), _status[i].texture_path,
wrapu, wrapv, mipmap ); wrapu, wrapv, mipmap, filtering );
_status[i].texture_loaded = true; _status[i].texture_loaded = true;
} }
} }
@@ -279,7 +281,7 @@ SGMaterial::build_state( bool defer_tex_load )
if ( !defer_tex_load ) { if ( !defer_tex_load ) {
SG_LOG(SG_INPUT, SG_INFO, " " << _status[i].texture_path ); SG_LOG(SG_INPUT, SG_INFO, " " << _status[i].texture_path );
assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv ); assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv, 1, filtering );
_status[i].texture_loaded = true; _status[i].texture_loaded = true;
} else { } else {
_status[i].texture_loaded = false; _status[i].texture_loaded = false;
@@ -316,7 +318,7 @@ void SGMaterial::set_state( osg::StateSet *s )
} }
void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname, void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname,
int _wrapu, int _wrapv, int _mipmap ) int _wrapu, int _wrapv, int _mipmap, float filtering )
{ {
map<string, osg::ref_ptr<osg::Texture2D> >::iterator _tex_cache_iter; map<string, osg::ref_ptr<osg::Texture2D> >::iterator _tex_cache_iter;
_tex_cache_iter = _tex_cache.find(fname); _tex_cache_iter = _tex_cache.find(fname);
@@ -324,6 +326,7 @@ void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname,
{ {
osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv, osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv,
mipmap ? -1 : 0); mipmap ? -1 : 0);
texture->setMaxAnisotropy( filtering);
state->setTextureAttributeAndModes(0, texture); state->setTextureAttributeAndModes(0, texture);
_tex_cache[fname] = texture; _tex_cache[fname] = texture;
} }
+4 -1
View File
@@ -252,6 +252,9 @@ private:
// use mipmapping? // use mipmapping?
int mipmap; int mipmap;
// use anisotropic filtering
float filtering;
// coverage of night lighting. // coverage of night lighting.
double light_coverage; double light_coverage;
@@ -293,7 +296,7 @@ private:
void build_state( bool defer_tex_load ); void build_state( bool defer_tex_load );
void set_state( osg::StateSet *s ); void set_state( osg::StateSet *s );
void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE ); void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE, float filtering = 1.0f );
}; };