00001 // Filename: decalEffect.cxx 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 #include "decalEffect.h" 00020 #include "bamReader.h" 00021 #include "bamWriter.h" 00022 #include "datagram.h" 00023 #include "datagramIterator.h" 00024 00025 TypeHandle DecalEffect::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: DecalEffect::make 00029 // Access: Published, Static 00030 // Description: Constructs a new DecalEffect object. 00031 //////////////////////////////////////////////////////////////////// 00032 CPT(RenderEffect) DecalEffect:: 00033 make() { 00034 DecalEffect *effect = new DecalEffect; 00035 return return_new(effect); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: DecalEffect::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 DecalEffect:: 00046 safe_to_combine() const { 00047 return false; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: DecalEffect::compare_to_impl 00052 // Access: Protected, Virtual 00053 // Description: Intended to be overridden by derived DecalEffect 00054 // types to return a unique number indicating whether 00055 // this DecalEffect is equivalent to the other one. 00056 // 00057 // This should return 0 if the two DecalEffect 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 DecalEffect 00063 // objects whose get_type() functions return the same. 00064 //////////////////////////////////////////////////////////////////// 00065 int DecalEffect:: 00066 compare_to_impl(const RenderEffect *other) const { 00067 // All DecalEffects are equivalent--there are no properties to 00068 // store. 00069 return 0; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: DecalEffect::register_with_read_factory 00074 // Access: Public, Static 00075 // Description: Tells the BamReader how to create objects of type 00076 // DecalEffect. 00077 //////////////////////////////////////////////////////////////////// 00078 void DecalEffect:: 00079 register_with_read_factory() { 00080 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: DecalEffect::write_datagram 00085 // Access: Public, Virtual 00086 // Description: Writes the contents of this object to the datagram 00087 // for shipping out to a Bam file. 00088 //////////////////////////////////////////////////////////////////// 00089 void DecalEffect:: 00090 write_datagram(BamWriter *manager, Datagram &dg) { 00091 RenderEffect::write_datagram(manager, dg); 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: DecalEffect::make_from_bam 00096 // Access: Protected, Static 00097 // Description: This function is called by the BamReader's factory 00098 // when a new object of type DecalEffect is encountered 00099 // in the Bam file. It should create the DecalEffect 00100 // and extract its information from the file. 00101 //////////////////////////////////////////////////////////////////// 00102 TypedWritable *DecalEffect:: 00103 make_from_bam(const FactoryParams ¶ms) { 00104 DecalEffect *effect = new DecalEffect; 00105 DatagramIterator scan; 00106 BamReader *manager; 00107 00108 parse_params(params, scan, manager); 00109 effect->fillin(scan, manager); 00110 00111 return effect; 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: DecalEffect::fillin 00116 // Access: Protected 00117 // Description: This internal function is called by make_from_bam to 00118 // read in all of the relevant data from the BamFile for 00119 // the new DecalEffect. 00120 //////////////////////////////////////////////////////////////////// 00121 void DecalEffect:: 00122 fillin(DatagramIterator &scan, BamReader *manager) { 00123 RenderEffect::fillin(scan, manager); 00124 }