Panda3D
Loading...
Searching...
No Matches
pointLight.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 pointLight.h
10 * @author mike
11 * @date 1997-01-09
12 */
13
14#ifndef POINTLIGHT_H
15#define POINTLIGHT_H
16
17#include "pandabase.h"
18
19#include "lightLensNode.h"
20
21/**
22 * A light originating from a single point in space, and shining in all
23 * directions.
24 */
25class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode {
26PUBLISHED:
27 explicit PointLight(const std::string &name);
28
29protected:
30 PointLight(const PointLight &copy);
31
32public:
33 virtual PandaNode *make_copy() const;
34 virtual void xform(const LMatrix4 &mat);
35 virtual void write(std::ostream &out, int indent_level) const;
36
37 virtual bool get_vector_to_light(LVector3 &result,
38 const LPoint3 &from_object_point,
39 const LMatrix4 &to_object_space);
40
41PUBLISHED:
42 INLINE const LColor &get_specular_color() const final;
43 INLINE void set_specular_color(const LColor &color);
44 INLINE void clear_specular_color();
45 MAKE_PROPERTY(specular_color, get_specular_color, set_specular_color);
46
47 INLINE const LVecBase3 &get_attenuation() const final;
48 INLINE void set_attenuation(const LVecBase3 &attenuation);
49 MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation);
50
51 INLINE PN_stdfloat get_max_distance() const;
52 INLINE void set_max_distance(PN_stdfloat max_distance);
53 MAKE_PROPERTY(max_distance, get_max_distance, set_max_distance);
54
55 INLINE const LPoint3 &get_point() const;
56 INLINE void set_point(const LPoint3 &point);
57 MAKE_PROPERTY(point, get_point, set_point);
58
59 virtual int get_class_priority() const;
60
61public:
62 virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light,
63 int light_id);
64
65private:
66 virtual void setup_shadow_map();
67
68 // This is the data that must be cycled between pipeline stages.
69 class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
70 public:
71 INLINE CData();
72 INLINE CData(const CData &copy);
73 virtual CycleData *make_copy() const;
74 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
75 virtual void fillin(DatagramIterator &scan, BamReader *manager);
76 virtual TypeHandle get_parent_type() const {
77 return PointLight::get_class_type();
78 }
79
80 LColor _specular_color;
81 LVecBase3 _attenuation;
82 PN_stdfloat _max_distance;
83 LPoint3 _point;
84 };
85
87 typedef CycleDataReader<CData> CDReader;
88 typedef CycleDataWriter<CData> CDWriter;
89
90public:
91 static void register_with_read_factory();
92 virtual void write_datagram(BamWriter *manager, Datagram &dg);
93
94protected:
95 static TypedWritable *make_from_bam(const FactoryParams &params);
96 void fillin(DatagramIterator &scan, BamReader *manager);
97
98public:
99 static TypeHandle get_class_type() {
100 return _type_handle;
101 }
102 static void init_type() {
103 LightLensNode::init_type();
104 register_type(_type_handle, "PointLight",
105 LightLensNode::get_class_type());
106 }
107 virtual TypeHandle get_type() const {
108 return get_class_type();
109 }
110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
111
112private:
113 static TypeHandle _type_handle;
114};
115
116INLINE std::ostream &operator << (std::ostream &out, const PointLight &light) {
117 light.output(out);
118 return out;
119}
120
121#include "pointLight.I"
122
123#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition camera.cxx:69
static void register_with_read_factory()
Tells the BamReader how to create objects of type Camera.
Definition camera.cxx:262
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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:53
A derivative of Light and of Camera.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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:189
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
A light originating from a single point in space, and shining in all directions.
Definition pointLight.h:25
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...