00001 // matmodel.hxx -- class to handle models tied to a material property 00002 // 00003 // Written by David Megginson, December 2001 00004 // 00005 // Copyright (C) 1998 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License as 00009 // published by the Free Software Foundation; either version 2 of the 00010 // License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, but 00013 // WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 // 00021 // $Id: matmodel_8hxx-source.html,v 1.14 2008/12/18 22:32:01 curt Exp $ 00022 00023 00024 #ifndef _SG_MAT_MODEL_HXX 00025 #define _SG_MAT_MODEL_HXX 00026 00027 #ifndef __cplusplus 00028 # error This library requires C++ 00029 #endif 00030 00031 #include <simgear/compiler.h> 00032 00033 #include <string> // Standard C++ string library 00034 #include <vector> 00035 00036 #include <osg/ref_ptr> 00037 #include <osg/Node> 00038 #include <osg/NodeVisitor> 00039 #include <osg/Billboard> 00040 00041 #include <simgear/structure/SGReferenced.hxx> 00042 #include <simgear/structure/SGSharedPtr.hxx> 00043 #include <simgear/props/props.hxx> 00044 #include <simgear/math/sg_random.h> 00045 00046 00047 class SGMatModelGroup; 00048 00049 00059 class SGMatModel : public SGReferenced { 00060 00061 public: 00062 00066 enum HeadingType { 00067 HEADING_FIXED, 00068 HEADING_BILLBOARD, 00069 HEADING_RANDOM 00070 }; 00071 00077 int get_model_count( SGPropertyNode *prop_root ); 00078 00079 00086 osg::Node *get_model( int index, SGPropertyNode *prop_root ); 00087 00088 00094 osg::Node *get_random_model( SGPropertyNode *prop_root ); 00095 00096 00102 double get_coverage_m2 () const; 00103 00109 double get_range_m () const; 00110 00116 double get_randomized_range_m(mt* seed) const; 00117 00123 HeadingType get_heading_type () const; 00124 00125 virtual ~SGMatModel (); 00126 00127 00128 protected: 00129 00130 friend class SGMatModelGroup; 00131 00132 SGMatModel (const SGPropertyNode * node, double range_m); 00133 00134 private: 00135 00142 void load_models( SGPropertyNode *prop_root ); 00143 00144 std::vector<std::string> _paths; 00145 mutable std::vector<osg::ref_ptr<osg::Node> > _models; 00146 mutable bool _models_loaded; 00147 double _coverage_m2; 00148 double _range_m; 00149 HeadingType _heading_type; 00150 }; 00151 00152 00161 class SGMatModelGroup : public SGReferenced { 00162 00163 public: 00164 00165 virtual ~SGMatModelGroup (); 00166 00167 00173 double get_range_m () const; 00174 00175 00181 int get_object_count () const; 00182 00183 00190 SGMatModel * get_object (int index) const; 00191 00192 protected: 00193 00194 friend class SGMaterial; 00195 00196 SGMatModelGroup (SGPropertyNode * node); 00197 00198 private: 00199 00200 double _range_m; 00201 std::vector<SGSharedPtr<SGMatModel> > _objects; 00202 }; 00203 00204 #endif // _SG_MAT_MODEL_HXX
1.5.6