#include <simgear/compiler.h>
#include <map>
-SG_USING_STD(map);
+
#include <osg/AlphaFunc>
#include <osg/Group>
#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>
#include "matmodel.hxx"
using namespace simgear;
-
-\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;
- }
-}
-
-
-\f
+using std::string;
+using std::map;\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGMatModel.
////////////////////////////////////////////////////////////////////////
}
// Note all the model paths
- vector <SGPropertyNode_ptr> path_nodes = node->getChildren("path");
+ std::vector <SGPropertyNode_ptr> path_nodes = node->getChildren("path");
for (unsigned int i = 0; i < path_nodes.size(); i++)
_paths.push_back(path_nodes[i]->getStringValue());
}
osg::Node*
-SGMatModel::get_model( int index,
- SGPropertyNode *prop_root )
-{
- load_models( prop_root ); // comment this out if preloading models
- return _models[index].get();
-}
-
-osg::Node*
-SGMatModel::get_random_model( SGPropertyNode *prop_root )
+SGMatModel::get_random_model( SGPropertyNode *prop_root, mt seed )
{
load_models( prop_root ); // comment this out if preloading models
int nModels = _models.size();
- int index = int(sg_random() * nModels);
- if (index >= nModels)
- index = 0;
- return _models[index].get();
+ return _models[mt_rand(&seed) * nModels].get();
}
double
: _range_m(node->getDoubleValue("range-m", 2000))
{
// Load the object subnodes
- vector<SGPropertyNode_ptr> object_nodes =
+ std::vector<SGPropertyNode_ptr> object_nodes =
((SGPropertyNode *)node)->getChildren("object");
for (unsigned int i = 0; i < object_nodes.size(); i++) {
const SGPropertyNode * object_node = object_nodes[i];