]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/mat.cxx
Canvas: fix element mouse hit detection with OSG 3.3.2.
[simgear.git] / simgear / scene / material / mat.cxx
1 // mat.cxx -- class to handle material properties
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998 - 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <simgear_config.h>
26 #endif
27
28 #include <simgear/compiler.h>
29
30 #include <string.h>
31 #include <map>
32 #include <vector>
33 #include <string>
34
35 #include <boost/foreach.hpp>
36 #include "mat.hxx"
37
38 #include <osg/CullFace>
39 #include <osg/Material>
40 #include <osg/ShadeModel>
41 #include <osg/StateSet>
42 #include <osg/TexEnv>
43 #include <osg/Texture>
44 #include <osg/Texture2D>
45 #include <osgDB/ReaderWriter>
46 #include <osgDB/ReadFile>
47 #include <osgDB/Registry>
48 #include <osgDB/FileUtils>
49
50 #include <simgear/debug/logstream.hxx>
51 #include <simgear/misc/sg_path.hxx>
52 #include <simgear/misc/sgstream.hxx>
53 #include <simgear/threads/SGGuard.hxx>
54
55 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
56 #include <simgear/props/props_io.hxx>
57 #include <simgear/props/vectorPropTemplates.hxx>
58 #include <simgear/scene/model/model.hxx>
59 #include <simgear/scene/material/matmodel.hxx>
60 #include <simgear/scene/util/RenderConstants.hxx>
61 #include <simgear/scene/util/StateAttributeFactory.hxx>
62 #include <simgear/props/condition.hxx>
63 #include <simgear/scene/util/SGSceneFeatures.hxx>
64 #include <simgear/scene/tgdb/SGTexturedTriangleBin.hxx>
65
66 #include "Effect.hxx"
67 #include "Technique.hxx"
68 #include "Pass.hxx"
69
70 using std::map;
71 using namespace simgear;
72
73 ////////////////////////////////////////////////////////////////////////
74 // Constructors and destructor.
75 ////////////////////////////////////////////////////////////////////////
76
77 SGMaterial::_internal_state::_internal_state(Effect *e, bool l,
78                                              const SGReaderWriterOptions* o)
79     : effect(e), effect_realized(l), options(o)
80 {
81 }
82
83 SGMaterial::_internal_state::_internal_state( Effect *e,
84                                               const std::string &t,
85                                               bool l,
86                                               const SGReaderWriterOptions* o )
87     : effect(e), effect_realized(l), options(o)
88 {
89     texture_paths.push_back(std::make_pair(t,0));
90 }
91
92 void SGMaterial::_internal_state::add_texture(const std::string &t, int i)
93 {
94     texture_paths.push_back(std::make_pair(t,i));
95 }
96
97 SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
98                         const SGPropertyNode *props,
99                         SGPropertyNode *prop_root,
100                         AreaList *a,
101                                                 SGSharedPtr<const SGCondition> c)
102 {
103     init();
104     areas = a;
105     condition = c;
106     read_properties( options, props, prop_root );
107     buildEffectProperties(options);
108 }
109
110 SGMaterial::SGMaterial( const osgDB::Options* options,
111                         const SGPropertyNode *props, 
112                         SGPropertyNode *prop_root,
113                         AreaList *a,
114                         SGSharedPtr<const SGCondition> c)
115 {
116     osg::ref_ptr<SGReaderWriterOptions> opt;
117     opt = SGReaderWriterOptions::copyOrCreate(options);
118     areas = a;
119     condition = c;
120     init();
121     read_properties(opt.get(), props, prop_root);
122     buildEffectProperties(opt.get());
123 }
124
125 SGMaterial::~SGMaterial (void)
126 {
127 }
128
129 \f
130 ////////////////////////////////////////////////////////////////////////
131 // Public methods.
132 ////////////////////////////////////////////////////////////////////////
133
134 void
135 SGMaterial::read_properties(const SGReaderWriterOptions* options,
136                             const SGPropertyNode *props,
137                             SGPropertyNode *prop_root)
138 {
139     std::vector<bool> dds;
140     std::vector<SGPropertyNode_ptr> textures = props->getChildren("texture");
141     for (unsigned int i = 0; i < textures.size(); i++)
142     {
143         std::string tname = textures[i]->getStringValue();
144
145         if (tname.empty()) {
146             tname = "unknown.rgb";
147         }
148
149         SGPath tpath("Textures.high");
150         tpath.append(tname);
151         std::string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
152         if (fullTexPath.empty()) {
153             tpath.set("Textures");
154             tpath.append(tname);
155             fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
156             if (fullTexPath.empty()) {
157                 SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \""
158                         << tname << "\" in Textures or Textures.high folders.");
159             }
160         }
161
162         if (tpath.lower_extension() == "dds") {
163             dds.push_back(true);
164         } else {
165             dds.push_back(false);
166         }
167
168         if (!fullTexPath.empty() ) {
169             _internal_state st( NULL, fullTexPath, false, options );
170             _status.push_back( st );
171         }
172     }
173
174     std::vector<SGPropertyNode_ptr> texturesets = props->getChildren("texture-set");
175     for (unsigned int i = 0; i < texturesets.size(); i++)
176     {
177         _internal_state st( NULL, false, options );
178         std::vector<SGPropertyNode_ptr> textures = texturesets[i]->getChildren("texture");
179         for (unsigned int j = 0; j < textures.size(); j++)
180         {
181             std::string tname = textures[j]->getStringValue();
182             if (tname.empty()) {
183                 tname = "unknown.rgb";
184             }
185
186             SGPath tpath("Textures.high");
187             tpath.append(tname);
188             std::string fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
189             if (fullTexPath.empty()) {
190                 tpath.set("Textures");
191                 tpath.append(tname);
192                 fullTexPath = SGModelLib::findDataFile(tpath.str(), options);
193                 if (fullTexPath.empty() ) {
194                     SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \""
195                             << tname << "\" in Textures or Textures.high folders.");
196                 }
197             }
198
199             if (j == 0) {
200                 if (tpath.lower_extension() == "dds") {
201                     dds.push_back(true);
202                 } else {
203                     dds.push_back(false);
204                 }
205             }
206
207             st.add_texture(fullTexPath, textures[j]->getIndex());
208         }
209
210         if (!st.texture_paths.empty() ) {
211             _status.push_back( st );
212         }
213     }
214
215     if (textures.empty() && texturesets.empty()) {
216         SGPath tpath("Textures");
217         tpath.append("Terrain");
218         tpath.append("unknown.rgb");
219         _internal_state st( NULL, tpath.str(), true, options );
220         _status.push_back( st );
221     }
222     
223     std::vector<SGPropertyNode_ptr> masks = props->getChildren("object-mask");
224     for (unsigned int i = 0; i < masks.size(); i++)
225     {
226         std::string omname = masks[i]->getStringValue();
227
228         if (! omname.empty()) {
229             SGPath ompath("Textures.high");
230             ompath.append(omname);
231             std::string fullMaskPath =
232               SGModelLib::findDataFile(ompath.str(), options);
233
234             if (fullMaskPath.empty()) {
235                 ompath.set("Textures");
236                 ompath.append(omname);
237                 fullMaskPath = SGModelLib::findDataFile(ompath.str(), options);
238             }
239
240             if (fullMaskPath.empty()) {
241                 SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \""
242                         << omname << "\" in Textures or Textures.high folders.");
243             }
244             else
245             {
246                 osg::Image* image = osgDB::readImageFile(fullMaskPath, options);
247                 if (image && image->valid())
248                 {
249                     Texture2DRef object_mask = new osg::Texture2D;
250
251                     bool dds_mask = (ompath.lower_extension() == "dds");
252
253                     if (i < dds.size() && dds[i] != dds_mask) {
254                         // Texture format does not match mask format. This is relevant for
255                         // the object mask, as DDS textures have an origin at the bottom
256                         // left rather than top left. Therefore we flip a copy of the image
257                         // (otherwise a second reference to the object mask would flip it
258                         // back!).                
259                         SG_LOG(SG_GENERAL, SG_DEBUG, "Flipping object mask" << omname);  
260                         image = (osg::Image* ) image->clone(osg::CopyOp::SHALLOW_COPY);
261                         image->flipVertical();
262                     }
263
264                     object_mask->setImage(image);
265
266                     // We force the filtering to be nearest, as the red channel (rotation)
267                     // in particular, doesn't make sense to be interpolated between pixels.
268                     object_mask->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);
269                     object_mask->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);
270
271                     object_mask->setDataVariance(osg::Object::STATIC);
272                     object_mask->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
273                     object_mask->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
274                     _masks.push_back(object_mask);
275                 }
276             }
277         }
278     }
279
280     xsize = props->getDoubleValue("xsize", 0.0);
281     ysize = props->getDoubleValue("ysize", 0.0);
282     wrapu = props->getBoolValue("wrapu", true);
283     wrapv = props->getBoolValue("wrapv", true);
284     mipmap = props->getBoolValue("mipmap", true);
285     light_coverage = props->getDoubleValue("light-coverage", 0.0);
286     
287     // Building properties
288     building_coverage = props->getDoubleValue("building-coverage", 0.0);
289     building_spacing = props->getDoubleValue("building-spacing-m", 5.0);
290     
291     std::string bt = props->getStringValue( "building-texture",
292                                             "Textures/buildings.png" );
293     building_texture = SGModelLib::findDataFile(bt, options);    
294     
295     if (building_texture.empty()) {
296         SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \"" << bt);
297     }
298     
299     bt = props->getStringValue("building-lightmap", "Textures/buildings-lightmap.png");
300     building_lightmap = SGModelLib::findDataFile(bt, options);    
301     
302     if (building_lightmap.empty()) {
303         SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \"" << bt);
304     }    
305             
306     building_small_ratio = props->getDoubleValue("building-small-ratio", 0.8);
307     building_medium_ratio = props->getDoubleValue("building-medium-ratio", 0.15);
308     building_large_ratio =  props->getDoubleValue("building-large-ratio", 0.05);
309     
310     building_small_pitch =  props->getDoubleValue("building-small-pitch", 0.8);
311     building_medium_pitch =  props->getDoubleValue("building-medium-pitch", 0.2);
312     building_large_pitch =  props->getDoubleValue("building-large-pitch", 0.1);
313
314     building_small_min_floors = props->getIntValue("building-small-min-floors", 1);
315     building_small_max_floors = props->getIntValue("building-small-max-floors", 3);
316     building_medium_min_floors = props->getIntValue("building-medium-min-floors", 3);
317     building_medium_max_floors = props->getIntValue("building-medium-max-floors", 8);
318     building_large_min_floors = props->getIntValue("building-large-min-floors", 5);
319     building_large_max_floors = props->getIntValue("building-large-max-floors", 20);
320     
321     building_small_min_width = props->getFloatValue("building-small-min-width-m", 15.0);
322     building_small_max_width = props->getFloatValue("building-small-max-width-m", 60.0);
323     building_small_min_depth = props->getFloatValue("building-small-min-depth-m", 10.0);
324     building_small_max_depth = props->getFloatValue("building-small-max-depth-m", 20.0);
325     
326     building_medium_min_width = props->getFloatValue("building-medium-min-width-m", 25.0);
327     building_medium_max_width = props->getFloatValue("building-medium-max-width-m", 50.0);
328     building_medium_min_depth = props->getFloatValue("building-medium-min-depth-m", 20.0);
329     building_medium_max_depth = props->getFloatValue("building-medium-max-depth-m", 50.0);
330     
331     building_large_min_width = props->getFloatValue("building-large-min-width-m", 50.0);
332     building_large_max_width = props->getFloatValue("building-large-max-width-m", 75.0);
333     building_large_min_depth = props->getFloatValue("building-large-min-depth-m", 50.0);
334     building_large_max_depth = props->getFloatValue("building-large-max-depth-m", 75.0);
335
336     building_range = props->getDoubleValue("building-range-m", 10000.0);
337     
338     cos_object_max_density_slope_angle  = cos(props->getFloatValue("object-max-density-angle-deg", 20.0) * osg::PI/180.0);
339     cos_object_zero_density_slope_angle = cos(props->getFloatValue("object-zero-density-angle-deg", 30.0) * osg::PI/180.0);
340         
341     // Random vegetation properties
342     wood_coverage = props->getDoubleValue("wood-coverage", 0.0);
343     tree_height = props->getDoubleValue("tree-height-m", 0.0);
344     tree_width = props->getDoubleValue("tree-width-m", 0.0);
345     tree_range = props->getDoubleValue("tree-range-m", 0.0);
346     tree_varieties = props->getIntValue("tree-varieties", 1);
347     cos_tree_max_density_slope_angle  = cos(props->getFloatValue("tree-max-density-angle-deg", 30.0) * osg::PI/180.0);
348     cos_tree_zero_density_slope_angle = cos(props->getFloatValue("tree-zero-density-angle-deg", 45.0) * osg::PI/180.0);
349
350     const SGPropertyNode* treeTexNode = props->getChild("tree-texture");
351     
352     if (treeTexNode) {
353         std::string treeTexPath = props->getStringValue("tree-texture");
354
355         if (! treeTexPath.empty()) {
356             SGPath treePath("Textures.high");
357             treePath.append(treeTexPath);
358             tree_texture = SGModelLib::findDataFile(treePath.str(), options);
359
360             if (tree_texture.empty()) {
361                 treePath.set("Textures");
362                 treePath.append(treeTexPath);
363                 tree_texture = SGModelLib::findDataFile(treePath.str(), options);
364             }
365         }
366     }
367
368     // surface values for use with ground reactions
369     _solid = props->getBoolValue("solid", _solid);
370     _friction_factor = props->getDoubleValue("friction-factor", _friction_factor);
371     _rolling_friction = props->getDoubleValue("rolling-friction", _rolling_friction);
372     _bumpiness = props->getDoubleValue("bumpiness", _bumpiness);
373     _load_resistance = props->getDoubleValue("load-resistance", _load_resistance);
374
375     // Taken from default values as used in ac3d
376     ambient[0] = props->getDoubleValue("ambient/r", 0.2);
377     ambient[1] = props->getDoubleValue("ambient/g", 0.2);
378     ambient[2] = props->getDoubleValue("ambient/b", 0.2);
379     ambient[3] = props->getDoubleValue("ambient/a", 1.0);
380
381     diffuse[0] = props->getDoubleValue("diffuse/r", 0.8);
382     diffuse[1] = props->getDoubleValue("diffuse/g", 0.8);
383     diffuse[2] = props->getDoubleValue("diffuse/b", 0.8);
384     diffuse[3] = props->getDoubleValue("diffuse/a", 1.0);
385
386     specular[0] = props->getDoubleValue("specular/r", 0.0);
387     specular[1] = props->getDoubleValue("specular/g", 0.0);
388     specular[2] = props->getDoubleValue("specular/b", 0.0);
389     specular[3] = props->getDoubleValue("specular/a", 1.0);
390
391     emission[0] = props->getDoubleValue("emissive/r", 0.0);
392     emission[1] = props->getDoubleValue("emissive/g", 0.0);
393     emission[2] = props->getDoubleValue("emissive/b", 0.0);
394     emission[3] = props->getDoubleValue("emissive/a", 1.0);
395
396     shininess = props->getDoubleValue("shininess", 1.0);
397
398     if (props->hasChild("effect"))
399         effect = props->getStringValue("effect");
400
401     std::vector<SGPropertyNode_ptr> object_group_nodes =
402             ((SGPropertyNode *)props)->getChildren("object-group");
403     for (unsigned int i = 0; i < object_group_nodes.size(); i++)
404         object_groups.push_back(new SGMatModelGroup(object_group_nodes[i]));
405
406     // read glyph table for taxi-/runway-signs
407     std::vector<SGPropertyNode_ptr> glyph_nodes = props->getChildren("glyph");
408     for (unsigned int i = 0; i < glyph_nodes.size(); i++) {
409         const char *name = glyph_nodes[i]->getStringValue("name");
410         if (name)
411             glyphs[name] = new SGMaterialGlyph(glyph_nodes[i]);
412     }
413     
414     // Read parameters entry, which is passed into the effect
415     if (props->hasChild("parameters")) {
416         parameters = props->getChild("parameters");
417     } else {
418         parameters = new SGPropertyNode();
419     }
420 }
421
422
423 \f
424 ////////////////////////////////////////////////////////////////////////
425 // Private methods.
426 ////////////////////////////////////////////////////////////////////////
427
428 void 
429 SGMaterial::init ()
430 {
431     _status.clear();
432     xsize = 0;
433     ysize = 0;
434     wrapu = true;
435     wrapv = true;
436
437     mipmap = true;
438     light_coverage = 0.0;
439     building_coverage = 0.0;
440
441     shininess = 1.0;
442     for (int i = 0; i < 4; i++) {
443         ambient[i]  = (i < 3) ? 0.2 : 1.0;
444         specular[i] = (i < 3) ? 0.0 : 1.0;
445         diffuse[i]  = (i < 3) ? 0.8 : 1.0;
446         emission[i] = (i < 3) ? 0.0 : 1.0;
447     }
448     effect = "Effects/terrain-default";
449 }
450
451 Effect* SGMaterial::get_effect(int i)
452 {    
453     if(!_status[i].effect_realized) {
454         if (!_status[i].effect.valid())
455             return 0;
456         _status[i].effect->realizeTechniques(_status[i].options.get());
457         _status[i].effect_realized = true;
458     }
459     return _status[i].effect.get();
460 }
461
462 Effect* SGMaterial::get_effect(const SGTexturedTriangleBin& triangleBin)
463 {
464     SGGuard<SGMutex> g(_lock);
465     if (_status.empty()) {
466         SG_LOG( SG_GENERAL, SG_WARN, "No effect available.");
467         return 0;
468     }
469     
470     int i = triangleBin.getTextureIndex() % _status.size();
471     return get_effect(i);
472 }
473
474 Effect* SGMaterial::get_effect()
475 {
476     SGGuard<SGMutex> g(_lock);
477     return get_effect(0);
478 }
479
480
481 osg::Texture2D* SGMaterial::get_object_mask(const SGTexturedTriangleBin& triangleBin)
482 {
483     if (_status.empty()) {
484         SG_LOG( SG_GENERAL, SG_WARN, "No mask available.");
485         return 0;
486     }
487     
488     // Note that the object mask is closely linked to the texture/effect
489     // so we index based on the texture index, 
490     unsigned int i = triangleBin.getTextureIndex() % _status.size();
491     if (i < _masks.size()) {
492         return _masks[i].get();
493     } else {
494         return 0;
495     }
496 }
497
498 void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
499 {
500     using namespace osg;
501     ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
502     SGPropertyNode_ptr propRoot = new SGPropertyNode();
503     makeChild(propRoot, "inherits-from")->setStringValue(effect);
504     
505     SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
506     copyProperties(parameters, paramProp);
507     
508     SGPropertyNode* materialProp = makeChild(paramProp, "material");
509     makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
510     makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse));
511     makeChild(materialProp, "specular")->setValue(SGVec4d(specular));
512     makeChild(materialProp, "emissive")->setValue(SGVec4d(emission));
513     makeChild(materialProp, "shininess")->setFloatValue(shininess);
514     if (ambient[3] < 1 || diffuse[3] < 1 ||
515         specular[3] < 1 || emission[3] < 1) {
516         makeChild(paramProp, "transparent")->setBoolValue(true);
517         SGPropertyNode* binProp = makeChild(paramProp, "render-bin");
518         makeChild(binProp, "bin-number")->setIntValue(TRANSPARENT_BIN);
519         makeChild(binProp, "bin-name")->setStringValue("DepthSortedBin");
520     }
521     BOOST_FOREACH(_internal_state& matState, _status)
522     {
523         SGPropertyNode_ptr effectProp = new SGPropertyNode();
524         copyProperties(propRoot, effectProp);
525         SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0);
526         for (unsigned int i = 0; i < matState.texture_paths.size(); i++) {
527             SGPropertyNode* texProp = makeChild(effectParamProp, "texture", matState.texture_paths[i].second);
528             makeChild(texProp, "image")->setStringValue(matState.texture_paths[i].first);
529             makeChild(texProp, "filter")
530                 ->setStringValue(mipmap ? "linear-mipmap-linear" : "nearest");
531             makeChild(texProp, "wrap-s")
532                 ->setStringValue(wrapu ? "repeat" : "clamp-to-edge");
533             makeChild(texProp, "wrap-t")
534                 ->setStringValue(wrapv ? "repeat" : "clamp-to-edge");
535         }
536         makeChild(effectParamProp, "xsize")->setDoubleValue(xsize);
537         makeChild(effectParamProp, "ysize")->setDoubleValue(ysize);
538         makeChild(effectParamProp, "scale")->setValue(SGVec3d(xsize,ysize,0.0));
539         makeChild(effectParamProp, "light-coverage")->setDoubleValue(light_coverage);
540
541         matState.effect = makeEffect(effectProp, false, options);
542         if (matState.effect.valid())
543             matState.effect->setUserData(user.get());
544     }
545 }
546
547 SGMaterialGlyph* SGMaterial::get_glyph (const std::string& name) const
548 {
549     map<std::string, SGSharedPtr<SGMaterialGlyph> >::const_iterator it;
550     it = glyphs.find(name);
551     if (it == glyphs.end())
552         return 0;
553
554     return it->second;
555 }
556
557 bool SGMaterial::valid(SGVec2f loc) const
558 {
559         SG_LOG( SG_TERRAIN, SG_BULK, "Checking materials for location ("
560                         << loc.x() << ","
561                         << loc.y() << ")");
562
563         // Check location first again the areas the material is valid for
564         AreaList::const_iterator i = areas->begin();
565
566         if (i == areas->end()) {
567                 // No areas defined, so simply check against condition
568                 if (condition) {
569                         return condition->test();
570                 } else {
571                         return true;
572                 }
573         }
574
575         for (; i != areas->end(); i++) {
576
577                 SG_LOG( SG_TERRAIN, SG_BULK, "Checking area ("
578                                 << i->x() << ","
579                                 << i->y() << ") width:"
580                                 << i->width() << " height:"
581                                 << i->height());
582                 // Areas defined, so check that the tile location falls within it
583                 // before checking against condition
584                 if (i->contains(loc.x(), loc.y())) {
585                         if (condition) {
586                                 return condition->test();
587                         } else {
588                                 return true;
589                         }
590                 }
591         }
592
593         return false;
594 }
595
596 \f
597 ////////////////////////////////////////////////////////////////////////
598 // SGMaterialGlyph.
599 ////////////////////////////////////////////////////////////////////////
600
601 SGMaterialGlyph::SGMaterialGlyph(SGPropertyNode *p) :
602     _left(p->getDoubleValue("left", 0.0)),
603     _right(p->getDoubleValue("right", 1.0))
604 {
605 }
606
607 void
608 SGSetTextureFilter( int max) {
609     SGSceneFeatures::instance()->setTextureFilter( max);
610 }
611
612 int
613 SGGetTextureFilter() {
614     return SGSceneFeatures::instance()->getTextureFilter();
615 }