Panda3D

lightLensNode.h

00001 // Filename: lightLensNode.h
00002 // Created by:  drose (26Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef LIGHTLENSNODE_H
00016 #define LIGHTLENSNODE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "light.h"
00021 #include "camera.h"
00022 #include "graphicsStateGuardianBase.h"
00023 #include "graphicsOutputBase.h"
00024 
00025 class ShaderGenerator;
00026 class GraphicsStateGuardian;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : LightLensNode
00030 // Description : A derivative of Light and of Camera. The name might
00031 //               be misleading: it does not directly derive from
00032 //               LensNode, but through the Camera class. The Camera
00033 //               serves no purpose unless shadows are enabled.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA_PGRAPHNODES LightLensNode : public Light, public Camera {
00036 PUBLISHED:
00037   LightLensNode(const string &name, Lens *lens = new PerspectiveLens());
00038   virtual ~LightLensNode();
00039 
00040   INLINE bool is_shadow_caster();
00041   INLINE void set_shadow_caster(bool caster);
00042   INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
00043 
00044 protected:
00045   LightLensNode(const LightLensNode &copy);
00046   void clear_shadow_buffers();
00047 
00048   bool _shadow_caster;
00049   int _sb_xsize, _sb_ysize, _sb_sort;
00050 
00051   // This is really a map of GSG -> GraphicsOutput.
00052   typedef pmap<PT(GraphicsStateGuardianBase), PT(GraphicsOutputBase) > ShadowBuffers;
00053   ShadowBuffers _sbuffers;
00054 
00055 public:
00056   virtual PandaNode *as_node();
00057   virtual Light *as_light();
00058 
00059 PUBLISHED:
00060   // We have to explicitly publish these because they resolve the
00061   // multiple inheritance.
00062   virtual void output(ostream &out) const;
00063   virtual void write(ostream &out, int indent_level = 0) const;
00064 
00065 public:
00066   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00067 
00068 protected:
00069   void fillin(DatagramIterator &scan, BamReader *manager);
00070 
00071 public:
00072   static TypeHandle get_class_type() {
00073     return _type_handle;
00074   }
00075   static void init_type() {
00076     Light::init_type();
00077     Camera::init_type();
00078     register_type(_type_handle, "LightLensNode",
00079                   Light::get_class_type(),
00080                   Camera::get_class_type());
00081   }
00082   virtual TypeHandle get_type() const {
00083     return get_class_type();
00084   }
00085   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00086 
00087 private:
00088   static TypeHandle _type_handle;
00089 
00090   friend class GraphicsStateGuardian;
00091   friend class ShaderGenerator;
00092 };
00093 
00094 INLINE ostream &operator << (ostream &out, const LightLensNode &light) {
00095   light.output(out);
00096   return out;
00097 }
00098 
00099 #include "lightLensNode.I"
00100 
00101 #endif
 All Classes Functions Variables Enumerations