00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGMATERIALCOLLECTION_H
00020 #define EGGMATERIALCOLLECTION_H
00021
00022 #include <pandabase.h>
00023
00024 #include "eggMaterial.h"
00025 #include "eggGroupNode.h"
00026 #include "vector_PT_EggMaterial.h"
00027
00028 #include <string>
00029 #include "pmap.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDAEGG EggMaterialCollection {
00040
00041
00042
00043
00044
00045 private:
00046 typedef pmap<PT_EggMaterial, int> Materials;
00047 typedef vector_PT_EggMaterial OrderedMaterials;
00048
00049 public:
00050 typedef OrderedMaterials::const_iterator iterator;
00051 typedef iterator const_iterator;
00052 typedef OrderedMaterials::size_type size_type;
00053
00054 typedef pmap<PT_EggMaterial, PT_EggMaterial > MaterialReplacement;
00055
00056
00057
00058 public:
00059 EggMaterialCollection();
00060 EggMaterialCollection(const EggMaterialCollection ©);
00061 EggMaterialCollection &operator = (const EggMaterialCollection ©);
00062 ~EggMaterialCollection();
00063
00064 void clear();
00065
00066 int extract_materials(EggGroupNode *node);
00067 EggGroupNode::iterator insert_materials(EggGroupNode *node);
00068 EggGroupNode::iterator insert_materials(EggGroupNode *node, EggGroupNode::iterator position);
00069
00070 int find_used_materials(EggNode *node);
00071 void remove_unused_materials(EggNode *node);
00072
00073 int collapse_equivalent_materials(int eq, EggGroupNode *node);
00074 int collapse_equivalent_materials(int eq, MaterialReplacement &removed);
00075 static void replace_materials(EggGroupNode *node,
00076 const MaterialReplacement &replace);
00077
00078 void uniquify_mrefs();
00079 void sort_by_mref();
00080
00081
00082
00083 INLINE iterator begin() const;
00084 INLINE iterator end() const;
00085 INLINE bool empty() const;
00086 INLINE size_type size() const;
00087
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