Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/lightAttrib.h

Go to the documentation of this file.
00001 // Filename: lightAttrib.h
00002 // Created by:  drose (26Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //       Class : LightAttrib
00030 // Description : Indicates which set of lights should be considered
00031 //               "on" to illuminate geometry at this level and below.
00032 //               A LightAttrib can either add lights or remove lights
00033 //               from the total set of "on" lights.
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 &params);
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 

Generated on Fri May 2 00:41:44 2003 for Panda by doxygen1.3