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

panda/src/pgraph/renderAttrib.h

Go to the documentation of this file.
00001 // Filename: renderAttrib.h
00002 // Created by:  drose (21Feb02)
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 RENDERATTRIB_H
00020 #define RENDERATTRIB_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "typedWritableReferenceCount.h"
00025 #include "indirectCompareTo.h"
00026 #include "pointerTo.h"
00027 #include "pset.h"
00028 
00029 class GraphicsStateGuardianBase;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : RenderAttrib
00033 // Description : This is the base class for a number of render
00034 //               attributes (other than transform) that may be set on
00035 //               scene graph nodes to control the appearance of
00036 //               geometry.  This includes TextureAttrib, ColorAttrib,
00037 //               etc.
00038 //
00039 //               RenderAttrib represents render attributes that always
00040 //               propagate down to the leaves without regard to the
00041 //               particular node they are assigned to.  A RenderAttrib
00042 //               will have the same effect on a leaf node whether it
00043 //               is assigned to the graph at the leaf or several nodes
00044 //               above.  This is different from RenderEffect, which
00045 //               represents a particular render property that is
00046 //               applied immediately to the node on which it is
00047 //               encountered, like billboarding or decaling.
00048 //
00049 //               You should not attempt to create or modify a
00050 //               RenderAttrib directly; instead, use the make() method
00051 //               of the appropriate kind of attrib you want.  This
00052 //               will allocate and return a new RenderAttrib of the
00053 //               appropriate type, and it may share pointers if
00054 //               possible.  Do not modify the new RenderAttrib if you
00055 //               wish to change its properties; instead, create a new
00056 //               one.
00057 ////////////////////////////////////////////////////////////////////
00058 class EXPCL_PANDA RenderAttrib : public TypedWritableReferenceCount {
00059 protected:
00060   RenderAttrib();
00061 private:
00062   RenderAttrib(const RenderAttrib &copy);
00063   void operator = (const RenderAttrib &copy);
00064 
00065 public:
00066   virtual ~RenderAttrib();
00067 
00068   INLINE CPT(RenderAttrib) compose(const RenderAttrib *other) const;
00069   INLINE CPT(RenderAttrib) invert_compose(const RenderAttrib *other) const;
00070   INLINE CPT(RenderAttrib) make_default() const;
00071   INLINE int compare_to(const RenderAttrib &other) const;
00072   virtual void issue(GraphicsStateGuardianBase *gsg) const;
00073 
00074 PUBLISHED:
00075   virtual void output(ostream &out) const;
00076   virtual void write(ostream &out, int indent_level) const;
00077 
00078   enum PandaCompareFunc {   // intentionally defined to match D3DCMPFUNC
00079     M_none=0,           // alpha-test disabled (always-draw)
00080     M_never,            // Never draw.
00081     M_less,             // incoming < reference_alpha
00082     M_equal,            // incoming == reference_alpha
00083     M_less_equal,       // incoming <= reference_alpha
00084     M_greater,          // incoming > reference_alpha
00085     M_not_equal,        // incoming != reference_alpha
00086     M_greater_equal,    // incoming >= reference_alpha
00087     M_always            // Always draw.  
00088   };
00089 
00090 protected:
00091   static CPT(RenderAttrib) return_new(RenderAttrib *attrib);
00092   virtual int compare_to_impl(const RenderAttrib *other) const;
00093   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00094   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00095   virtual RenderAttrib *make_default_impl() const=0;
00096   void output_comparefunc(ostream &out,PandaCompareFunc fn) const;
00097 
00098 private:
00099   typedef pset<const RenderAttrib *, IndirectCompareTo<RenderAttrib> > Attribs;
00100   static Attribs *_attribs;
00101 
00102   Attribs::iterator _saved_entry;
00103 
00104 public:
00105   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00106   static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
00107   virtual void finalize();
00108 
00109 protected:
00110   static TypedWritable *new_from_bam(RenderAttrib *attrib, BamReader *manager);
00111   void fillin(DatagramIterator &scan, BamReader *manager);
00112   
00113 public:
00114   static TypeHandle get_class_type() {
00115     return _type_handle;
00116   }
00117   static void init_type() {
00118     TypedWritableReferenceCount::init_type();
00119     register_type(_type_handle, "RenderAttrib",
00120                   TypedWritableReferenceCount::get_class_type());
00121   }
00122   virtual TypeHandle get_type() const {
00123     return get_class_type();
00124   }
00125   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00126 
00127 private:
00128   static TypeHandle _type_handle;
00129 };
00130 
00131 INLINE ostream &operator << (ostream &out, const RenderAttrib &attrib) {
00132   attrib.output(out);
00133   return out;
00134 }
00135 
00136 #include "renderAttrib.I"
00137 
00138 #endif
00139 

Generated on Fri May 2 00:42:13 2003 for Panda by doxygen1.3