00001 // Filename: animBundleNode.cxx 00002 // Created by: drose (06Mar02) 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 "animBundleNode.h" 00020 #include "datagram.h" 00021 #include "datagramIterator.h" 00022 #include "bamReader.h" 00023 #include "bamWriter.h" 00024 00025 TypeHandle AnimBundleNode::_type_handle; 00026 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: AnimBundleNode::safe_to_flatten 00030 // Access: Public, Virtual 00031 // Description: Returns true if it is generally safe to flatten out 00032 // this particular kind of Node by duplicating 00033 // instances, false otherwise (for instance, a Camera 00034 // cannot be safely flattened, because the Camera 00035 // pointer itself is meaningful). 00036 //////////////////////////////////////////////////////////////////// 00037 bool AnimBundleNode:: 00038 safe_to_flatten() const { 00039 return false; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: AnimBundleNode::register_with_read_factory 00044 // Access: Public, Static 00045 // Description: Tells the BamReader how to create objects of type 00046 // AnimBundleNode. 00047 //////////////////////////////////////////////////////////////////// 00048 void AnimBundleNode:: 00049 register_with_read_factory() { 00050 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: AnimBundleNode::write_datagram 00055 // Access: Public, Virtual 00056 // Description: Writes the contents of this object to the datagram 00057 // for shipping out to a Bam file. 00058 //////////////////////////////////////////////////////////////////// 00059 void AnimBundleNode:: 00060 write_datagram(BamWriter *manager, Datagram &dg) { 00061 PandaNode::write_datagram(manager, dg); 00062 manager->write_pointer(dg, _bundle); 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: AnimBundleNode::complete_pointers 00067 // Access: Public, Virtual 00068 // Description: Receives an array of pointers, one for each time 00069 // manager->read_pointer() was called in fillin(). 00070 // Returns the number of pointers processed. 00071 //////////////////////////////////////////////////////////////////// 00072 int AnimBundleNode:: 00073 complete_pointers(TypedWritable **p_list, BamReader* manager) { 00074 int pi = PandaNode::complete_pointers(p_list, manager); 00075 _bundle = DCAST(AnimBundle, p_list[pi++]); 00076 return pi; 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function: AnimBundleNode::make_from_bam 00081 // Access: Protected, Static 00082 // Description: This function is called by the BamReader's factory 00083 // when a new object of this type is encountered 00084 // in the Bam file. It should create the object 00085 // and extract its information from the file. 00086 //////////////////////////////////////////////////////////////////// 00087 TypedWritable *AnimBundleNode:: 00088 make_from_bam(const FactoryParams ¶ms) { 00089 AnimBundleNode *node = new AnimBundleNode; 00090 DatagramIterator scan; 00091 BamReader *manager; 00092 00093 parse_params(params, scan, manager); 00094 node->fillin(scan, manager); 00095 00096 return node; 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: AnimBundleNode::fillin 00101 // Access: Protected 00102 // Description: This internal function is called by make_from_bam to 00103 // read in all of the relevant data from the BamFile for 00104 // the new PandaNode. 00105 //////////////////////////////////////////////////////////////////// 00106 void AnimBundleNode:: 00107 fillin(DatagramIterator &scan, BamReader* manager) { 00108 PandaNode::fillin(scan, manager); 00109 manager->read_pointer(scan); 00110 }