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

panda/src/shader/shaderTransition.h

Go to the documentation of this file.
00001 // Filename: shaderTransition.h
00002 // Created by:  mike (19Jan99)
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 SHADERTRANSITION_H
00020 #define SHADERTRANSITION_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "shader.h"
00025 
00026 #include <immediateTransition.h>
00027 #include <pointerTo.h>
00028 #include <nodeRelation.h>
00029 
00030 #include "plist.h"
00031 #include "pmap.h"
00032 #include "pset.h"
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //       Class : ShaderTransition
00036 // Description : A ShaderTransition holds the set of shaders that
00037 //               might be in effect to render a particular part of the
00038 //               subgraph.  These shaders can range from lightweight
00039 //               rendering effects to full-blown multipass renderings;
00040 //               use with caution.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_SHADER ShaderTransition : public ImmediateTransition {
00043 private:
00044   //  typedef pvector< PT(Shader) > Shaders;
00045   typedef plist< PT(Shader) > Shaders;
00046   typedef pmap<TypeHandle, int> ShaderOrder;
00047   typedef pmap<PT(Shader), int> ShaderOverride;
00048   typedef pset<TypeHandle> ShaderBlend;
00049 
00050 public:
00051   INLINE ShaderTransition();
00052 
00053 public:
00054   // Functions to access and adjust the list of shaders.
00055   typedef Shaders::const_iterator iterator;
00056   typedef Shaders::const_iterator const_iterator;
00057 
00058   void clear();
00059   bool is_empty() const;
00060   void insert(Shader *shader);
00061 
00062   //If you wish to override the ordering of your shader.  Say for some
00063   //reason you don't want this Shadow to appear in the reflections, or you want
00064   //Spheremaped objects to reflect the reflections in planar objects instead of
00065   //the other way around.   Then set override appropriately.
00066   bool set_shader(Shader *shader, int override = -1);
00067   bool clear_shader(Shader *shader);
00068   bool has_shader(Shader *shader) const;
00069 
00070   const_iterator begin() const;
00071   const_iterator end() const;
00072 
00073 public:
00074   static void set_shader_order(TypeHandle shader, int order);
00075   static void set_shader_always_blend(TypeHandle shader);
00076 
00077 private:
00078   bool must_blend();
00079 
00080 public:
00081   virtual NodeTransition *make_copy() const;
00082 
00083   virtual bool sub_render(NodeRelation *arc,
00084                           const AllTransitionsWrapper &input_trans,
00085                           AllTransitionsWrapper &modify_trans,
00086                           RenderTraverser *trav);
00087   virtual bool has_sub_render() const;
00088 
00089 private:
00090   Shaders _shaders;
00091   static ShaderOrder* _shader_order;
00092   static ShaderBlend* _shader_always_blend;
00093   ShaderOverride _overrides;
00094 
00095 public:
00096   virtual TypeHandle get_type() const {
00097     return get_class_type();
00098   }
00099   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00100   static TypeHandle get_class_type() {
00101     return _type_handle;
00102   }
00103   static void init_type() {
00104     ImmediateTransition::init_type();
00105     register_type(_type_handle, "ShaderTransition",
00106                   ImmediateTransition::get_class_type());
00107   }
00108 
00109 private:
00110   static TypeHandle _type_handle;
00111   friend class ShaderAttribute;
00112 };
00113 
00114 INLINE bool set_shader(NodeRelation *arc, Shader *shader);
00115 INLINE bool clear_shader(NodeRelation *arc, Shader *shader);
00116 INLINE bool has_shader(const NodeRelation *arc, Shader *shader);
00117 
00118 #include "shaderTransition.I"
00119 
00120 #endif
00121 
00122 

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