Panda3D
 All Classes Functions Variables Enumerations
lightLensNode.h
1 // Filename: lightLensNode.h
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 #ifndef LIGHTLENSNODE_H
16 #define LIGHTLENSNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "light.h"
21 #include "camera.h"
22 #include "graphicsStateGuardianBase.h"
23 #include "graphicsOutputBase.h"
24 
25 class ShaderGenerator;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : LightLensNode
30 // Description : A derivative of Light and of Camera. The name might
31 // be misleading: it does not directly derive from
32 // LensNode, but through the Camera class. The Camera
33 // serves no purpose unless shadows are enabled.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_PGRAPHNODES LightLensNode : public Light, public Camera {
36 PUBLISHED:
37  LightLensNode(const string &name, Lens *lens = new PerspectiveLens());
38  virtual ~LightLensNode();
39 
40  INLINE bool is_shadow_caster();
41  INLINE void set_shadow_caster(bool caster);
42  INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
43 
44  INLINE GraphicsOutputBase *get_shadow_buffer(GraphicsStateGuardianBase *gsg);
45 
46 protected:
47  LightLensNode(const LightLensNode &copy);
48  void clear_shadow_buffers();
49 
50  bool _shadow_caster;
51  int _sb_xsize, _sb_ysize, _sb_sort;
52 
53  // This is really a map of GSG -> GraphicsOutput.
55  ShadowBuffers _sbuffers;
56 
57 public:
58  virtual PandaNode *as_node();
59  virtual Light *as_light();
60 
61 PUBLISHED:
62  // We have to explicitly publish these because they resolve the
63  // multiple inheritance.
64  virtual void output(ostream &out) const;
65  virtual void write(ostream &out, int indent_level = 0) const;
66 
67 public:
68  virtual void write_datagram(BamWriter *manager, Datagram &dg);
69 
70 protected:
71  void fillin(DatagramIterator &scan, BamReader *manager);
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  Light::init_type();
79  Camera::init_type();
80  register_type(_type_handle, "LightLensNode",
81  Light::get_class_type(),
82  Camera::get_class_type());
83  }
84  virtual TypeHandle get_type() const {
85  return get_class_type();
86  }
87  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
88 
89 private:
90  static TypeHandle _type_handle;
91 
92  friend class GraphicsStateGuardian;
93  friend class ShaderGenerator;
94 };
95 
96 INLINE ostream &operator << (ostream &out, const LightLensNode &light) {
97  light.output(out);
98  return out;
99 }
100 
101 #include "lightLensNode.I"
102 
103 #endif
virtual Light * as_light()
Cross-casts the node to a Light pointer, if it is one of the four kinds of Light nodes, or returns NULL if it is not.
Definition: pandaNode.cxx:2528
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
The abstract interface to all kinds of lights.
Definition: light.h:42
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: camera.cxx:316
A perspective-type lens: a normal camera.
The ShaderGenerator is a device that effectively replaces the classic fixed function pipeline with a ...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A derivative of Light and of Camera.
Definition: lightLensNode.h:35
Encapsulates all the communication with a particular instance of a given rendering backend...
A class to retrieve the individual data elements previously stored in a Datagram. ...
An abstract base class for GraphicsOutput, for all the usual reasons.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition: camera.h:37
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43