00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EGGVERTEX_H
00016 #define EGGVERTEX_H
00017
00018 #include "pandabase.h"
00019
00020 #include "eggObject.h"
00021 #include "eggAttributes.h"
00022 #include "eggMorphList.h"
00023 #include "eggVertexUV.h"
00024 #include "eggVertexAux.h"
00025
00026 #include "referenceCount.h"
00027 #include "luse.h"
00028 #include "pset.h"
00029 #include "iterator_types.h"
00030
00031 class EggVertexPool;
00032 class EggGroup;
00033 class EggPrimitive;
00034
00035
00036
00037
00038
00039
00040
00041 class EXPCL_PANDAEGG EggVertex : public EggObject, public EggAttributes {
00042 public:
00043 typedef pset<EggGroup *> GroupRef;
00044 typedef pmultiset<EggPrimitive *> PrimitiveRef;
00045 typedef pmap< string, PT(EggVertexUV) > UVMap;
00046 typedef pmap< string, PT(EggVertexAux) > AuxMap;
00047
00048 typedef second_of_pair_iterator<UVMap::const_iterator> uv_iterator;
00049 typedef uv_iterator const_uv_iterator;
00050 typedef UVMap::size_type uv_size_type;
00051
00052 typedef second_of_pair_iterator<AuxMap::const_iterator> aux_iterator;
00053 typedef aux_iterator const_aux_iterator;
00054 typedef AuxMap::size_type aux_size_type;
00055
00056
00057 PUBLISHED:
00058 EggVertex();
00059 EggVertex(const EggVertex ©);
00060 EggVertex &operator = (const EggVertex ©);
00061 virtual ~EggVertex();
00062
00063 INLINE EggVertexPool *get_pool() const;
00064
00065 INLINE bool is_forward_reference() const;
00066
00067
00068
00069 INLINE void set_pos(double pos);
00070 INLINE void set_pos(const LPoint2d &pos);
00071 INLINE void set_pos(const LPoint3d &pos);
00072 INLINE void set_pos(const LPoint4d &pos);
00073 INLINE void set_pos4(const LPoint4d &pos);
00074
00075
00076
00077
00078
00079
00080
00081 INLINE int get_num_dimensions() const;
00082 INLINE double get_pos1() const;
00083 INLINE LPoint2d get_pos2() const;
00084 INLINE LVertexd get_pos3() const;
00085 INLINE LPoint4d get_pos4() const;
00086
00087 INLINE bool has_uv() const;
00088 INLINE LTexCoordd get_uv() const;
00089 INLINE void set_uv(const LTexCoordd &texCoord);
00090 INLINE void clear_uv();
00091 bool has_uv(const string &name) const;
00092 bool has_uvw(const string &name) const;
00093 LTexCoordd get_uv(const string &name) const;
00094 const LTexCoord3d &get_uvw(const string &name) const;
00095 void set_uv(const string &name, const LTexCoordd &texCoord);
00096 void set_uvw(const string &name, const LTexCoord3d &texCoord);
00097 const EggVertexUV *get_uv_obj(const string &name) const;
00098 EggVertexUV *modify_uv_obj(const string &name);
00099 void set_uv_obj(EggVertexUV *vertex_uv);
00100 void clear_uv(const string &name);
00101
00102 INLINE bool has_aux() const;
00103 INLINE void clear_aux();
00104 bool has_aux(const string &name) const;
00105 const LVecBase4d &get_aux(const string &name) const;
00106 void set_aux(const string &name, const LVecBase4d &aux);
00107 const EggVertexAux *get_aux_obj(const string &name) const;
00108 EggVertexAux *modify_aux_obj(const string &name);
00109 void set_aux_obj(EggVertexAux *vertex_aux);
00110 void clear_aux(const string &name);
00111
00112 public:
00113 INLINE const_uv_iterator uv_begin() const;
00114 INLINE const_uv_iterator uv_end() const;
00115 INLINE uv_size_type uv_size() const;
00116
00117 INLINE const_aux_iterator aux_begin() const;
00118 INLINE const_aux_iterator aux_end() const;
00119 INLINE aux_size_type aux_size() const;
00120
00121 PUBLISHED:
00122 INLINE int get_index() const;
00123
00124 INLINE void set_external_index(int external_index);
00125 INLINE int get_external_index() const;
00126
00127 void write(ostream &out, int indent_level) const;
00128 INLINE bool sorts_less_than(const EggVertex &other) const;
00129 int compare_to(const EggVertex &other) const;
00130
00131 int get_num_local_coord() const;
00132 int get_num_global_coord() const;
00133
00134 void transform(const LMatrix4d &mat);
00135
00136 public:
00137 GroupRef::const_iterator gref_begin() const;
00138 GroupRef::const_iterator gref_end() const;
00139 GroupRef::size_type gref_size() const;
00140 PUBLISHED:
00141 bool has_gref(const EggGroup *group) const;
00142
00143 void copy_grefs_from(const EggVertex &other);
00144 void clear_grefs();
00145
00146 public:
00147 PrimitiveRef::const_iterator pref_begin() const;
00148 PrimitiveRef::const_iterator pref_end() const;
00149 PrimitiveRef::size_type pref_size() const;
00150 PUBLISHED:
00151 int has_pref(const EggPrimitive *prim) const;
00152
00153 #ifdef _DEBUG
00154 void test_gref_integrity() const;
00155 void test_pref_integrity() const;
00156 #else
00157 void test_gref_integrity() const { }
00158 void test_pref_integrity() const { }
00159 #endif // _DEBUG
00160
00161 void output(ostream &out) const;
00162
00163 EggMorphVertexList _dxyzs;
00164
00165 private:
00166 EggVertexPool *_pool;
00167 bool _forward_reference;
00168 int _index;
00169 int _external_index;
00170 LPoint4d _pos;
00171 short _num_dimensions;
00172 GroupRef _gref;
00173 PrimitiveRef _pref;
00174
00175 UVMap _uv_map;
00176 AuxMap _aux_map;
00177
00178 public:
00179 static TypeHandle get_class_type() {
00180 return _type_handle;
00181 }
00182 static void init_type() {
00183 EggObject::init_type();
00184 EggAttributes::init_type();
00185 register_type(_type_handle, "EggVertex",
00186 EggObject::get_class_type(),
00187 EggAttributes::get_class_type());
00188 }
00189 virtual TypeHandle get_type() const {
00190 return get_class_type();
00191 }
00192 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00193
00194 private:
00195 static TypeHandle _type_handle;
00196
00197 friend class EggVertexPool;
00198 friend class EggGroup;
00199 friend class EggPrimitive;
00200 };
00201
00202 INLINE ostream &operator << (ostream &out, const EggVertex &vert) {
00203 vert.output(out);
00204 return out;
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214 class EXPCL_PANDAEGG UniqueEggVertices {
00215 public:
00216 INLINE bool operator ()(const EggVertex *v1, const EggVertex *v2) const;
00217 };
00218
00219 #include "eggVertex.I"
00220
00221 #endif
00222
00223
00224