00001 // Filename: selectiveChildNode.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 SELECTIVECHILDNODE_H 00020 #define SELECTIVECHILDNODE_H 00021 00022 #include "pandabase.h" 00023 00024 #include "pandaNode.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : SelectiveChildNode 00028 // Description : A base class for nodes like LODNode and SequenceNode 00029 // that select only one visible child at a time. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA SelectiveChildNode : public PandaNode { 00032 PUBLISHED: 00033 INLINE SelectiveChildNode(const string &name); 00034 00035 protected: 00036 INLINE SelectiveChildNode(const SelectiveChildNode ©); 00037 00038 public: 00039 virtual bool has_selective_visibility() const; 00040 virtual int get_first_visible_child() const; 00041 virtual int get_next_visible_child(int n) const; 00042 00043 protected: 00044 INLINE void select_child(int n); 00045 00046 private: 00047 // Not sure if this should be cycled or not. It's not exactly 00048 // thread-safe not to cycle it, but it doesn't really need the full 00049 // pipeline control. It's probably a problem in the non-thread-safe 00050 // design; need to rethink the design a bit. 00051 int _selected_child; 00052 00053 public: 00054 static TypeHandle get_class_type() { 00055 return _type_handle; 00056 } 00057 static void init_type() { 00058 PandaNode::init_type(); 00059 register_type(_type_handle, "SelectiveChildNode", 00060 PandaNode::get_class_type()); 00061 } 00062 virtual TypeHandle get_type() const { 00063 return get_class_type(); 00064 } 00065 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00066 00067 private: 00068 static TypeHandle _type_handle; 00069 }; 00070 00071 #include "selectiveChildNode.I" 00072 00073 #endif