30 return new CData(*
this);
39 _color.write_datagram(dg);
48 _color.read_datagram(scan);
78 if (_has_color_temperature && _color_temperature == temperature) {
82 _has_color_temperature =
true;
83 _color_temperature = temperature;
88 if (temperature == 6500) {
94 PN_stdfloat mm = 1000.0 / temperature;
95 PN_stdfloat mm2 = mm * mm;
96 PN_stdfloat mm3 = mm2 * mm;
98 if (temperature < 4000) {
99 x = -0.2661239 * mm3 - 0.2343580 * mm2 + 0.8776956 * mm + 0.179910;
101 x = -3.0258469 * mm3 + 2.1070379 * mm2 + 0.2226347 * mm + 0.240390;
104 PN_stdfloat x2 = x * x;
105 PN_stdfloat x3 = x2 * x;
106 if (temperature < 2222) {
107 y = -1.1063814 * x3 - 1.34811020 * x2 + 2.18555832 * x - 0.20219683;
108 }
else if (temperature < 4000) {
109 y = -0.9549476 * x3 - 1.37418593 * x2 + 2.09137015 * x - 0.16748867;
111 y = 3.0817580 * x3 - 5.87338670 * x2 + 3.75112997 * x - 0.37001483;
116 LVecBase3 xyz(x / y, 1, (1 - x - y) / y);
119 const static LMatrix3 xyz_to_rgb(
120 3.2406255, -0.9689307, 0.0557101,
121 -1.537208, 1.8757561, -0.2040211,
122 -0.4986286, 0.0415175, 1.0569959);
124 LColor color(xyz_to_rgb.xform(xyz), 1);
126 CDWriter cdata(_cycler);
127 cdata->_color = color;
147 static const LColor white(1, 1, 1, 1);
158 static const LVecBase3 no_atten(1, 0, 0);
201 if (cdata->_viz_geom_stale) {
204 cdata_w->_viz_geom =
new GeomNode(
"viz");
205 fill_viz_geom(cdata_w->_viz_geom);
206 cdata_w->_viz_geom_stale =
false;
208 return cdata->_viz_geom;
226 dg.
add_bool(_has_color_temperature);
227 if (_has_color_temperature) {
245 _has_color_temperature = scan.
get_bool();
247 _has_color_temperature =
false;
249 if (_has_color_temperature) {
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...
virtual const LColor & get_specular_color() const
Returns the color of specular highlights generated by the light.
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.
A single page of data maintained by a PipelineCycler.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
virtual void attrib_unref()
This is called when the light is removed from a LightAttrib.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int32_t get_int32()
Extracts a signed 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_bool(bool value)
Adds a boolean value to the datagram.
set_color_temperature
Sets the color temperature of the light in kelvins.
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.
GeomNode * get_viz()
Returns a GeomNode that may be rendered to visualize the Light.
virtual bool is_ambient_light() const
Returns true if this is an AmbientLight, false if it is some other kind of light.
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual const LVecBase3 & get_attenuation() const
Returns the terms of the attenuation equation for the light.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
virtual PN_stdfloat get_exponent() const
For spotlights, returns the exponent that controls the amount of light falloff from the center of the...
virtual void attrib_ref()
This is called when the light is added to a LightAttrib.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
A node that holds Geom objects, renderable pieces of geometry.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.