30 LightLensNode(
const std::string &name,
Lens *lens) :
32 _has_specular_color(false),
34 _used_by_auto_shader(false)
37 _shadow_caster =
false;
38 _sb_size.set(512, 512);
42 set_initial_state(RenderState::make(CullFaceAttrib::make_reverse(),
43 ColorWriteAttrib::make(ColorWriteAttrib::C_off)));
52 clear_shadow_buffers();
66 _shadow_caster(copy._shadow_caster),
67 _sb_size(copy._sb_size),
69 _has_specular_color(copy._has_specular_color),
71 _used_by_auto_shader(false)
86 if (_shadow_caster && !caster) {
87 clear_shadow_buffers();
89 if (_shadow_caster != caster && _used_by_auto_shader) {
91 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
93 _shadow_caster = caster;
108 if ((_shadow_caster && !caster) || buffer_xsize != _sb_size[0] || buffer_ysize != _sb_size[1]) {
109 clear_shadow_buffers();
111 if (_shadow_caster != caster && _used_by_auto_shader) {
113 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
115 _shadow_caster = caster;
116 _sb_size.set(buffer_xsize, buffer_ysize);
118 if (buffer_sort != _sb_sort) {
119 ShadowBuffers::iterator it;
120 for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) {
121 (*it).second->set_sort(buffer_sort);
123 _sb_sort = buffer_sort;
136 clear_shadow_buffers() {
140 _shadow_map->clear_image();
143 ShadowBuffers::iterator it;
144 for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) {
145 (*it).first->remove_window((*it).second);
155 if (_shadow_map !=
nullptr &&
156 _shadow_map->get_x_size() == _sb_size[0] &&
157 _shadow_map->get_y_size() == _sb_size[1]) {
162 if (_shadow_map ==
nullptr) {
163 _shadow_map =
new Texture(get_name());
166 _shadow_map->setup_2d_texture(_sb_size[0], _sb_size[1], Texture::T_unsigned_byte, Texture::F_depth_component);
167 _shadow_map->set_clear_color(LColor(1));
168 _shadow_map->set_wrap_u(SamplerState::WM_border_color);
169 _shadow_map->set_wrap_v(SamplerState::WM_border_color);
170 _shadow_map->set_border_color(LColor(1));
171 _shadow_map->set_minfilter(SamplerState::FT_shadow);
172 _shadow_map->set_magfilter(SamplerState::FT_shadow);
192 clear_shadow_buffers();
217 output(std::ostream &out)
const {
218 LensNode::output(out);
225 write(std::ostream &out,
int indent_level)
const {
226 LensNode::write(out, indent_level);
236 Light::write_datagram(manager, dg);
250 Camera::fillin(scan, manager);
251 Light::fillin(scan, manager);
253 bool shadow_caster = scan.
get_bool();
void set_shadow_caster(bool caster)
Sets the flag indicating whether this light should cast shadows or not.
A basic node of the scene graph or data graph.
The abstract interface to all kinds of lights.
bool get_bool()
Extracts a boolean value.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
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-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
static void inc(Integer &var)
Atomically increments the indicated variable.
static bool dec(Integer &var)
Atomically decrements the indicated variable and returns true if the new value is nonzero,...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_bool(bool value)
Adds a boolean value to the datagram.
virtual void attrib_unref()
This is called when the light is removed from a LightAttrib.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
virtual Light * as_light()
Cross-casts the node to a Light pointer, if it is one of the four kinds of Light nodes,...
A derivative of Light and of Camera.
virtual PandaNode * as_node()
Returns the Light object upcast to a PandaNode.
set_active
Sets the active flag on the 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.
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void attrib_ref()
This is called when the light is added to a LightAttrib.