polylightNode.h 4.4 KB

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