Panda3D

pointLight.h

00001 // Filename: pointLight.h
00002 // Created by:  mike (09Jan97)
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 POINTLIGHT_H
00016 #define POINTLIGHT_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "lightLensNode.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : PointLight
00024 // Description : A light originating from a single point in space, and
00025 //               shining in all directions.
00026 ////////////////////////////////////////////////////////////////////
00027 class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode {
00028 PUBLISHED:
00029   PointLight(const string &name);
00030 
00031 protected:
00032   PointLight(const PointLight &copy);
00033 
00034 public:
00035   virtual PandaNode *make_copy() const;
00036   virtual void xform(const LMatrix4 &mat);
00037   virtual void write(ostream &out, int indent_level) const;
00038 
00039   virtual bool get_vector_to_light(LVector3 &result,
00040                                    const LPoint3 &from_object_point, 
00041                                    const LMatrix4 &to_object_space);
00042 
00043 PUBLISHED:
00044   INLINE const LColor &get_specular_color() const;
00045   INLINE void set_specular_color(const LColor &color);
00046   
00047   INLINE const LVecBase3 &get_attenuation() const;
00048   INLINE void set_attenuation(const LVecBase3 &attenuation);
00049   
00050   INLINE const LPoint3 &get_point() const;
00051   INLINE void set_point(const LPoint3 &point);
00052 
00053   virtual int get_class_priority() const;
00054   
00055 public:
00056   virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light,
00057                     int light_id);
00058 
00059 private:
00060   // This is the data that must be cycled between pipeline stages.
00061   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
00062   public:
00063     INLINE CData();
00064     INLINE CData(const CData &copy);
00065     virtual CycleData *make_copy() const;
00066     virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00067     virtual void fillin(DatagramIterator &scan, BamReader *manager);
00068     virtual TypeHandle get_parent_type() const {
00069       return PointLight::get_class_type();
00070     }
00071 
00072     LColor _specular_color;
00073     LVecBase3 _attenuation;
00074     LPoint3 _point;
00075   };
00076 
00077   PipelineCycler<CData> _cycler;
00078   typedef CycleDataReader<CData> CDReader;
00079   typedef CycleDataWriter<CData> CDWriter;
00080 
00081 public:
00082   static void register_with_read_factory();
00083   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00084 
00085 protected:
00086   static TypedWritable *make_from_bam(const FactoryParams &params);
00087   void fillin(DatagramIterator &scan, BamReader *manager);
00088 
00089 public:
00090   static TypeHandle get_class_type() {
00091     return _type_handle;
00092   }
00093   static void init_type() {
00094     LightLensNode::init_type();
00095     register_type(_type_handle, "PointLight",
00096                   LightLensNode::get_class_type());
00097   }
00098   virtual TypeHandle get_type() const {
00099     return get_class_type();
00100   }
00101   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00102 
00103 private:
00104   static TypeHandle _type_handle;
00105 };
00106 
00107 INLINE ostream &operator << (ostream &out, const PointLight &light) {
00108   light.output(out);
00109   return out;
00110 }
00111 
00112 #include "pointLight.I"
00113 
00114 #endif
 All Classes Functions Variables Enumerations