00001 // Filename: showBoundsEffect.cxx 00002 // Created by: drose (25Mar02) 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 #include "showBoundsEffect.h" 00020 #include "bamReader.h" 00021 #include "bamWriter.h" 00022 #include "datagram.h" 00023 #include "datagramIterator.h" 00024 00025 TypeHandle ShowBoundsEffect::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: ShowBoundsEffect::make 00029 // Access: Published, Static 00030 // Description: Constructs a new ShowBoundsEffect object. 00031 //////////////////////////////////////////////////////////////////// 00032 CPT(RenderEffect) ShowBoundsEffect:: 00033 make() { 00034 ShowBoundsEffect *effect = new ShowBoundsEffect; 00035 return return_new(effect); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: ShowBoundsEffect::safe_to_combine 00040 // Access: Public, Virtual 00041 // Description: Returns true if this kind of effect can safely be 00042 // combined with sibling nodes that share the exact same 00043 // effect, or false if this is not a good idea. 00044 //////////////////////////////////////////////////////////////////// 00045 bool ShowBoundsEffect:: 00046 safe_to_combine() const { 00047 return false; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: ShowBoundsEffect::compare_to_impl 00052 // Access: Protected, Virtual 00053 // Description: Intended to be overridden by derived ShowBoundsEffect 00054 // types to return a unique number indicating whether 00055 // this ShowBoundsEffect is equivalent to the other one. 00056 // 00057 // This should return 0 if the two ShowBoundsEffect objects 00058 // are equivalent, a number less than zero if this one 00059 // should be sorted before the other one, and a number 00060 // greater than zero otherwise. 00061 // 00062 // This will only be called with two ShowBoundsEffect 00063 // objects whose get_type() functions return the same. 00064 //////////////////////////////////////////////////////////////////// 00065 int ShowBoundsEffect:: 00066 compare_to_impl(const RenderEffect *other) const { 00067 // All ShowBoundsEffects are equivalent--there are no properties to 00068 // store. 00069 return 0; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: ShowBoundsEffect::make_default_impl 00074 // Access: Protected, Virtual 00075 // Description: Intended to be overridden by derived ShowBoundsEffect 00076 // types to specify what the default property for a 00077 // ShowBoundsEffect of this type should be. 00078 // 00079 // This should return a newly-allocated ShowBoundsEffect of 00080 // the same type that corresponds to whatever the 00081 // standard default for this kind of ShowBoundsEffect is. 00082 //////////////////////////////////////////////////////////////////// 00083 RenderEffect *ShowBoundsEffect:: 00084 make_default_impl() const { 00085 return new ShowBoundsEffect; 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: ShowBoundsEffect::register_with_read_factory 00090 // Access: Public, Static 00091 // Description: Tells the BamReader how to create objects of type 00092 // ShowBoundsEffect. 00093 //////////////////////////////////////////////////////////////////// 00094 void ShowBoundsEffect:: 00095 register_with_read_factory() { 00096 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: ShowBoundsEffect::write_datagram 00101 // Access: Public, Virtual 00102 // Description: Writes the contents of this object to the datagram 00103 // for shipping out to a Bam file. 00104 //////////////////////////////////////////////////////////////////// 00105 void ShowBoundsEffect:: 00106 write_datagram(BamWriter *manager, Datagram &dg) { 00107 RenderEffect::write_datagram(manager, dg); 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: ShowBoundsEffect::make_from_bam 00112 // Access: Protected, Static 00113 // Description: This function is called by the BamReader's factory 00114 // when a new object of type ShowBoundsEffect is encountered 00115 // in the Bam file. It should create the ShowBoundsEffect 00116 // and extract its information from the file. 00117 //////////////////////////////////////////////////////////////////// 00118 TypedWritable *ShowBoundsEffect:: 00119 make_from_bam(const FactoryParams ¶ms) { 00120 ShowBoundsEffect *effect = new ShowBoundsEffect; 00121 DatagramIterator scan; 00122 BamReader *manager; 00123 00124 parse_params(params, scan, manager); 00125 effect->fillin(scan, manager); 00126 00127 return effect; 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: ShowBoundsEffect::fillin 00132 // Access: Protected 00133 // Description: This internal function is called by make_from_bam to 00134 // read in all of the relevant data from the BamFile for 00135 // the new ShowBoundsEffect. 00136 //////////////////////////////////////////////////////////////////// 00137 void ShowBoundsEffect:: 00138 fillin(DatagramIterator &scan, BamReader *manager) { 00139 RenderEffect::fillin(scan, manager); 00140 }