Panda3D
 All Classes Functions Variables Enumerations
lightLensNode.I
1 // Filename: lightLensNode.I
2 // Created by: drose (26Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function: LightLensNode::is_shadow_caster
17 // Access: Published
18 // Description: Returns whether this light is configured to cast
19 // shadows or not.
20 ////////////////////////////////////////////////////////////////////
21 INLINE bool LightLensNode::
23  return _shadow_caster;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: LightLensNode::set_shadow_caster
28 // Access: Published
29 // Description: Sets the flag indicating whether this light should
30 // cast shadows or not. This is the variant without
31 // buffer size, meaning that the current buffer size
32 // will be kept (512x512 is the default).
33 // Note that enabling shadows will require the shader
34 // generator to be enabled on the scene.
35 ////////////////////////////////////////////////////////////////////
36 INLINE void LightLensNode::
37 set_shadow_caster(bool caster) {
38  if (_shadow_caster && !caster) {
39  clear_shadow_buffers();
40  }
41  _shadow_caster = caster;
42  set_active(caster);
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: LightLensNode::set_shadow_caster
47 // Access: Published
48 // Description: Sets the flag indicating whether this light should
49 // cast shadows or not. The xsize and ysize parameters
50 // specify the size of the shadow buffer that will be
51 // set up, the sort parameter specifies the sort.
52 // Note that enabling shadows will require the shader
53 // generator to be enabled on the scene.
54 ////////////////////////////////////////////////////////////////////
55 INLINE void LightLensNode::
56 set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_sort) {
57  if ((_shadow_caster && !caster) || buffer_xsize != _sb_xsize || buffer_ysize != _sb_ysize) {
58  clear_shadow_buffers();
59  }
60  _shadow_caster = caster;
61  _sb_xsize = buffer_xsize;
62  _sb_ysize = buffer_ysize;
63 
64  if (buffer_sort != _sb_sort) {
65  ShadowBuffers::iterator it;
66  for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) {
67  (*it).second->set_sort(buffer_sort);
68  }
69  _sb_sort = buffer_sort;
70  }
71  set_active(caster);
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: LightLensNode::get_shadow_buffer
76 // Access: Published
77 // Description: Returns the buffer that has been constructed for
78 // a given GSG, or NULL if no such buffer has (yet)
79 // been constructed. This should be used for
80 // debugging only, you will not need to call this
81 // normally.
82 ////////////////////////////////////////////////////////////////////
85  ShadowBuffers::iterator it = _sbuffers.find(gsg);
86  if (it == _sbuffers.end()) {
87  return NULL;
88  } else {
89  return (*it).second;
90  }
91 }
void set_shadow_caster(bool caster)
Sets the flag indicating whether this light should cast shadows or not.
Definition: lightLensNode.I:37
bool is_shadow_caster()
Returns whether this light is configured to cast shadows or not.
Definition: lightLensNode.I:22
void set_active(bool active)
Sets the active flag on the camera.
Definition: camera.I:23
GraphicsOutputBase * get_shadow_buffer(GraphicsStateGuardianBase *gsg)
Returns the buffer that has been constructed for a given GSG, or NULL if no such buffer has (yet) bee...
Definition: lightLensNode.I:84
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
An abstract base class for GraphicsOutput, for all the usual reasons.