00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EGGMATERIALCOLLECTION_H
00016 #define EGGMATERIALCOLLECTION_H
00017
00018 #include "pandabase.h"
00019
00020 #include "eggMaterial.h"
00021 #include "eggGroupNode.h"
00022 #include "vector_PT_EggMaterial.h"
00023
00024 #include "pmap.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class EXPCL_PANDAEGG EggMaterialCollection {
00035
00036
00037
00038
00039
00040 private:
00041 typedef pmap<PT_EggMaterial, int> Materials;
00042 typedef vector_PT_EggMaterial OrderedMaterials;
00043
00044 public:
00045 typedef OrderedMaterials::const_iterator iterator;
00046 typedef iterator const_iterator;
00047 typedef OrderedMaterials::size_type size_type;
00048
00049 typedef pmap<PT_EggMaterial, PT_EggMaterial > MaterialReplacement;
00050
00051
00052
00053 PUBLISHED:
00054 EggMaterialCollection();
00055 EggMaterialCollection(const EggMaterialCollection ©);
00056 EggMaterialCollection &operator = (const EggMaterialCollection ©);
00057 ~EggMaterialCollection();
00058
00059 void clear();
00060
00061 int extract_materials(EggGroupNode *node);
00062
00063 public:
00064 EggGroupNode::iterator insert_materials(EggGroupNode *node);
00065 EggGroupNode::iterator insert_materials(EggGroupNode *node, EggGroupNode::iterator position);
00066
00067 PUBLISHED:
00068 int find_used_materials(EggNode *node);
00069 void remove_unused_materials(EggNode *node);
00070
00071 int collapse_equivalent_materials(int eq, EggGroupNode *node);
00072 int collapse_equivalent_materials(int eq, MaterialReplacement &removed);
00073 static void replace_materials(EggGroupNode *node,
00074 const MaterialReplacement &replace);
00075
00076 void uniquify_mrefs();
00077 void sort_by_mref();
00078
00079
00080
00081 public:
00082 INLINE iterator begin() const;
00083 INLINE iterator end() const;
00084 INLINE bool empty() const;
00085 INLINE size_type size() const;
00086
00087 PUBLISHED:
00088 bool add_material(EggMaterial *material);
00089 bool remove_material(EggMaterial *material);
00090
00091
00092
00093
00094
00095 EggMaterial *create_unique_material(const EggMaterial ©, int eq);
00096
00097
00098 EggMaterial *find_mref(const string &mref_name) const;
00099
00100 private:
00101 Materials _materials;
00102 OrderedMaterials _ordered_materials;
00103 };
00104
00105 #include "eggMaterialCollection.I"
00106
00107 #endif