Panda3D

colorScaleAttrib.h

00001 // Filename: colorScaleAttrib.h
00002 // Created by:  drose (14Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef COLORSCALEATTRIB_H
00016 #define COLORSCALEATTRIB_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "renderAttrib.h"
00021 #include "luse.h"
00022 
00023 class FactoryParams;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : ColorScaleAttrib
00027 // Description : Applies a scale to colors in the scene graph and on
00028 //               vertices.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA_PGRAPH ColorScaleAttrib : public RenderAttrib {
00031 protected:
00032   ColorScaleAttrib(bool off, const LVecBase4f &scale);
00033   INLINE ColorScaleAttrib(const ColorScaleAttrib &copy);
00034 
00035 PUBLISHED:
00036   static CPT(RenderAttrib) make_identity();
00037   static CPT(RenderAttrib) make(const LVecBase4f &scale);
00038   static CPT(RenderAttrib) make_off();
00039   static CPT(RenderAttrib) make_default();
00040 
00041   INLINE bool is_off() const;
00042   INLINE bool is_identity() const;
00043   INLINE bool has_scale() const;
00044   INLINE bool has_rgb_scale() const;
00045   INLINE bool has_alpha_scale() const;
00046   INLINE const LVecBase4f &get_scale() const;
00047   CPT(RenderAttrib) set_scale(const LVecBase4f &scale) const;
00048 
00049 public:
00050   virtual bool lower_attrib_can_override() const;
00051   virtual void output(ostream &out) const;
00052 
00053 protected:
00054   virtual int compare_to_impl(const RenderAttrib *other) const;
00055   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00056   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00057 
00058 private:
00059   void quantize_scale();
00060 
00061 private:
00062   bool _off;
00063   bool _has_scale;
00064   bool _has_rgb_scale;
00065   bool _has_alpha_scale;
00066   LVecBase4f _scale;
00067   static CPT(RenderAttrib) _identity_attrib;
00068 
00069 PUBLISHED:
00070   static int get_class_slot() {
00071     return _attrib_slot;
00072   }
00073   virtual int get_slot() const {
00074     return get_class_slot();
00075   }
00076 
00077 public:
00078   static void register_with_read_factory();
00079   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00080 
00081 protected:
00082   static TypedWritable *make_from_bam(const FactoryParams &params);
00083   void fillin(DatagramIterator &scan, BamReader *manager);
00084   
00085 public:
00086   static TypeHandle get_class_type() {
00087     return _type_handle;
00088   }
00089   static void init_type() {
00090     RenderAttrib::init_type();
00091     register_type(_type_handle, "ColorScaleAttrib",
00092                   RenderAttrib::get_class_type());
00093     _attrib_slot = register_slot(_type_handle, 100, make_default);
00094   }
00095   virtual TypeHandle get_type() const {
00096     return get_class_type();
00097   }
00098   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00099 
00100 private:
00101   static TypeHandle _type_handle;
00102   static int _attrib_slot;
00103 };
00104 
00105 #include "colorScaleAttrib.I"
00106 
00107 #endif
00108 
 All Classes Functions Variables Enumerations