fadeLodNode.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Filename: fadeLodNode.h
  2. // Created by: sshodhan (14Jun04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef FADELODNODE_H
  15. #define FADELODNODE_H
  16. #include "pandabase.h"
  17. #include "lodNode.h"
  18. ////////////////////////////////////////////////////////////////////
  19. // Class : FadeLODNode
  20. // Description : A Level-of-Detail node with alpha based switching.
  21. ////////////////////////////////////////////////////////////////////
  22. class EXPCL_PANDA_PGRAPHNODES FadeLODNode : public LODNode {
  23. PUBLISHED:
  24. FadeLODNode(const string &name);
  25. protected:
  26. FadeLODNode(const FadeLODNode &copy);
  27. public:
  28. virtual PandaNode *make_copy() const;
  29. virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
  30. virtual void output(ostream &out) const;
  31. PUBLISHED:
  32. INLINE void set_fade_time(float t);
  33. INLINE float get_fade_time() const;
  34. void set_fade_bin(const string &name, int draw_order);
  35. INLINE const string &get_fade_bin_name() const;
  36. INLINE int get_fade_bin_draw_order() const;
  37. void set_fade_state_override(int override);
  38. INLINE int get_fade_state_override() const;
  39. private:
  40. CPT(RenderState) get_fade_1_old_state();
  41. CPT(RenderState) get_fade_1_new_state(float in_alpha);
  42. CPT(RenderState) get_fade_2_old_state(float out_alpha);
  43. CPT(RenderState) get_fade_2_new_state();
  44. private:
  45. float _fade_time;
  46. string _fade_bin_name;
  47. int _fade_bin_draw_order;
  48. int _fade_state_override;
  49. CPT(RenderState) _fade_1_new_state;
  50. CPT(RenderState) _fade_1_old_state;
  51. CPT(RenderState) _fade_2_new_state;
  52. CPT(RenderState) _fade_2_old_state;
  53. public:
  54. static void register_with_read_factory();
  55. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  56. protected:
  57. static TypedWritable *make_from_bam(const FactoryParams &params);
  58. void fillin(DatagramIterator &scan, BamReader *manager);
  59. public:
  60. static TypeHandle get_class_type() {
  61. return _type_handle;
  62. }
  63. static void init_type() {
  64. LODNode::init_type();
  65. register_type(_type_handle, "FadeLODNode",
  66. LODNode::get_class_type());
  67. }
  68. virtual TypeHandle get_type() const {
  69. return get_class_type();
  70. }
  71. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  72. private:
  73. static TypeHandle _type_handle;
  74. };
  75. #include "fadeLodNode.I"
  76. #endif