Panda3D

polylightNode.h

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, float x = 0.0, float y = 0.0, float z = 0.0,
00042   float r = 1.0, float g = 1.0, float b = 1.0,
00043   float 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(LVecBase3f position);
00062   INLINE void set_pos(float x,float y, float z);
00063   INLINE LVecBase3f get_pos() const;
00064   INLINE void set_color(Colorf color);
00065   INLINE void set_color(float r, float g, float b);
00066   INLINE Colorf get_color() const;
00067   INLINE Colorf get_color_scenegraph() const;
00068   INLINE void set_radius(float r);
00069   INLINE float get_radius() const;
00070   INLINE bool set_attenuation(Attenuation_Type type);
00071   INLINE Attenuation_Type get_attenuation() const;
00072   INLINE void set_a0(float a0);
00073   INLINE void set_a1(float a1);
00074   INLINE void set_a2(float a2);
00075   INLINE float get_a0() const;
00076   INLINE float get_a1() const;
00077   INLINE float 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(float offset);
00084   INLINE float get_offset() const;
00085   INLINE void set_scale(float scale);
00086   INLINE float get_scale() const;
00087   INLINE void set_step_size(float step) ;
00088   INLINE float get_step_size() const;
00089   INLINE void set_freq(float f);
00090   INLINE float 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   Colorf flicker() const;
00102   virtual PandaNode *make_copy() const;
00103 
00104   
00105 private:
00106   bool _enabled;
00107   LVecBase3f _position;
00108   Colorf _color;
00109   float _radius;
00110   Attenuation_Type _attenuation_type;
00111   float _a0;
00112   float _a1;
00113   float _a2;
00114   bool _flickering;
00115   Flicker_Type _flicker_type;
00116   float _offset;
00117   float _scale;
00118   float _step_size;
00119   float _sin_freq;
00120   //float _speed;
00121   //float 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 &params);
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 
 All Classes Functions Variables Enumerations