00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LIGHTATTRIB_H
00020 #define LIGHTATTRIB_H
00021
00022 #include "pandabase.h"
00023
00024 #include "light.h"
00025 #include "renderAttrib.h"
00026 #include "ordered_vector.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035 class EXPCL_PANDA LightAttrib : public RenderAttrib {
00036 private:
00037 INLINE LightAttrib();
00038
00039 PUBLISHED:
00040 enum Operation {
00041 O_set,
00042 O_add,
00043 O_remove
00044 };
00045
00046 static CPT(RenderAttrib) make_all_off();
00047 static CPT(RenderAttrib) make(Operation op,
00048 Light *light);
00049 static CPT(RenderAttrib) make(Operation op,
00050 Light *light1, Light *light2);
00051 static CPT(RenderAttrib) make(Operation op,
00052 Light *light1, Light *light2,
00053 Light *light3);
00054 static CPT(RenderAttrib) make(Operation op,
00055 Light *light1, Light *light2,
00056 Light *light3, Light *light4);
00057
00058 INLINE Operation get_operation() const;
00059
00060 INLINE int get_num_lights() const;
00061 INLINE Light *get_light(int n) const;
00062 bool has_light(Light *light) const;
00063
00064 INLINE CPT(RenderAttrib) add_light(Light *light) const;
00065 INLINE CPT(RenderAttrib) remove_light(Light *light) const;
00066
00067 INLINE bool is_identity() const;
00068 INLINE bool is_all_off() const;
00069
00070 public:
00071 virtual void issue(GraphicsStateGuardianBase *gsg) const;
00072 virtual void output(ostream &out) const;
00073
00074 protected:
00075 virtual int compare_to_impl(const RenderAttrib *other) const;
00076 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00077 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00078 virtual RenderAttrib *make_default_impl() const;
00079
00080 private:
00081 CPT(RenderAttrib) do_add(const LightAttrib *other, Operation op) const;
00082 CPT(RenderAttrib) do_remove(const LightAttrib *other, Operation op) const;
00083
00084 private:
00085 Operation _operation;
00086 typedef ov_set< PT(Light) > Lights;
00087 Lights _lights;
00088
00089 public:
00090 static void register_with_read_factory();
00091 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00092 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00093
00094 protected:
00095 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00096 void fillin(DatagramIterator &scan, BamReader *manager);
00097
00098 public:
00099 static TypeHandle get_class_type() {
00100 return _type_handle;
00101 }
00102 static void init_type() {
00103 RenderAttrib::init_type();
00104 register_type(_type_handle, "LightAttrib",
00105 RenderAttrib::get_class_type());
00106 }
00107 virtual TypeHandle get_type() const {
00108 return get_class_type();
00109 }
00110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00111
00112 private:
00113 static TypeHandle _type_handle;
00114 };
00115
00116 #include "lightAttrib.I"
00117
00118 #endif
00119