X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2Fmat.hxx;h=9e2d06e432d58d7f490a85c4222040ab4f87ece2;hb=416fb94ae880d2f1ec1b16fbe621ae1219fb1b31;hp=e041b6987a97dd8972c2f27eec44d30065a61265;hpb=c3b1802e956db11c2b06d354d90bca3ca9622a7b;p=simgear.git diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index e041b698..9e2d06e4 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -45,6 +45,7 @@ namespace osg class StateSet; } +#include #include #include #include @@ -54,6 +55,7 @@ class StateSet; namespace simgear { class Effect; +void reload_shaders(); } class SGMaterialGlyph; @@ -83,29 +85,10 @@ public: * state information for the material. This node is usually * loaded from the $FG_ROOT/materials.xml file. */ - SGMaterial( const std::string &fg_root, const SGPropertyNode *props); - - - /** - * Construct a material from an absolute texture path. - * - * @param texture_path A string containing an absolute path - * to a texture file (usually RGB). - */ - SGMaterial( const std::string &texpath ); - - - /** - * Construct a material around an existing state. - * - * This constructor allows the application to create a custom, - * low-level state for the scene graph and wrap a material around - * it. Note: the pointer ownership is transferred to the material. - * - * @param s The state for this material. - */ - SGMaterial( osg::StateSet *s ); + SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props); + SGMaterial(const simgear::SGReaderWriterXMLOptions*, + const SGPropertyNode *props); /** * Destructor. */ @@ -150,23 +133,37 @@ public: inline double get_light_coverage () const { return light_coverage; } /** - * Get the forest coverage. + * Get the wood coverage. * - * A smaller number means more generated forest canopy. + * A smaller number means more generated woods within the forest. * - * @return The area (m^2) covered by each canopy. + * @return The area (m^2) covered by each wood. */ - inline double get_tree_coverage () const { return tree_coverage; } + inline double get_wood_coverage () const { return wood_coverage; } /** - * Get the forest height. + * Get the density of the wood + * + * @return The area (m^2) covered by each tree in the wood. + */ + inline double get_tree_density () const { return tree_density; } + + /** + * Get the size of each wood + * + * @return the average area (m^2) of each wood + */ + inline double get_wood_size () const { return wood_size; } + + /** + * Get the tree height. * * @return The average height of the trees. */ inline double get_tree_height () const { return tree_height; } /** - * Get the forest width. + * Get the tree width. * * @return The average width of the trees. */ @@ -275,11 +272,15 @@ protected: protected: struct _internal_state { - _internal_state( osg::StateSet *s, const std::string &t, bool l ); - osg::ref_ptr state; + _internal_state(simgear::Effect *e, bool l, + const simgear::SGReaderWriterXMLOptions *o); + _internal_state(simgear::Effect *e, const std::string &t, bool l, + const simgear::SGReaderWriterXMLOptions *o); + void add_texture(const std::string &t, int i); osg::ref_ptr effect; - std::string texture_path; - bool texture_loaded; + std::vector > texture_paths; + bool effect_realized; + osg::ref_ptr options; }; private: @@ -307,9 +308,15 @@ private: // coverage of night lighting. double light_coverage; - // coverage of trees - double tree_coverage; - + // coverage of woods + double wood_coverage; + + // The size of each wood + double wood_size; + + // Tree density within the wood + double tree_density; + // Range at which trees become visible double tree_range; @@ -341,6 +348,9 @@ private: SGVec4f ambient, diffuse, specular, emission; double shininess; + // effect for this material + std::string effect; + // the list of names for this material. May be empty. std::vector _names; @@ -356,14 +366,9 @@ private: // Internal constructors and methods. //////////////////////////////////////////////////////////////////// - SGMaterial( const std::string &fg_root, const SGMaterial &mat ); // unimplemented - - void read_properties( const std::string &fg_root, const SGPropertyNode *props ); - void build_state( bool defer_tex_load ); - void set_state( osg::StateSet *s ); - - void assignTexture( osg::StateSet *state, const std::string &fname, bool _wrapu = true, bool _wrapv = true, bool _mipmap = true ); - + void read_properties(const simgear::SGReaderWriterXMLOptions* options, + const SGPropertyNode *props); + void buildEffectProperties(const simgear::SGReaderWriterXMLOptions* options); };