00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GEOMNODE_H
00020 #define GEOMNODE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pandaNode.h"
00025 #include "pointerToArray.h"
00026 #include "geom.h"
00027 #include "pipelineCycler.h"
00028 #include "cycleData.h"
00029 #include "pvector.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA GeomNode : public PandaNode {
00039 PUBLISHED:
00040 GeomNode(const string &name);
00041
00042 protected:
00043 GeomNode(const GeomNode ©);
00044 public:
00045 virtual ~GeomNode();
00046 virtual PandaNode *make_copy() const;
00047 virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs,
00048 int attrib_types,
00049 GeomTransformer &transformer);
00050 virtual void xform(const LMatrix4f &mat);
00051 virtual PandaNode *combine_with(PandaNode *other);
00052 virtual CPT(TransformState)
00053 calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point,
00054 bool &found_any,
00055 const TransformState *transform) const;
00056
00057 PUBLISHED:
00058 INLINE int get_num_geoms() const;
00059 INLINE Geom *get_geom(int n) const;
00060 INLINE const RenderState *get_geom_state(int n) const;
00061 INLINE void set_geom_state(int n, const RenderState *state);
00062
00063 INLINE int add_geom(Geom *geom, const RenderState *state = RenderState::make_empty());
00064 void add_geoms_from(const GeomNode *other);
00065 INLINE void remove_geom(int n);
00066 INLINE void remove_all_geoms();
00067
00068 void write_geoms(ostream &out, int indent_level) const;
00069 void write_verbose(ostream &out, int indent_level) const;
00070
00071 public:
00072 virtual void output(ostream &out) const;
00073
00074 virtual bool is_geom_node() const;
00075
00076 protected:
00077 virtual BoundingVolume *recompute_internal_bound();
00078
00079 private:
00080 class GeomEntry {
00081 public:
00082 INLINE GeomEntry(Geom *geom, const RenderState *state);
00083 PT(Geom) _geom;
00084 CPT(RenderState) _state;
00085 };
00086 typedef pvector<GeomEntry> Geoms;
00087
00088
00089 class EXPCL_PANDA CData : public CycleData {
00090 public:
00091 INLINE CData();
00092 CData(const CData ©);
00093 virtual CycleData *make_copy() const;
00094 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00095 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00096 virtual void fillin(DatagramIterator &scan, BamReader *manager);
00097
00098 Geoms _geoms;
00099 };
00100
00101 PipelineCycler<CData> _cycler;
00102 typedef CycleDataReader<CData> CDReader;
00103 typedef CycleDataWriter<CData> CDWriter;
00104
00105 public:
00106 static void register_with_read_factory();
00107 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00108
00109 protected:
00110 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00111 void fillin(DatagramIterator &scan, BamReader *manager);
00112
00113 public:
00114 static TypeHandle get_class_type() {
00115 return _type_handle;
00116 }
00117 static void init_type() {
00118 PandaNode::init_type();
00119 register_type(_type_handle, "GeomNode",
00120 PandaNode::get_class_type());
00121 }
00122 virtual TypeHandle get_type() const {
00123 return get_class_type();
00124 }
00125 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00126
00127 private:
00128 static TypeHandle _type_handle;
00129
00130 friend class PandaNode::Children;
00131 friend class GeomTransformer;
00132 };
00133
00134 #include "geomNode.I"
00135
00136 #endif