00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SPOTLIGHT_H
00016 #define SPOTLIGHT_H
00017
00018 #include "pandabase.h"
00019
00020 #include "lightLensNode.h"
00021 #include "texture.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class EXPCL_PANDA_PGRAPHNODES Spotlight : public LightLensNode {
00038 PUBLISHED:
00039 Spotlight(const string &name);
00040
00041 protected:
00042 Spotlight(const Spotlight ©);
00043
00044 public:
00045 virtual PandaNode *make_copy() const;
00046 virtual void xform(const LMatrix4 &mat);
00047 virtual void write(ostream &out, int indent_level) const;
00048
00049 virtual bool get_vector_to_light(LVector3 &result,
00050 const LPoint3 &from_object_point,
00051 const LMatrix4 &to_object_space);
00052
00053 PUBLISHED:
00054 INLINE PN_stdfloat get_exponent() const;
00055 INLINE void set_exponent(PN_stdfloat exponent);
00056
00057 INLINE const LColor &get_specular_color() const;
00058 INLINE void set_specular_color(const LColor &color);
00059
00060 INLINE const LVecBase3 &get_attenuation() const;
00061 INLINE void set_attenuation(const LVecBase3 &attenuation);
00062
00063 virtual int get_class_priority() const;
00064
00065 static PT(Texture) make_spot(int pixel_width, PN_stdfloat full_radius,
00066 LColor &fg, LColor &bg);
00067
00068 public:
00069 virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light,
00070 int light_id);
00071
00072 protected:
00073 virtual void fill_viz_geom(GeomNode *viz_geom);
00074
00075 private:
00076 CPT(RenderState) get_viz_state();
00077
00078 private:
00079
00080 class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
00081 public:
00082 INLINE CData();
00083 INLINE CData(const CData ©);
00084 virtual CycleData *make_copy() const;
00085 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00086 virtual void fillin(DatagramIterator &scan, BamReader *manager);
00087 virtual TypeHandle get_parent_type() const {
00088 return Spotlight::get_class_type();
00089 }
00090
00091 PN_stdfloat _exponent;
00092 LColor _specular_color;
00093 LVecBase3 _attenuation;
00094 };
00095
00096 PipelineCycler<CData> _cycler;
00097 typedef CycleDataReader<CData> CDReader;
00098 typedef CycleDataWriter<CData> CDWriter;
00099
00100 public:
00101 static void register_with_read_factory();
00102 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00103
00104 protected:
00105 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00106 void fillin(DatagramIterator &scan, BamReader *manager);
00107
00108 public:
00109 static TypeHandle get_class_type() {
00110 return _type_handle;
00111 }
00112 static void init_type() {
00113 LightLensNode::init_type();
00114 register_type(_type_handle, "Spotlight",
00115 LightLensNode::get_class_type());
00116 }
00117 virtual TypeHandle get_type() const {
00118 return get_class_type();
00119 }
00120 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00121
00122 private:
00123 static TypeHandle _type_handle;
00124 };
00125
00126 INLINE ostream &operator << (ostream &out, const Spotlight &light) {
00127 light.output(out);
00128 return out;
00129 }
00130
00131 #include "spotlight.I"
00132
00133 #endif