00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00036
00037
00038
00039
00040
00041
00042 class EXPCL_SHADER ShaderTransition : public ImmediateTransition {
00043 private:
00044
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
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
00063
00064
00065
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