Panda3D
polylightNode.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file polylightNode.h
10  * @author sshodhan
11  * @date 2004-06-02
12  */
13 
14 #ifndef POLYLIGHTNODE_H
15 #define POLYLIGHTNODE_H
16 
17 #include "pandabase.h"
18 
19 #include "luse.h"
20 #include "nodePath.h"
21 #include "pmap.h"
22 #include "pnotify.h"
23 #include "pandaNode.h"
24 #include "colorAttrib.h"
25 
26 /**
27  * A PolylightNode
28  */
29 class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{
30 // private:
31 
32 
33 PUBLISHED:
34  /*
35  // This was the old constructor... interrogate would generate a separate
36  // wrapper for each parameter... so its better to have a simpler constructor
37  // and require the programmer to use set_* methods.
38  PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0,
39  PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0,
40  PN_stdfloat radius=50.0, string attenuation_type= "linear",
41  bool flickering =false, string flicker_type="random");
42  */
43 
44  enum Flicker_Type {
45  FRANDOM,
46  FSIN,
47  FCUSTOM,
48  };
49 
50  enum Attenuation_Type {
51  ALINEAR,
52  AQUADRATIC,
53  };
54 
55  explicit PolylightNode(const std::string &name);
56  INLINE void enable();
57  INLINE void disable();
58  INLINE void set_pos(const LPoint3 &position);
59  INLINE void set_pos(PN_stdfloat x,PN_stdfloat y, PN_stdfloat z);
60  INLINE LPoint3 get_pos() const;
61  INLINE void set_color(const LColor &color);
62  INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b);
63  INLINE LColor get_color() const;
64  INLINE LColor get_color_scenegraph() const;
65  INLINE void set_radius(PN_stdfloat r);
66  INLINE PN_stdfloat get_radius() const;
67  INLINE bool set_attenuation(Attenuation_Type type);
68  INLINE Attenuation_Type get_attenuation() const;
69  INLINE void set_a0(PN_stdfloat a0);
70  INLINE void set_a1(PN_stdfloat a1);
71  INLINE void set_a2(PN_stdfloat a2);
72  INLINE PN_stdfloat get_a0() const;
73  INLINE PN_stdfloat get_a1() const;
74  INLINE PN_stdfloat get_a2() const;
75  INLINE void flicker_on();
76  INLINE void flicker_off();
77  INLINE bool is_flickering() const;
78  INLINE bool set_flicker_type(Flicker_Type type);
79  INLINE Flicker_Type get_flicker_type() const;
80  INLINE void set_offset(PN_stdfloat offset);
81  INLINE PN_stdfloat get_offset() const;
82  INLINE void set_scale(PN_stdfloat scale);
83  INLINE PN_stdfloat get_scale() const;
84  INLINE void set_step_size(PN_stdfloat step) ;
85  INLINE PN_stdfloat get_step_size() const;
86  INLINE void set_freq(PN_stdfloat f);
87  INLINE PN_stdfloat get_freq() const;
88 
89  // Comparison methods
90  INLINE bool operator == (const PolylightNode &other) const;
91  INLINE bool operator != (const PolylightNode &other) const;
92  INLINE bool operator < (const PolylightNode &other) const;
93  int compare_to(const PolylightNode &other) const;
94 
95  INLINE bool is_enabled() const;
96 
97 public:
98  LColor flicker() const;
99  virtual PandaNode *make_copy() const;
100  virtual void xform(const LMatrix4 &mat);
101 
102 private:
103  bool _enabled;
104  LPoint3 _position;
105  LColor _color;
106  PN_stdfloat _radius;
107  Attenuation_Type _attenuation_type;
108  PN_stdfloat _a0;
109  PN_stdfloat _a1;
110  PN_stdfloat _a2;
111  bool _flickering;
112  Flicker_Type _flicker_type;
113  PN_stdfloat _offset;
114  PN_stdfloat _scale;
115  PN_stdfloat _step_size;
116  PN_stdfloat _sin_freq;
117  // PN_stdfloat _speed; PN_stdfloat fixed_points
118 
119 
120 public:
121  static void register_with_read_factory();
122  virtual void write_datagram(BamWriter *manager, Datagram &dg);
123  virtual void output(std::ostream &out) const;
124 
125 protected:
126  static TypedWritable *make_from_bam(const FactoryParams &params);
127  void fillin(DatagramIterator &scan, BamReader *manager);
128 
129 
130 
131 public:
132  static TypeHandle get_class_type() {
133  return _type_handle;
134  }
135  static void init_type() {
136  PandaNode::init_type();
137  register_type(_type_handle, "PolylightNode",
138  PandaNode::get_class_type());
139  }
140  virtual TypeHandle get_type() const {
141  return get_class_type();
142  }
143  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
144 
145 private:
146  static TypeHandle _type_handle;
147 };
148 
149 #include "polylightNode.I"
150 
151 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:3589
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:3580
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:310
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
A PolylightNode.
Definition: polylightNode.h:29
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:487
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:73
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38