00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EGGVERTEXPOOL_H
00016 #define EGGVERTEXPOOL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "eggVertex.h"
00021 #include "eggNode.h"
00022 #include "pt_EggVertex.h"
00023
00024 #include "pointerTo.h"
00025 #include "pset.h"
00026 #include "pvector.h"
00027 #include "pmap.h"
00028 #include "lmatrix.h"
00029 #include "iterator_types.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class EXPCL_PANDAEGG EggVertexPool : public EggNode {
00047
00048
00049
00050
00051
00052 private:
00053
00054
00055
00056 typedef pmap<int, PT_EggVertex> IndexVertices;
00057
00058
00059
00060
00061
00062
00063 typedef pmultiset<EggVertex *, UniqueEggVertices> UniqueVertices;
00064
00065 public:
00066 typedef second_of_pair_iterator<IndexVertices::const_iterator> iterator;
00067 typedef iterator const_iterator;
00068 typedef IndexVertices::size_type size_type;
00069
00070
00071
00072 PUBLISHED:
00073 EggVertexPool(const string &name);
00074 EggVertexPool(const EggVertexPool ©);
00075 ~EggVertexPool();
00076
00077 INLINE bool has_vertex(int index) const;
00078
00079 bool has_forward_vertices() const;
00080 bool has_defined_vertices() const;
00081
00082
00083 EggVertex *get_vertex(int index) const;
00084 INLINE EggVertex *operator [](int index) const;
00085
00086
00087 EggVertex *get_forward_vertex(int index);
00088
00089
00090 int get_highest_index() const;
00091 void set_highest_index(int highest_index);
00092
00093 int get_num_dimensions() const;
00094 bool has_normals() const;
00095 bool has_colors() const;
00096 bool has_nonwhite_colors() const;
00097 void check_overall_color(bool &has_overall_color, LColor &overall_color) const;
00098 bool has_uvs() const;
00099 bool has_aux() const;
00100 void get_uv_names(vector_string &uv_names, vector_string &uvw_names,
00101 vector_string &tbn_names) const;
00102 void get_aux_names(vector_string &aux_names) const;
00103
00104 public:
00105
00106 iterator begin() const;
00107 iterator end() const;
00108 bool empty() const;
00109
00110 PUBLISHED:
00111 size_type size() const;
00112
00113
00114
00115 EggVertex *add_vertex(EggVertex *vertex, int index = -1);
00116
00117
00118
00119 INLINE EggVertex *make_new_vertex();
00120 INLINE EggVertex *make_new_vertex(double pos);
00121 INLINE EggVertex *make_new_vertex(const LPoint2d &pos);
00122 INLINE EggVertex *make_new_vertex(const LPoint3d &pos);
00123 INLINE EggVertex *make_new_vertex(const LPoint4d &pos);
00124
00125
00126
00127
00128 EggVertex *create_unique_vertex(const EggVertex ©);
00129 EggVertex *find_matching_vertex(const EggVertex ©);
00130
00131 void remove_vertex(EggVertex *vertex);
00132 int remove_unused_vertices();
00133 void add_unused_vertices_to_prim(EggPrimitive *prim);
00134
00135 void transform(const LMatrix4d &mat);
00136 void sort_by_external_index();
00137
00138 void write(ostream &out, int indent_level) const;
00139
00140 protected:
00141 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
00142 CoordinateSystem to_cs);
00143 virtual void r_transform_vertices(const LMatrix4d &mat);
00144
00145 private:
00146 UniqueVertices _unique_vertices;
00147 IndexVertices _index_vertices;
00148 int _highest_index;
00149
00150
00151 public:
00152
00153 static TypeHandle get_class_type() {
00154 return _type_handle;
00155 }
00156 static void init_type() {
00157 EggNode::init_type();
00158 register_type(_type_handle, "EggVertexPool",
00159 EggNode::get_class_type());
00160 }
00161 virtual TypeHandle get_type() const {
00162 return get_class_type();
00163 }
00164 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00165
00166 private:
00167 static TypeHandle _type_handle;
00168
00169 friend class EggVertex;
00170 };
00171
00172 typedef pvector< PT(EggVertexPool) > EggVertexPools;
00173
00174 #include "eggVertexPool.I"
00175
00176 #endif