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

panda/src/pgraph/lodNode.h

Go to the documentation of this file.
00001 // Filename: lodNode.h
00002 // Created by:  drose (06Mar02)
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 LODNODE_H
00020 #define LODNODE_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "selectiveChildNode.h"
00025 
00026 #include "LOD.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : LODNode
00030 // Description : A Level-of-Detail node.  This selects only one of its
00031 //               children for rendering, according to the distance
00032 //               from the camera and the table indicated in the
00033 //               associated LOD object.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA LODNode : public SelectiveChildNode {
00036 PUBLISHED:
00037   INLINE LODNode(const string &name);
00038 
00039 protected:
00040   INLINE LODNode(const LODNode &copy);
00041 public:
00042   virtual PandaNode *make_copy() const;
00043   virtual bool safe_to_combine() const;
00044   virtual void xform(const LMatrix4f &mat);
00045   virtual bool has_cull_callback() const;
00046   virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00047 
00048   virtual void output(ostream &out) const;
00049 
00050 PUBLISHED:
00051   // The sense of in vs. out distances is as if the object were coming
00052   // towards you from far away: it switches "in" at the far distance,
00053   // and switches "out" at the close distance.  Thus, "in" should be
00054   // larger than "out".
00055 
00056   INLINE void add_switch(float in, float out);
00057   INLINE bool set_switch(int index, float in, float out);
00058   INLINE void clear_switches(void);
00059 
00060   INLINE int get_num_switches() const;
00061   INLINE float get_in(int index) const;
00062   INLINE float get_out(int index) const;
00063 
00064   INLINE void set_center(const LPoint3f &center);
00065   INLINE const LPoint3f &get_center() const;
00066 
00067 public:
00068   static void register_with_read_factory();
00069   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00070 
00071 protected:
00072   static TypedWritable *make_from_bam(const FactoryParams &params);
00073   void fillin(DatagramIterator &scan, BamReader *manager);
00074 
00075 private:
00076   class EXPCL_PANDA CData : public CycleData {
00077   public:
00078     INLINE CData();
00079     INLINE CData(const CData &copy);
00080     virtual CycleData *make_copy() const;
00081     virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00082     virtual void fillin(DatagramIterator &scan, BamReader *manager);
00083 
00084     LOD _lod;
00085   };
00086 
00087   PipelineCycler<CData> _cycler;
00088   typedef CycleDataReader<CData> CDReader;
00089   typedef CycleDataWriter<CData> CDWriter;
00090 
00091 public:
00092   static TypeHandle get_class_type() {
00093     return _type_handle;
00094   }
00095   static void init_type() {
00096     SelectiveChildNode::init_type();
00097     register_type(_type_handle, "LODNode",
00098                   SelectiveChildNode::get_class_type());
00099   }
00100   virtual TypeHandle get_type() const {
00101     return get_class_type();
00102   }
00103   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00104 
00105 private:
00106   static TypeHandle _type_handle;
00107 };
00108 
00109 #include "lodNode.I"
00110 
00111 #endif

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