]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/matmodel.cxx
Merge branch 'zan/stencil'
[simgear.git] / simgear / scene / material / matmodel.cxx
index 70850edc2a30fd6e3d50fd9ee2c5908371a8237d..bdad512eef0add5bf58e2d728169a8c15b20f7ef 100644 (file)
@@ -28,7 +28,7 @@
 #include <simgear/compiler.h>
 
 #include <map>
-SG_USING_STD(map);
+using std::map;
 
 #include <osg/AlphaFunc>
 #include <osg/Group>
@@ -36,11 +36,8 @@ SG_USING_STD(map);
 #include <osg/StateSet>
 #include <osg/Transform>
 
-#ifdef SG_MATH_EXCEPTION_CLASH
-#  include <math.h>
-#endif
-
 #include <simgear/debug/logstream.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
@@ -48,27 +45,7 @@ SG_USING_STD(map);
 
 #include "matmodel.hxx"
 
-\f
-////////////////////////////////////////////////////////////////////////
-// Local static functions.
-////////////////////////////////////////////////////////////////////////
-
-/**
- * Internal method to test whether a file exists.
- *
- * TODO: this should be moved to a SimGear library of local file
- * functions.
- */
-static inline bool
-local_file_exists( const string& path ) {
-    sg_gzifstream in( path );
-    if ( ! in.is_open() ) {
-       return false;
-    } else {
-       return true;
-    }
-}
-
+using namespace simgear;
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -115,27 +92,19 @@ SGMatModel::~SGMatModel ()
 }
 
 int
-SGMatModel::get_model_count( SGModelLib *modellib,
-                             const string &fg_root,
-                             SGPropertyNode *prop_root,
-                             double sim_time_sec )
+SGMatModel::get_model_count( SGPropertyNode *prop_root )
 {
-  load_models( modellib, fg_root, prop_root, sim_time_sec );
+  load_models( prop_root );
   return _models.size();
 }
 
 inline void
-SGMatModel::load_models ( SGModelLib *modellib,
-                          const string &fg_root,
-                          SGPropertyNode *prop_root,
-                          double sim_time_sec )
+SGMatModel::load_models( SGPropertyNode *prop_root )
 {
                                // Load model only on demand
   if (!_models_loaded) {
     for (unsigned int i = 0; i < _paths.size(); i++) {
-      osg::Node *entity = modellib->load_model( fg_root, _paths[i],
-                                                prop_root, sim_time_sec,
-                                                /*cache_object*/ true );
+      osg::Node *entity = SGModelLib::loadModel(_paths[i], prop_root);
       if (entity != 0) {
         // FIXME: this stuff can be handled
         // in the XML wrapper as well (at least,
@@ -166,23 +135,9 @@ SGMatModel::load_models ( SGModelLib *modellib,
 }
 
 osg::Node*
-SGMatModel::get_model( int index,
-                       SGModelLib *modellib,
-                       const string &fg_root,
-                       SGPropertyNode *prop_root,
-                       double sim_time_sec )
-{
-  load_models( modellib, fg_root, prop_root, sim_time_sec ); // comment this out if preloading models
-  return _models[index].get();
-}
-
-osg::Node*
-SGMatModel::get_random_model( SGModelLib *modellib,
-                              const string &fg_root,
-                              SGPropertyNode *prop_root,
-                              double sim_time_sec )
+SGMatModel::get_random_model( SGPropertyNode *prop_root )
 {
-  load_models( modellib, fg_root, prop_root, sim_time_sec ); // comment this out if preloading models
+  load_models( prop_root ); // comment this out if preloading models
   int nModels = _models.size();
   int index = int(sg_random() * nModels);
   if (index >= nModels)