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