00001 // Filename: movingPart.I 00002 // Created by: drose (22Feb99) 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 "animChannelFixed.h" 00020 #include <datagram.h> 00021 #include <datagramIterator.h> 00022 #include <bamReader.h> 00023 #include <bamWriter.h> 00024 00025 template<class SwitchType> 00026 TypeHandle MovingPart<SwitchType>::_type_handle; 00027 00028 // We don't need to explicitly call MovingPart::init_type(), because 00029 // it is an abstract class and therefore must have derived objects. 00030 // Its derived objects will call init_type() for us. 00031 00032 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: MovingPart::Copy Constructor 00036 // Access: Protected 00037 // Description: Normally, you'd use make_copy() or copy_subgraph() to 00038 // make a copy of this. 00039 //////////////////////////////////////////////////////////////////// 00040 template<class SwitchType> 00041 INLINE MovingPart<SwitchType>:: 00042 MovingPart(const MovingPart<SwitchType> ©) : 00043 MovingPartBase(copy), 00044 _value(copy._value), 00045 _initial_value(copy._initial_value) 00046 { 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: MovingPart::Constructor 00051 // Access: Public 00052 // Description: 00053 //////////////////////////////////////////////////////////////////// 00054 template<class SwitchType> 00055 INLINE MovingPart<SwitchType>:: 00056 MovingPart(PartGroup *parent, const string &name, 00057 const ValueType &initial_value) : 00058 MovingPartBase(parent, name), 00059 _value(initial_value), 00060 _initial_value(initial_value) 00061 { 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: MovingPart::Constructor 00066 // Access: Protected 00067 // Description: 00068 //////////////////////////////////////////////////////////////////// 00069 template<class SwitchType> 00070 INLINE MovingPart<SwitchType>:: 00071 MovingPart(void) { 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: MovingPart::get_value_type 00076 // Access: Public, Virtual 00077 // Description: Returns the TypeHandle associated with the ValueType 00078 // we are concerned with. This is provided to allow a 00079 // bit of run-time checking that joints and channels are 00080 // matching properly in type. 00081 //////////////////////////////////////////////////////////////////// 00082 template<class SwitchType> 00083 TypeHandle MovingPart<SwitchType>:: 00084 get_value_type() const { 00085 return get_type_handle(ValueType); 00086 } 00087 00088 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: MovingPart::make_initial_channel 00092 // Access: Public, Virtual 00093 // Description: Creates and returns a new AnimChannel that is not 00094 // part of any hierarchy, but that returns the default 00095 // value associated with this part. 00096 //////////////////////////////////////////////////////////////////// 00097 template<class SwitchType> 00098 AnimChannelBase *MovingPart<SwitchType>:: 00099 make_initial_channel() const { 00100 return new AnimChannelFixed<SwitchType>(get_name(), _initial_value); 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: MovingPart::output_value 00105 // Access: Public, Virtual 00106 // Description: Outputs a very brief description of the channel's 00107 // current value. 00108 //////////////////////////////////////////////////////////////////// 00109 template<class SwitchType> 00110 void MovingPart<SwitchType>:: 00111 output_value(ostream &out) const { 00112 SwitchType::output_value(out, _value); 00113 } 00114 00115 //////////////////////////////////////////////////////////////////// 00116 // Function: MovingPart::write_datagram 00117 // Access: Public 00118 // Description: Function to write the important information in 00119 // the particular object to a Datagram 00120 //////////////////////////////////////////////////////////////////// 00121 template<class SwitchType> 00122 void MovingPart<SwitchType>:: 00123 write_datagram(BamWriter *manager, Datagram &me) 00124 { 00125 MovingPartBase::write_datagram(manager, me); 00126 SwitchType::write_datagram(me, _value); 00127 SwitchType::write_datagram(me, _initial_value); 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: MovingPart::fillin 00132 // Access: Protected 00133 // Description: Function that reads out of the datagram (or asks 00134 // manager to read) all of the data that is needed to 00135 // re-create this object and stores it in the appropiate 00136 // place 00137 //////////////////////////////////////////////////////////////////// 00138 template<class SwitchType> 00139 void MovingPart<SwitchType>:: 00140 fillin(DatagramIterator& scan, BamReader* manager) 00141 { 00142 MovingPartBase::fillin(scan, manager); 00143 SwitchType::read_datagram(scan, _value); 00144 SwitchType::read_datagram(scan, _initial_value); 00145 } 00146 00147 00148