00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGGROUPNODE_H
00020 #define EGGGROUPNODE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "eggNode.h"
00025
00026 #include "coordinateSystem.h"
00027 #include "typedObject.h"
00028 #include "pointerTo.h"
00029 #include "luse.h"
00030
00031 #include "plist.h"
00032
00033 class EggTextureCollection;
00034 class EggMaterialCollection;
00035 class EggPolygon;
00036 class EggVertex;
00037 class DSearchPath;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class EXPCL_PANDAEGG EggGroupNode : public EggNode {
00053
00054
00055
00056
00057
00058 private:
00059
00060
00061
00062 typedef plist< PT(EggNode) > Children;
00063
00064
00065
00066 public:
00067 EggGroupNode(const string &name = "") : EggNode(name) { }
00068 EggGroupNode(const EggGroupNode ©);
00069 EggGroupNode &operator = (const EggGroupNode ©);
00070 virtual ~EggGroupNode();
00071
00072 virtual void write(ostream &out, int indent_level) const;
00073
00074
00075
00076
00077
00078
00079 #ifdef WIN32_VC
00080 typedef const PT(EggNode) *pointer;
00081 typedef const PT(EggNode) *const_pointer;
00082 #else
00083 typedef Children::const_pointer pointer;
00084 typedef Children::const_pointer const_pointer;
00085 #endif
00086 typedef Children::const_reference reference;
00087 typedef Children::const_reference const_reference;
00088 typedef Children::const_iterator iterator;
00089 typedef Children::const_iterator const_iterator;
00090 typedef Children::const_reverse_iterator reverse_iterator;
00091 typedef Children::const_reverse_iterator const_reverse_iterator;
00092 typedef Children::size_type size_type;
00093 typedef Children::difference_type difference_type;
00094
00095 iterator begin() const;
00096 iterator end() const;
00097 reverse_iterator rbegin() const;
00098 reverse_iterator rend() const;
00099 bool empty() const;
00100 size_type size() const;
00101
00102 iterator insert(iterator position, PT(EggNode) x);
00103 iterator erase(iterator position);
00104 iterator erase(iterator first, iterator last);
00105 void replace(iterator position, PT(EggNode) x);
00106 void clear();
00107
00108 PT(EggNode) add_child(PT(EggNode) node);
00109 PT(EggNode) remove_child(PT(EggNode) node);
00110 void steal_children(EggGroupNode &other);
00111
00112 void resolve_filenames(const DSearchPath &searchpath);
00113 void reverse_vertex_ordering();
00114
00115 void recompute_vertex_normals(double threshold, CoordinateSystem cs = CS_default);
00116 void recompute_polygon_normals(CoordinateSystem cs = CS_default);
00117 void strip_normals();
00118
00119 int triangulate_polygons(bool convex_also);
00120
00121 int remove_unused_vertices();
00122 int remove_invalid_primitives();
00123
00124 protected:
00125 virtual void update_under(int depth_offset);
00126
00127 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
00128 CoordinateSystem to_cs);
00129 virtual void r_transform_vertices(const LMatrix4d &mat);
00130 virtual void r_mark_coordsys(CoordinateSystem cs);
00131 virtual void r_flatten_transforms();
00132 virtual void r_apply_texmats(EggTextureCollection &textures);
00133
00134
00135 CoordinateSystem find_coordsys_entry();
00136 int find_textures(EggTextureCollection *collection);
00137 int find_materials(EggMaterialCollection *collection);
00138 bool r_load_externals(const DSearchPath &searchpath,
00139 CoordinateSystem coordsys);
00140
00141 private:
00142 Children _children;
00143
00144
00145
00146
00147 void prepare_add_child(EggNode *node);
00148 void prepare_remove_child(EggNode *node);
00149
00150
00151 class NVertexReference {
00152 public:
00153 EggPolygon *_polygon;
00154 Normald _normal;
00155 size_t _vertex;
00156 };
00157 typedef pvector<NVertexReference> NVertexGroup;
00158 typedef pmap<Vertexd, NVertexGroup> NVertexCollection;
00159
00160 void r_collect_vertex_normals(NVertexCollection &collection,
00161 double threshold, CoordinateSystem cs);
00162 void do_compute_vertex_normals(const NVertexGroup &group);
00163
00164 public:
00165 static TypeHandle get_class_type() {
00166 return _type_handle;
00167 }
00168 static void init_type() {
00169 EggNode::init_type();
00170 register_type(_type_handle, "EggGroupNode",
00171 EggNode::get_class_type());
00172 }
00173 virtual TypeHandle get_type() const {
00174 return get_class_type();
00175 }
00176 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00177
00178 private:
00179 static TypeHandle _type_handle;
00180
00181 friend class EggTextureCollection;
00182 friend class EggMaterialCollection;
00183 };
00184
00185 #include "eggGroupNode.I"
00186
00187 #endif
00188