00001 // Filename: switchNode.h 00002 // Created by: drose (31Jul02) 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 SWITCHNODE_H 00020 #define SWITCHNODE_H 00021 00022 #include "pandabase.h" 00023 00024 #include "selectiveChildNode.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : SwitchNode 00028 // Description : A node that renders only one of its children, 00029 // according to the user's indication. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA SwitchNode : public SelectiveChildNode { 00032 PUBLISHED: 00033 INLINE SwitchNode(const string &name); 00034 00035 public: 00036 SwitchNode(const SwitchNode ©); 00037 00038 virtual PandaNode *make_copy() const; 00039 virtual bool safe_to_combine() const; 00040 00041 virtual bool has_cull_callback() const; 00042 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); 00043 virtual bool has_single_child_visibility() const; 00044 00045 PUBLISHED: 00046 INLINE void set_visible_child(int index); 00047 virtual int get_visible_child() const; 00048 00049 private: 00050 class EXPCL_PANDA CData : public CycleData { 00051 public: 00052 INLINE CData(); 00053 INLINE CData(const CData ©); 00054 virtual CycleData *make_copy() const; 00055 virtual void write_datagram(BamWriter *manager, Datagram &dg) const; 00056 virtual void fillin(DatagramIterator &scan, BamReader *manager); 00057 00058 int _visible_child; 00059 }; 00060 00061 PipelineCycler<CData> _cycler; 00062 typedef CycleDataReader<CData> CDReader; 00063 typedef CycleDataWriter<CData> CDWriter; 00064 00065 public: 00066 static void register_with_read_factory(); 00067 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00068 00069 protected: 00070 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00071 void fillin(DatagramIterator &scan, BamReader *manager); 00072 00073 public: 00074 static TypeHandle get_class_type() { 00075 return _type_handle; 00076 } 00077 static void init_type() { 00078 SelectiveChildNode::init_type(); 00079 register_type(_type_handle, "SwitchNode", 00080 SelectiveChildNode::get_class_type()); 00081 } 00082 virtual TypeHandle get_type() const { 00083 return get_class_type(); 00084 } 00085 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00086 00087 private: 00088 static TypeHandle _type_handle; 00089 }; 00090 00091 #include "switchNode.I" 00092 00093 #endif