Panda3D
 All Classes Functions Variables Enumerations
renderEffect.h
00001 // Filename: renderEffect.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 RENDEREFFECT_H
00016 #define RENDEREFFECT_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "transformState.h"
00021 #include "renderState.h"
00022 
00023 #include "typedWritableReferenceCount.h"
00024 #include "pointerTo.h"
00025 #include "pset.h"
00026 #include "luse.h"
00027 
00028 class CullTraverser;
00029 class CullTraverserData;
00030 class PandaNode;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : RenderEffect
00034 // Description : This is the base class for a number of special render
00035 //               effects that may be set on scene graph nodes to
00036 //               change the way they render.  This includes
00037 //               BillboardEffect, DecalEffect, etc.
00038 //
00039 //               RenderEffect represents render properties that must
00040 //               be applied as soon as they are encountered in the
00041 //               scene graph, rather than propagating down to the
00042 //               leaves.  This is different from RenderAttrib, which
00043 //               represents properties like color and texture that
00044 //               don't do anything until they propagate down to a
00045 //               GeomNode.
00046 //
00047 //               You should not attempt to create or modify a
00048 //               RenderEffect directly; instead, use the make() method
00049 //               of the appropriate kind of effect you want.  This
00050 //               will allocate and return a new RenderEffect of the
00051 //               appropriate type, and it may share pointers if
00052 //               possible.  Do not modify the new RenderEffect if you
00053 //               wish to change its properties; instead, create a new
00054 //               one.
00055 ////////////////////////////////////////////////////////////////////
00056 class EXPCL_PANDA_PGRAPH RenderEffect : public TypedWritableReferenceCount {
00057 protected:
00058   RenderEffect();
00059 private:
00060   RenderEffect(const RenderEffect &copy);
00061   void operator = (const RenderEffect &copy);
00062 
00063 public:
00064   virtual ~RenderEffect();
00065 
00066   virtual bool safe_to_transform() const;
00067   virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
00068   virtual bool safe_to_combine() const;
00069   virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const;
00070 
00071   virtual bool has_cull_callback() const;
00072   virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
00073                              CPT(TransformState) &node_transform,
00074                              CPT(RenderState) &node_state) const;
00075 
00076   virtual bool has_adjust_transform() const;
00077   virtual void adjust_transform(CPT(TransformState) &net_transform,
00078                                 CPT(TransformState) &node_transform,
00079                                 PandaNode *node) const;
00080 
00081 PUBLISHED:
00082   INLINE int compare_to(const RenderEffect &other) const;
00083 
00084   virtual void output(ostream &out) const;
00085   virtual void write(ostream &out, int indent_level) const;
00086 
00087   static int get_num_effects();
00088   static void list_effects(ostream &out);
00089   static bool validate_effects();
00090 
00091 protected:
00092   static CPT(RenderEffect) return_new(RenderEffect *effect);
00093 
00094   virtual int compare_to_impl(const RenderEffect *other) const;
00095 
00096 private:
00097   typedef pset<const RenderEffect *, indirect_compare_to<const RenderEffect *> > Effects;
00098   static Effects *_effects;
00099 
00100   Effects::iterator _saved_entry;
00101 
00102 public:
00103   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00104   static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
00105   virtual void finalize(BamReader *manager);
00106 
00107 protected:
00108   static TypedWritable *new_from_bam(RenderEffect *effect, BamReader *manager);
00109   void fillin(DatagramIterator &scan, BamReader *manager);
00110   
00111 public:
00112   static TypeHandle get_class_type() {
00113     return _type_handle;
00114   }
00115   static void init_type() {
00116     TypedWritableReferenceCount::init_type();
00117     register_type(_type_handle, "RenderEffect",
00118                   TypedWritableReferenceCount::get_class_type());
00119   }
00120   virtual TypeHandle get_type() const {
00121     return get_class_type();
00122   }
00123   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00124 
00125 private:
00126   static TypeHandle _type_handle;
00127 };
00128 
00129 INLINE ostream &operator << (ostream &out, const RenderEffect &effect) {
00130   effect.output(out);
00131   return out;
00132 }
00133 
00134 #include "renderEffect.I"
00135 
00136 #endif
00137 
 All Classes Functions Variables Enumerations