sliderTable.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Filename: sliderTable.h
  2. // Created by: drose (28Mar05)
  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 SLIDERTABLE_H
  19. #define SLIDERTABLE_H
  20. #include "pandabase.h"
  21. #include "vertexSlider.h"
  22. #include "typedWritableReferenceCount.h"
  23. #include "pointerTo.h"
  24. #include "pmap.h"
  25. #include "cycleData.h"
  26. #include "cycleDataReader.h"
  27. #include "cycleDataWriter.h"
  28. #include "pipelineCycler.h"
  29. ////////////////////////////////////////////////////////////////////
  30. // Class : SliderTable
  31. // Description : Stores the total set of VertexSliders that the
  32. // vertices in a particular GeomVertexData object might
  33. // depend on.
  34. //
  35. // This is similar to a TransformTable, but it stores
  36. // VertexSliders instead of VertexTransforms, and it
  37. // stores them by name instead of by index number.
  38. // Also, it is only used when animating vertices on the
  39. // CPU, since GPU's don't support morphs at this point
  40. // in time.
  41. ////////////////////////////////////////////////////////////////////
  42. class EXPCL_PANDA SliderTable : public TypedWritableReferenceCount {
  43. PUBLISHED:
  44. SliderTable();
  45. SliderTable(const SliderTable &copy);
  46. void operator = (const SliderTable &copy);
  47. virtual ~SliderTable();
  48. INLINE bool is_registered() const;
  49. INLINE static CPT(SliderTable) register_table(const SliderTable *table);
  50. INLINE int get_num_sliders() const;
  51. INLINE const VertexSlider *get_slider(int n) const;
  52. INLINE const VertexSlider *find_slider(const InternalName *name) const;
  53. INLINE bool has_slider(const InternalName *name) const;
  54. INLINE bool is_empty() const;
  55. INLINE UpdateSeq get_modified() const;
  56. void set_slider(int n, const VertexSlider *slider);
  57. void remove_slider(int n);
  58. int add_slider(const VertexSlider *slider);
  59. void write(ostream &out) const;
  60. private:
  61. void do_register();
  62. void do_unregister();
  63. INLINE void update_modified(UpdateSeq modified);
  64. private:
  65. bool _is_registered;
  66. typedef pvector< CPT(VertexSlider) > Sliders;
  67. Sliders _sliders;
  68. typedef pmap< CPT(InternalName), const VertexSlider *> SlidersByName;
  69. SlidersByName _sliders_by_name;
  70. // This is the data that must be cycled between pipeline stages.
  71. class EXPCL_PANDA CData : public CycleData {
  72. public:
  73. INLINE CData();
  74. INLINE CData(const CData &copy);
  75. virtual CycleData *make_copy() const;
  76. virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
  77. virtual void fillin(DatagramIterator &scan, BamReader *manager);
  78. virtual TypeHandle get_parent_type() const {
  79. return SliderTable::get_class_type();
  80. }
  81. UpdateSeq _modified;
  82. };
  83. PipelineCycler<CData> _cycler;
  84. typedef CycleDataReader<CData> CDReader;
  85. typedef CycleDataWriter<CData> CDWriter;
  86. public:
  87. static void register_with_read_factory();
  88. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  89. virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
  90. protected:
  91. static TypedWritable *make_from_bam(const FactoryParams &params);
  92. void fillin(DatagramIterator &scan, BamReader *manager);
  93. public:
  94. static TypeHandle get_class_type() {
  95. return _type_handle;
  96. }
  97. static void init_type() {
  98. TypedWritableReferenceCount::init_type();
  99. register_type(_type_handle, "SliderTable",
  100. TypedWritableReferenceCount::get_class_type());
  101. }
  102. virtual TypeHandle get_type() const {
  103. return get_class_type();
  104. }
  105. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  106. private:
  107. static TypeHandle _type_handle;
  108. friend class VertexSlider;
  109. };
  110. INLINE ostream &operator << (ostream &out, const SliderTable &obj);
  111. #include "sliderTable.I"
  112. #endif