Panda3D
|
00001 // Filename: PolylightNode.h 00002 // Created by: sshodhan (02Jun04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef POLYLIGHTNODE_H 00016 #define POLYLIGHTNODE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "luse.h" 00021 #include "nodePath.h" 00022 #include "pmap.h" 00023 #include "pnotify.h" 00024 #include "pandaNode.h" 00025 #include "colorAttrib.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : PolylightNode 00029 // Description : A PolylightNode 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{ 00032 //private: 00033 00034 00035 PUBLISHED: 00036 /* 00037 // This was the old constructor... interrogate would generate a 00038 // separate wrapper for each parameter... so its better to 00039 // have a simpler constructor and require the programmer 00040 // to use set_* methods. 00041 PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0, 00042 PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0, 00043 PN_stdfloat radius=50.0, string attenuation_type= "linear", 00044 bool flickering =false, string flicker_type="random"); 00045 */ 00046 00047 enum Flicker_Type { 00048 FRANDOM, 00049 FSIN, 00050 FCUSTOM, 00051 }; 00052 00053 enum Attenuation_Type { 00054 ALINEAR, 00055 AQUADRATIC, 00056 }; 00057 00058 PolylightNode(const string &name); 00059 INLINE void enable(); 00060 INLINE void disable(); 00061 INLINE void set_pos(const LVecBase3 &position); 00062 INLINE void set_pos(PN_stdfloat x,PN_stdfloat y, PN_stdfloat z); 00063 INLINE LVecBase3 get_pos() const; 00064 INLINE void set_color(const LColor &color); 00065 INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b); 00066 INLINE LColor get_color() const; 00067 INLINE LColor get_color_scenegraph() const; 00068 INLINE void set_radius(PN_stdfloat r); 00069 INLINE PN_stdfloat get_radius() const; 00070 INLINE bool set_attenuation(Attenuation_Type type); 00071 INLINE Attenuation_Type get_attenuation() const; 00072 INLINE void set_a0(PN_stdfloat a0); 00073 INLINE void set_a1(PN_stdfloat a1); 00074 INLINE void set_a2(PN_stdfloat a2); 00075 INLINE PN_stdfloat get_a0() const; 00076 INLINE PN_stdfloat get_a1() const; 00077 INLINE PN_stdfloat get_a2() const; 00078 INLINE void flicker_on(); 00079 INLINE void flicker_off(); 00080 INLINE bool is_flickering() const; 00081 INLINE bool set_flicker_type(Flicker_Type type); 00082 INLINE Flicker_Type get_flicker_type() const; 00083 INLINE void set_offset(PN_stdfloat offset); 00084 INLINE PN_stdfloat get_offset() const; 00085 INLINE void set_scale(PN_stdfloat scale); 00086 INLINE PN_stdfloat get_scale() const; 00087 INLINE void set_step_size(PN_stdfloat step) ; 00088 INLINE PN_stdfloat get_step_size() const; 00089 INLINE void set_freq(PN_stdfloat f); 00090 INLINE PN_stdfloat get_freq() const; 00091 00092 // Comparison methods 00093 INLINE bool operator == (const PolylightNode &other) const; 00094 INLINE bool operator != (const PolylightNode &other) const; 00095 INLINE bool operator < (const PolylightNode &other) const; 00096 int compare_to(const PolylightNode &other) const; 00097 00098 INLINE bool is_enabled() const; 00099 00100 public: 00101 LColor flicker() const; 00102 virtual PandaNode *make_copy() const; 00103 00104 00105 private: 00106 bool _enabled; 00107 LVecBase3 _position; 00108 LColor _color; 00109 PN_stdfloat _radius; 00110 Attenuation_Type _attenuation_type; 00111 PN_stdfloat _a0; 00112 PN_stdfloat _a1; 00113 PN_stdfloat _a2; 00114 bool _flickering; 00115 Flicker_Type _flicker_type; 00116 PN_stdfloat _offset; 00117 PN_stdfloat _scale; 00118 PN_stdfloat _step_size; 00119 PN_stdfloat _sin_freq; 00120 //PN_stdfloat _speed; 00121 //PN_stdfloat fixed_points 00122 00123 00124 public: 00125 static void register_with_read_factory(); 00126 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00127 virtual void output(ostream &out) const; 00128 00129 protected: 00130 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00131 void fillin(DatagramIterator &scan, BamReader *manager); 00132 00133 00134 00135 public: 00136 static TypeHandle get_class_type() { 00137 return _type_handle; 00138 } 00139 static void init_type() { 00140 PandaNode::init_type(); 00141 register_type(_type_handle, "PolylightNode", 00142 PandaNode::get_class_type()); 00143 } 00144 virtual TypeHandle get_type() const { 00145 return get_class_type(); 00146 } 00147 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00148 00149 private: 00150 static TypeHandle _type_handle; 00151 }; 00152 00153 #include "polylightNode.I" 00154 00155 #endif 00156 00157