Panda3D
pointLight.h
1 // Filename: pointLight.h
2 // Created by: mike (09Jan97)
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 POINTLIGHT_H
16 #define POINTLIGHT_H
17 
18 #include "pandabase.h"
19 
20 #include "lightLensNode.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : PointLight
24 // Description : A light originating from a single point in space, and
25 // shining in all directions.
26 ////////////////////////////////////////////////////////////////////
27 class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode {
28 PUBLISHED:
29  PointLight(const string &name);
30 
31 protected:
32  PointLight(const PointLight &copy);
33 
34 public:
35  virtual PandaNode *make_copy() const;
36  virtual void xform(const LMatrix4 &mat);
37  virtual void write(ostream &out, int indent_level) const;
38 
39  virtual bool get_vector_to_light(LVector3 &result,
40  const LPoint3 &from_object_point,
41  const LMatrix4 &to_object_space);
42 
43 PUBLISHED:
44  INLINE const LColor &get_specular_color() const FINAL;
45  INLINE void set_specular_color(const LColor &color);
46 
47  INLINE const LVecBase3 &get_attenuation() const FINAL;
48  INLINE void set_attenuation(const LVecBase3 &attenuation);
49 
50  INLINE const LPoint3 &get_point() const;
51  INLINE void set_point(const LPoint3 &point);
52 
53  virtual int get_class_priority() const;
54 
55 public:
56  virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light,
57  int light_id);
58 
59 private:
60  // This is the data that must be cycled between pipeline stages.
61  class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
62  public:
63  INLINE CData();
64  INLINE CData(const CData &copy);
65  virtual CycleData *make_copy() const;
66  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
67  virtual void fillin(DatagramIterator &scan, BamReader *manager);
68  virtual TypeHandle get_parent_type() const {
69  return PointLight::get_class_type();
70  }
71 
72  LColor _specular_color;
73  LVecBase3 _attenuation;
74  LPoint3 _point;
75  };
76 
77  PipelineCycler<CData> _cycler;
80 
81 public:
82  static void register_with_read_factory();
83  virtual void write_datagram(BamWriter *manager, Datagram &dg);
84 
85 protected:
86  static TypedWritable *make_from_bam(const FactoryParams &params);
87  void fillin(DatagramIterator &scan, BamReader *manager);
88 
89 public:
90  static TypeHandle get_class_type() {
91  return _type_handle;
92  }
93  static void init_type() {
94  LightLensNode::init_type();
95  register_type(_type_handle, "PointLight",
96  LightLensNode::get_class_type());
97  }
98  virtual TypeHandle get_type() const {
99  return get_class_type();
100  }
101  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
102 
103 private:
104  static TypeHandle _type_handle;
105 };
106 
107 INLINE ostream &operator << (ostream &out, const PointLight &light) {
108  light.output(out);
109  return out;
110 }
111 
112 #include "pointLight.I"
113 
114 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
virtual const LColor & get_specular_color() const
Returns the color of specular highlights generated by the light.
Definition: light.cxx:99
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:91
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
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
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: camera.cxx:78
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:34
This describes the structure of a single array within a Geom data.
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
virtual bool get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space)
Computes the vector from a particular vertex to this light.
Definition: light.cxx:136
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual const LVecBase3 & get_attenuation() const
Returns the terms of the attenuation equation for the light.
Definition: light.cxx:113
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
Definition: cycleData.cxx:68
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
Definition: lensNode.cxx:61
A derivative of Light and of Camera.
Definition: lightLensNode.h:35
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
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A light originating from a single point in space, and shining in all directions.
Definition: pointLight.h:27