00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SPOTLIGHT_H
00020 #define SPOTLIGHT_H
00021
00022 #include "pandabase.h"
00023
00024 #include "lightLensNode.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class EXPCL_PANDA Spotlight : public LightLensNode {
00041 PUBLISHED:
00042 Spotlight(const string &name);
00043
00044 protected:
00045 Spotlight(const Spotlight ©);
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
00075 class EXPCL_PANDA CData : public CycleData {
00076 public:
00077 INLINE CData();
00078 INLINE CData(const CData ©);
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 ¶ms);
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