Panda3D
polylightNode.h
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 
15 #ifndef POLYLIGHTNODE_H
16 #define POLYLIGHTNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "luse.h"
21 #include "nodePath.h"
22 #include "pmap.h"
23 #include "pnotify.h"
24 #include "pandaNode.h"
25 #include "colorAttrib.h"
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : PolylightNode
29 // Description : A PolylightNode
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{
32 //private:
33 
34 
35 PUBLISHED:
36  /*
37  // This was the old constructor... interrogate would generate a
38  // separate wrapper for each parameter... so its better to
39  // have a simpler constructor and require the programmer
40  // to use set_* methods.
41  PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0,
42  PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0,
43  PN_stdfloat radius=50.0, string attenuation_type= "linear",
44  bool flickering =false, string flicker_type="random");
45  */
46 
47  enum Flicker_Type {
48  FRANDOM,
49  FSIN,
50  FCUSTOM,
51  };
52 
53  enum Attenuation_Type {
54  ALINEAR,
55  AQUADRATIC,
56  };
57 
58  PolylightNode(const string &name);
59  INLINE void enable();
60  INLINE void disable();
61  INLINE void set_pos(const LPoint3 &position);
62  INLINE void set_pos(PN_stdfloat x,PN_stdfloat y, PN_stdfloat z);
63  INLINE LPoint3 get_pos() const;
64  INLINE void set_color(const LColor &color);
65  INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b);
66  INLINE LColor get_color() const;
67  INLINE LColor get_color_scenegraph() const;
68  INLINE void set_radius(PN_stdfloat r);
69  INLINE PN_stdfloat get_radius() const;
70  INLINE bool set_attenuation(Attenuation_Type type);
71  INLINE Attenuation_Type get_attenuation() const;
72  INLINE void set_a0(PN_stdfloat a0);
73  INLINE void set_a1(PN_stdfloat a1);
74  INLINE void set_a2(PN_stdfloat a2);
75  INLINE PN_stdfloat get_a0() const;
76  INLINE PN_stdfloat get_a1() const;
77  INLINE PN_stdfloat get_a2() const;
78  INLINE void flicker_on();
79  INLINE void flicker_off();
80  INLINE bool is_flickering() const;
81  INLINE bool set_flicker_type(Flicker_Type type);
82  INLINE Flicker_Type get_flicker_type() const;
83  INLINE void set_offset(PN_stdfloat offset);
84  INLINE PN_stdfloat get_offset() const;
85  INLINE void set_scale(PN_stdfloat scale);
86  INLINE PN_stdfloat get_scale() const;
87  INLINE void set_step_size(PN_stdfloat step) ;
88  INLINE PN_stdfloat get_step_size() const;
89  INLINE void set_freq(PN_stdfloat f);
90  INLINE PN_stdfloat get_freq() const;
91 
92  // Comparison methods
93  INLINE bool operator == (const PolylightNode &other) const;
94  INLINE bool operator != (const PolylightNode &other) const;
95  INLINE bool operator < (const PolylightNode &other) const;
96  int compare_to(const PolylightNode &other) const;
97 
98  INLINE bool is_enabled() const;
99 
100 public:
101  LColor flicker() const;
102  virtual PandaNode *make_copy() const;
103  virtual void xform(const LMatrix4 &mat);
104 
105 private:
106  bool _enabled;
107  LPoint3 _position;
108  LColor _color;
109  PN_stdfloat _radius;
110  Attenuation_Type _attenuation_type;
111  PN_stdfloat _a0;
112  PN_stdfloat _a1;
113  PN_stdfloat _a2;
114  bool _flickering;
115  Flicker_Type _flicker_type;
116  PN_stdfloat _offset;
117  PN_stdfloat _scale;
118  PN_stdfloat _step_size;
119  PN_stdfloat _sin_freq;
120  //PN_stdfloat _speed;
121  //PN_stdfloat fixed_points
122 
123 
124 public:
125  static void register_with_read_factory();
126  virtual void write_datagram(BamWriter *manager, Datagram &dg);
127  virtual void output(ostream &out) const;
128 
129 protected:
130  static TypedWritable *make_from_bam(const FactoryParams &params);
131  void fillin(DatagramIterator &scan, BamReader *manager);
132 
133 
134 
135 public:
136  static TypeHandle get_class_type() {
137  return _type_handle;
138  }
139  static void init_type() {
140  PandaNode::init_type();
141  register_type(_type_handle, "PolylightNode",
142  PandaNode::get_class_type());
143  }
144  virtual TypeHandle get_type() const {
145  return get_class_type();
146  }
147  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
148 
149 private:
150  static TypeHandle _type_handle;
151 };
152 
153 #include "polylightNode.I"
154 
155 #endif
156 
157 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: pandaNode.cxx:4164
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:4153
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
Definition: pandaNode.cxx:377
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
A PolylightNode.
Definition: polylightNode.h:31
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43