Panda3D
sphereLight.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 sphereLight.h
10  * @author rdb
11  * @date 2016-04-15
12  */
13 
14 #ifndef SPHERELIGHT_H
15 #define SPHERELIGHT_H
16 
17 #include "pandabase.h"
18 
19 #include "lightLensNode.h"
20 #include "pointLight.h"
21 
22 /**
23  * A sphere light is like a point light, except that it represents a sphere
24  * with a radius, rather than being an infinitely thin point in space.
25  */
26 class EXPCL_PANDA_PGRAPHNODES SphereLight : public PointLight {
27 PUBLISHED:
28  explicit SphereLight(const std::string &name);
29 
30 protected:
31  SphereLight(const SphereLight &copy);
32 
33 public:
34  virtual PandaNode *make_copy() const;
35  virtual void xform(const LMatrix4 &mat);
36  virtual void write(std::ostream &out, int indent_level) const;
37 
38 PUBLISHED:
39  INLINE PN_stdfloat get_radius() const;
40  INLINE void set_radius(PN_stdfloat radius);
41  MAKE_PROPERTY(radius, get_radius, set_radius);
42 
43 private:
44  // This is the data that must be cycled between pipeline stages.
45  class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
46  public:
47  INLINE CData();
48  INLINE CData(const CData &copy);
49  virtual CycleData *make_copy() const;
50  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
51  virtual void fillin(DatagramIterator &scan, BamReader *manager);
52  virtual TypeHandle get_parent_type() const {
53  return SphereLight::get_class_type();
54  }
55 
56  PN_stdfloat _radius;
57  };
58 
59  PipelineCycler<CData> _cycler;
60  typedef CycleDataReader<CData> CDReader;
61  typedef CycleDataWriter<CData> CDWriter;
62 
63 public:
64  static void register_with_read_factory();
65  virtual void write_datagram(BamWriter *manager, Datagram &dg);
66 
67 protected:
68  static TypedWritable *make_from_bam(const FactoryParams &params);
69  void fillin(DatagramIterator &scan, BamReader *manager);
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76  PointLight::init_type();
77  register_type(_type_handle, "SphereLight",
78  PointLight::get_class_type());
79  }
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84 
85 private:
86  static TypeHandle _type_handle;
87 };
88 
89 #include "sphereLight.I"
90 
91 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
Definition: pointLight.cxx:119
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:47
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(), along with zero to four record_derivation()s.
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:76
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pointLight.cxx:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
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:32
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:58
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A light originating from a single point in space, and shining in all directions.
Definition: pointLight.h:25
A sphere light is like a point light, except that it represents a sphere with a radius, rather than being an infinitely thin point in space.
Definition: sphereLight.h:26