Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/geomNode.h

Go to the documentation of this file.
00001 // Filename: geomNode.h
00002 // Created by:  drose (22Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //       Class : GeomNode
00033 // Description : A node that holds Geom objects, renderable pieces of
00034 //               geometry.  This is the primary kind of leaf node in
00035 //               the scene graph; almost all visible objects will be
00036 //               contained in a GeomNode somewhere.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA GeomNode : public PandaNode {
00039 PUBLISHED:
00040   GeomNode(const string &name);
00041 
00042 protected:
00043   GeomNode(const GeomNode &copy);
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   // This is the data that must be cycled between pipeline stages.
00089   class EXPCL_PANDA CData : public CycleData {
00090   public:
00091     INLINE CData();
00092     CData(const CData &copy);
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 &params);
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

Generated on Fri May 2 00:41:41 2003 for Panda by doxygen1.3