29 return new CData(*
this);
36 void PointLight::CData::
38 _specular_color.write_datagram(dg);
39 _attenuation.write_datagram(dg);
43 _point.write_datagram(dg);
50 void PointLight::CData::
52 _specular_color.read_datagram(scan);
53 _attenuation.read_datagram(scan);
57 _point.read_datagram(scan);
64 PointLight(
const std::string &name) :
68 lens->set_interocular_distance(0);
69 lens->set_view_vector(1, 0, 0, 0, -1, 0);
72 lens->set_interocular_distance(0);
73 lens->set_view_vector(-1, 0, 0, 0, -1, 0);
76 lens->set_interocular_distance(0);
77 lens->set_view_vector(0, 1, 0, 0, 0, 1);
80 lens->set_interocular_distance(0);
81 lens->set_view_vector(0, -1, 0, 0, 0, -1);
84 lens->set_interocular_distance(0);
85 lens->set_view_vector(0, 0, 1, 0, -1, 0);
88 lens->set_interocular_distance(0);
89 lens->set_view_vector(0, 0, -1, 0, -1, 0);
100 _cycler(copy._cycler)
122 cdata->_point = cdata->_point * mat;
130 write(std::ostream &out,
int indent_level)
const {
131 indent(out, indent_level) << *
this <<
":\n";
132 indent(out, indent_level + 2)
133 <<
"color " << get_color() <<
"\n";
134 if (_has_specular_color) {
135 indent(out, indent_level + 2)
138 indent(out, indent_level + 2)
142 indent(out, indent_level + 2)
161 const LMatrix4 &to_object_space) {
163 LPoint3 point = cdata->_point * to_object_space;
165 result = point - from_object_point;
177 return (
int)CP_point_priority;
185 gsg->bind_light(
this, light, light_id);
193 if (_shadow_map !=
nullptr && _shadow_map->get_x_size() == _sb_size[0]) {
198 if (_sb_size[0] != _sb_size[1]) {
199 pgraphnodes_cat.error()
200 <<
"PointLight shadow buffers must have an equal width and height!\n";
203 if (_shadow_map ==
nullptr) {
204 _shadow_map =
new Texture(get_name());
207 _shadow_map->setup_cube_map(_sb_size[0], Texture::T_unsigned_byte, Texture::F_depth_component);
208 _shadow_map->set_clear_color(LColor(1));
209 _shadow_map->set_wrap_u(SamplerState::WM_clamp);
210 _shadow_map->set_wrap_v(SamplerState::WM_clamp);
213 _shadow_map->set_minfilter(SamplerState::FT_linear);
214 _shadow_map->set_magfilter(SamplerState::FT_linear);
250 node->fillin(scan, manager);
261 LightLensNode::fillin(scan, manager);
264 _has_specular_color = scan.
get_bool();
266 _has_specular_color =
true;
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.
A basic node of the scene graph or data graph.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
bool get_bool()
Extracts a boolean value.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
A base class for any number of different kinds of lenses, linear and otherwise.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single page of data maintained by a PipelineCycler.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Base class for objects that can be written to and read from Bam files.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_bool(bool value)
Adds a boolean value to the datagram.
const LVecBase3 & get_attenuation() const final
Returns the terms of the attenuation equation for the light.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
A perspective-type lens: a normal camera.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PointLight.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_max_distance
Returns the maximum distance at which the light has any effect, as previously specified by set_max_di...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
virtual int get_class_priority() const
Returns the relative priority associated with all lights of this class.
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.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
A light originating from a single point in space, and shining in all directions.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.