00001 // Filename: partBundleNode.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 "partBundleNode.h" 00020 #include "datagram.h" 00021 #include "datagramIterator.h" 00022 #include "bamReader.h" 00023 #include "bamWriter.h" 00024 00025 TypeHandle PartBundleNode::_type_handle; 00026 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: PartBundleNode::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 PartBundleNode:: 00038 safe_to_flatten() const { 00039 return false; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: PartBundleNode::write_datagram 00044 // Access: Public, Virtual 00045 // Description: Writes the contents of this object to the datagram 00046 // for shipping out to a Bam file. 00047 //////////////////////////////////////////////////////////////////// 00048 void PartBundleNode:: 00049 write_datagram(BamWriter *manager, Datagram &dg) { 00050 PandaNode::write_datagram(manager, dg); 00051 manager->write_pointer(dg, _bundle); 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function: PartBundleNode::complete_pointers 00056 // Access: Public, Virtual 00057 // Description: Receives an array of pointers, one for each time 00058 // manager->read_pointer() was called in fillin(). 00059 // Returns the number of pointers processed. 00060 //////////////////////////////////////////////////////////////////// 00061 int PartBundleNode:: 00062 complete_pointers(TypedWritable **p_list, BamReader* manager) { 00063 int pi = PandaNode::complete_pointers(p_list, manager); 00064 _bundle = DCAST(PartBundle, p_list[pi++]); 00065 _bundle->_node = this; 00066 return pi; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: PartBundleNode::fillin 00071 // Access: Protected 00072 // Description: This internal function is called by make_from_bam to 00073 // read in all of the relevant data from the BamFile for 00074 // the new PandaNode. 00075 //////////////////////////////////////////////////////////////////// 00076 void PartBundleNode:: 00077 fillin(DatagramIterator &scan, BamReader* manager) { 00078 PandaNode::fillin(scan, manager); 00079 manager->read_pointer(scan); 00080 }