polylightNode.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // Filename: PolylightNode.h
  2. // Created by: sshodhan (02Jun04)
  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 POLYLIGHTNODE_H
  15. #define POLYLIGHTNODE_H
  16. #include "pandabase.h"
  17. #include "luse.h"
  18. #include "nodePath.h"
  19. #include "pmap.h"
  20. #include "pnotify.h"
  21. #include "pandaNode.h"
  22. #include "colorAttrib.h"
  23. ////////////////////////////////////////////////////////////////////
  24. // Class : PolylightNode
  25. // Description : A PolylightNode
  26. ////////////////////////////////////////////////////////////////////
  27. class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{
  28. //private:
  29. PUBLISHED:
  30. /*
  31. // This was the old constructor... interrogate would generate a
  32. // separate wrapper for each parameter... so its better to
  33. // have a simpler constructor and require the programmer
  34. // to use set_* methods.
  35. PolylightNode(const string &name, float x = 0.0, float y = 0.0, float z = 0.0,
  36. float r = 1.0, float g = 1.0, float b = 1.0,
  37. float radius=50.0, string attenuation_type= "linear",
  38. bool flickering =false, string flicker_type="random");
  39. */
  40. enum Flicker_Type {
  41. FRANDOM,
  42. FSIN,
  43. FCUSTOM,
  44. };
  45. enum Attenuation_Type {
  46. ALINEAR,
  47. AQUADRATIC,
  48. };
  49. PolylightNode(const string &name);
  50. INLINE void enable();
  51. INLINE void disable();
  52. INLINE void set_pos(LVecBase3f position);
  53. INLINE void set_pos(float x,float y, float z);
  54. INLINE LVecBase3f get_pos() const;
  55. INLINE void set_color(Colorf color);
  56. INLINE void set_color(float r, float g, float b);
  57. INLINE Colorf get_color() const;
  58. INLINE Colorf get_color_scenegraph() const;
  59. INLINE void set_radius(float r);
  60. INLINE float get_radius() const;
  61. INLINE bool set_attenuation(Attenuation_Type type);
  62. INLINE Attenuation_Type get_attenuation() const;
  63. INLINE void set_a0(float a0);
  64. INLINE void set_a1(float a1);
  65. INLINE void set_a2(float a2);
  66. INLINE float get_a0() const;
  67. INLINE float get_a1() const;
  68. INLINE float get_a2() const;
  69. INLINE void flicker_on();
  70. INLINE void flicker_off();
  71. INLINE bool is_flickering() const;
  72. INLINE bool set_flicker_type(Flicker_Type type);
  73. INLINE Flicker_Type get_flicker_type() const;
  74. INLINE void set_offset(float offset);
  75. INLINE float get_offset() const;
  76. INLINE void set_scale(float scale);
  77. INLINE float get_scale() const;
  78. INLINE void set_step_size(float step) ;
  79. INLINE float get_step_size() const;
  80. INLINE void set_freq(float f);
  81. INLINE float get_freq() const;
  82. // Comparison methods
  83. INLINE bool operator == (const PolylightNode &other) const;
  84. INLINE bool operator != (const PolylightNode &other) const;
  85. INLINE bool operator < (const PolylightNode &other) const;
  86. int compare_to(const PolylightNode &other) const;
  87. INLINE bool is_enabled() const;
  88. public:
  89. Colorf flicker() const;
  90. virtual PandaNode *make_copy() const;
  91. private:
  92. bool _enabled;
  93. LVecBase3f _position;
  94. Colorf _color;
  95. float _radius;
  96. Attenuation_Type _attenuation_type;
  97. float _a0;
  98. float _a1;
  99. float _a2;
  100. bool _flickering;
  101. Flicker_Type _flicker_type;
  102. float _offset;
  103. float _scale;
  104. float _step_size;
  105. float _sin_freq;
  106. //float _speed;
  107. //float fixed_points
  108. public:
  109. static void register_with_read_factory();
  110. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  111. virtual void output(ostream &out) const;
  112. protected:
  113. static TypedWritable *make_from_bam(const FactoryParams &params);
  114. void fillin(DatagramIterator &scan, BamReader *manager);
  115. public:
  116. static TypeHandle get_class_type() {
  117. return _type_handle;
  118. }
  119. static void init_type() {
  120. PandaNode::init_type();
  121. register_type(_type_handle, "PolylightNode",
  122. PandaNode::get_class_type());
  123. }
  124. virtual TypeHandle get_type() const {
  125. return get_class_type();
  126. }
  127. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  128. private:
  129. static TypeHandle _type_handle;
  130. };
  131. #include "polylightNode.I"
  132. #endif