X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2Fmat.hxx;h=62a46afc7fb5efc94ad6a7f0f0259873c5bb666e;hb=dda676b1b2ba3af767de5e93b54086a426a05707;hp=66bf19e9735ee8dc176709be9a735f04e08fa6eb;hpb=c01740d5166fd96af597dd050faef7b8c4f89601;p=simgear.git diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 66bf19e9..62a46afc 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -33,14 +33,17 @@ #include #include STL_STRING // Standard C++ string library +#include #include #include #include -#include + +#include "matmodel.hxx" SG_USING_STD(string); +SG_USING_STD(vector); /** @@ -56,169 +59,6 @@ class SGMaterial { public: - - ////////////////////////////////////////////////////////////////////// - // Inner classes. - ////////////////////////////////////////////////////////////////////// - - class ObjectGroup; - - /** - * A randomly-placeable object. - * - * SGMaterial uses this class to keep track of the model(s) and - * parameters for a single instance of a randomly-placeable object. - * The object can have more than one variant model (i.e. slightly - * different shapes of trees), but they are considered equivalent - * and interchangeable. - */ - class Object - { - public: - - /** - * The heading type for a randomly-placed object. - */ - enum HeadingType { - HEADING_FIXED, - HEADING_BILLBOARD, - HEADING_RANDOM - }; - - - /** - * Get the number of variant models available for the object. - * - * @return The number of variant models. - */ - int get_model_count( SGModelLoader *loader, - const string &fg_root, - SGPropertyNode *prop_root, - double sim_time_sec ); - - - /** - * Get a specific variant model for the object. - * - * @param index The index of the model. - * @return The model. - */ - ssgEntity *get_model( int index, - SGModelLoader *loader, - const string &fg_root, - SGPropertyNode *prop_root, - double sim_time_sec ); - - - /** - * Get a randomly-selected variant model for the object. - * - * @return A randomly select model from the variants. - */ - ssgEntity *get_random_model( SGModelLoader *loader, - const string &fg_root, - SGPropertyNode *prop_root, - double sim_time_sec ); - - - /** - * Get the average number of meters^2 occupied by each instance. - * - * @return The coverage in meters^2. - */ - double get_coverage_m2 () const; - - - /** - * Get the heading type for the object. - * - * @return The heading type. - */ - HeadingType get_heading_type () const; - - protected: - - friend class ObjectGroup; - - Object (const SGPropertyNode * node, double range_m); - - virtual ~Object (); - - private: - - /** - * Actually load the models. - * - * This class uses lazy loading so that models won't be held - * in memory for materials that are never referenced. - */ - void load_models( SGModelLoader *loader, - const string &fg_root, - SGPropertyNode *prop_root, - double sim_time_sec ); - - vector _paths; - mutable vector _models; - mutable bool _models_loaded; - double _coverage_m2; - double _range_m; - HeadingType _heading_type; - }; - - - /** - * A collection of related objects with the same visual range. - * - * Grouping objects with the same range together significantly - * reduces the memory requirements of randomly-placed objects. - * Each SGMaterial instance keeps a (possibly-empty) list of - * object groups for placing randomly on the scenery. - */ - class ObjectGroup - { - public: - virtual ~ObjectGroup (); - - - /** - * Get the visual range of the object in meters. - * - * @return The visual range. - */ - double get_range_m () const; - - - /** - * Get the number of objects in the group. - * - * @return The number of objects. - */ - int get_object_count () const; - - - /** - * Get a specific object. - * - * @param index The object's index, zero-based. - * @return The object selected. - */ - Object * get_object (int index) const; - - protected: - - friend class SGMaterial; - - ObjectGroup (SGPropertyNode * node); - - private: - - double _range_m; - vector _objects; - - }; - - - //////////////////////////////////////////////////////////////////// // Public Constructors. @@ -311,7 +151,7 @@ public: /** * Get a randomly-placed object for this material. */ - virtual ObjectGroup * get_object_group (int index) const { + virtual SGMatModelGroup * get_object_group (int index) const { return object_groups[index]; } @@ -383,7 +223,7 @@ private: // true if texture loading deferred, and not yet loaded bool texture_loaded; - vector object_groups; + vector object_groups; // ref count so we can properly delete if we have multiple // pointers to this record