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