00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef DIRECTIONALLIGHT_H
00016 #define DIRECTIONALLIGHT_H
00017
00018 #include "pandabase.h"
00019
00020 #include "lightLensNode.h"
00021
00022
00023
00024
00025
00026
00027 class EXPCL_PANDA_PGRAPHNODES DirectionalLight : public LightLensNode {
00028 PUBLISHED:
00029 DirectionalLight(const string &name);
00030
00031 protected:
00032 DirectionalLight(const DirectionalLight ©);
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 LPoint3 &get_point() const;
00048 INLINE void set_point(const LPoint3 &point);
00049
00050 INLINE const LVector3 &get_direction() const;
00051 INLINE void set_direction(const LVector3 &direction);
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
00061 class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
00062 public:
00063 INLINE CData();
00064 INLINE CData(const CData ©);
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 DirectionalLight::get_class_type();
00070 }
00071
00072 LColor _specular_color;
00073 LPoint3 _point;
00074 LVector3 _direction;
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 ¶ms);
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, "DirectionalLight",
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 DirectionalLight &light) {
00108 light.output(out);
00109 return out;
00110 }
00111
00112 #include "directionalLight.I"
00113
00114 #endif