sequenceNode.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Filename: sequenceNode.h
  2. // Created by: drose (06Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef SEQUENCENODE_H
  19. #define SEQUENCENODE_H
  20. #include "pandabase.h"
  21. #include "selectiveChildNode.h"
  22. #include "clockObject.h"
  23. ////////////////////////////////////////////////////////////////////
  24. // Class : SequenceNode
  25. // Description : A node that automatically cycles through rendering
  26. // each one of its children according to its frame rate.
  27. ////////////////////////////////////////////////////////////////////
  28. class EXPCL_PANDA SequenceNode : public SelectiveChildNode {
  29. PUBLISHED:
  30. INLINE SequenceNode(float cycle_rate, const string &name);
  31. public:
  32. SequenceNode(const SequenceNode &copy);
  33. virtual PandaNode *make_copy() const;
  34. virtual bool safe_to_combine() const;
  35. virtual bool has_cull_callback() const;
  36. virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
  37. virtual bool has_single_child_visibility() const;
  38. PUBLISHED:
  39. INLINE void set_cycle_rate(float cycle_rate);
  40. INLINE float get_cycle_rate() const;
  41. INLINE void set_visible_child(int index);
  42. virtual int get_visible_child() const;
  43. private:
  44. INLINE float calc_frame(float now) const;
  45. INLINE float calc_frame() const;
  46. class EXPCL_PANDA CData : public CycleData {
  47. public:
  48. INLINE CData();
  49. INLINE CData(const CData &copy);
  50. virtual CycleData *make_copy() const;
  51. virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
  52. virtual void fillin(DatagramIterator &scan, BamReader *manager);
  53. float _cycle_rate;
  54. float _frame_offset;
  55. float _start_time;
  56. };
  57. PipelineCycler<CData> _cycler;
  58. typedef CycleDataReader<CData> CDReader;
  59. typedef CycleDataWriter<CData> CDWriter;
  60. public:
  61. static void register_with_read_factory();
  62. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  63. protected:
  64. static TypedWritable *make_from_bam(const FactoryParams &params);
  65. void fillin(DatagramIterator &scan, BamReader *manager);
  66. public:
  67. static TypeHandle get_class_type() {
  68. return _type_handle;
  69. }
  70. static void init_type() {
  71. SelectiveChildNode::init_type();
  72. register_type(_type_handle, "SequenceNode",
  73. SelectiveChildNode::get_class_type());
  74. }
  75. virtual TypeHandle get_type() const {
  76. return get_class_type();
  77. }
  78. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  79. private:
  80. static TypeHandle _type_handle;
  81. };
  82. #include "sequenceNode.I"
  83. #endif