Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/spotlight.h

Go to the documentation of this file.
00001 // Filename: spotlight.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef SPOTLIGHT_H
00020 #define SPOTLIGHT_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "lightLensNode.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : Spotlight
00028 // Description : A light originating from a single point in space, and
00029 //               shining in a particular direction, with a cone-shaped
00030 //               falloff.
00031 //
00032 //               The Spotlight frustum is defined using a Lens, so it
00033 //               can have any of the properties that a camera lens can
00034 //               have.
00035 //
00036 //               Note that the class is named Spotlight instead of
00037 //               SpotLight, because "spotlight" is a single English
00038 //               word, instead of two words.
00039 ////////////////////////////////////////////////////////////////////
00040 class EXPCL_PANDA Spotlight : public LightLensNode {
00041 PUBLISHED:
00042   Spotlight(const string &name);
00043 
00044 protected:
00045   Spotlight(const Spotlight &copy);
00046 
00047 public:
00048   virtual PandaNode *make_copy() const;
00049   virtual void xform(const LMatrix4f &mat);
00050   virtual void write(ostream &out, int indent_level) const;
00051 
00052 PUBLISHED:
00053   INLINE float get_exponent() const;
00054   INLINE void set_exponent(float exponent);
00055   
00056   INLINE const Colorf &get_specular_color() const;
00057   INLINE void set_specular_color(const Colorf &color);
00058   
00059   INLINE const LVecBase3f &get_attenuation() const;
00060   INLINE void set_attenuation(const LVecBase3f &attenuation);
00061   
00062 public:
00063   virtual void bind(GraphicsStateGuardianBase *gsg, int light_id);
00064 
00065   bool make_image(Texture *texture, float radius);
00066 
00067 protected:
00068   virtual void fill_viz_geom(GeomNode *viz_geom);
00069 
00070 private:
00071   CPT(RenderState) get_viz_state();
00072 
00073 private:
00074   // This is the data that must be cycled between pipeline stages.
00075   class EXPCL_PANDA CData : public CycleData {
00076   public:
00077     INLINE CData();
00078     INLINE CData(const CData &copy);
00079     virtual CycleData *make_copy() const;
00080     virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00081     virtual void fillin(DatagramIterator &scan, BamReader *manager);
00082 
00083     float _exponent;
00084     Colorf _specular_color;
00085     LVecBase3f _attenuation;
00086   };
00087 
00088   PipelineCycler<CData> _cycler;
00089   typedef CycleDataReader<CData> CDReader;
00090   typedef CycleDataWriter<CData> CDWriter;
00091 
00092 public:
00093   static void register_with_read_factory();
00094   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00095 
00096 protected:
00097   static TypedWritable *make_from_bam(const FactoryParams &params);
00098   void fillin(DatagramIterator &scan, BamReader *manager);
00099 
00100 public:
00101   static TypeHandle get_class_type() {
00102     return _type_handle;
00103   }
00104   static void init_type() {
00105     LightLensNode::init_type();
00106     register_type(_type_handle, "Spotlight",
00107                   LightLensNode::get_class_type());
00108   }
00109   virtual TypeHandle get_type() const {
00110     return get_class_type();
00111   }
00112   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00113 
00114 private:
00115   static TypeHandle _type_handle;
00116 };
00117 
00118 INLINE ostream &operator << (ostream &out, const Spotlight &light) {
00119   light.output(out);
00120   return out;
00121 }
00122 
00123 #include "spotlight.I"
00124 
00125 #endif

Generated on Fri May 2 00:42:25 2003 for Panda by doxygen1.3