Panda3D
|
00001 // Filename: occluderEffect.h 00002 // Created by: drose (17Mar11) 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 OCCLUDEREFFECT_H 00016 #define OCCLUDEREFFECT_H 00017 00018 #include "pandabase.h" 00019 00020 #include "occluderNode.h" 00021 #include "renderEffect.h" 00022 #include "nodePath.h" 00023 #include "ordered_vector.h" 00024 #include "pmap.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : OccluderEffect 00028 // Description : This functions similarly to a LightAttrib or 00029 // ClipPlaneAttrib. It indicates the set of occluders 00030 // that modify the geometry at this level and below. 00031 // Unlike a ClipPlaneAttrib, an OccluderEffect takes 00032 // effect immediately when it is encountered during 00033 // traversal, and thus can only add occluders; it may 00034 // not remove them. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_PGRAPH OccluderEffect : public RenderEffect { 00037 private: 00038 INLINE OccluderEffect(); 00039 INLINE OccluderEffect(const OccluderEffect ©); 00040 00041 PUBLISHED: 00042 static CPT(RenderEffect) make(); 00043 00044 INLINE int get_num_on_occluders() const; 00045 INLINE NodePath get_on_occluder(int n) const; 00046 MAKE_SEQ(get_on_occluders, get_num_on_occluders, get_on_occluder); 00047 INLINE bool has_on_occluder(const NodePath &occluder) const; 00048 00049 INLINE bool is_identity() const; 00050 00051 CPT(RenderEffect) add_on_occluder(const NodePath &occluder) const; 00052 CPT(RenderEffect) remove_on_occluder(const NodePath &occluder) const; 00053 00054 public: 00055 virtual void output(ostream &out) const; 00056 00057 protected: 00058 virtual int compare_to_impl(const RenderEffect *other) const; 00059 00060 private: 00061 void sort_on_occluders(); 00062 00063 private: 00064 typedef ov_set<NodePath> Occluders; 00065 Occluders _on_occluders; 00066 00067 UpdateSeq _sort_seq; 00068 00069 static CPT(RenderEffect) _empty_effect; 00070 00071 public: 00072 static void register_with_read_factory(); 00073 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00074 virtual int complete_pointers(TypedWritable **plist, BamReader *manager); 00075 virtual bool require_fully_complete() const; 00076 00077 protected: 00078 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00079 void fillin(DatagramIterator &scan, BamReader *manager); 00080 00081 public: 00082 static TypeHandle get_class_type() { 00083 return _type_handle; 00084 } 00085 static void init_type() { 00086 RenderEffect::init_type(); 00087 register_type(_type_handle, "OccluderEffect", 00088 RenderEffect::get_class_type()); 00089 } 00090 virtual TypeHandle get_type() const { 00091 return get_class_type(); 00092 } 00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00094 00095 private: 00096 static TypeHandle _type_handle; 00097 }; 00098 00099 #include "occluderEffect.I" 00100 00101 #endif 00102