Panda3D
|
00001 // Filename: texturePosition.cxx 00002 // Created by: drose (04Dec00) 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 "texturePosition.h" 00016 00017 #include "datagram.h" 00018 #include "datagramIterator.h" 00019 #include "bamReader.h" 00020 #include "bamWriter.h" 00021 00022 TypeHandle TexturePosition::_type_handle; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function: TexturePosition::Constructor 00026 // Access: Public 00027 // Description: 00028 //////////////////////////////////////////////////////////////////// 00029 TexturePosition:: 00030 TexturePosition() { 00031 _margin = 0; 00032 _x = 0; 00033 _y = 0; 00034 _x_size = 0; 00035 _y_size = 0; 00036 _min_uv.set(0.0, 0.0); 00037 _max_uv.set(0.0, 0.0); 00038 _wrap_u = EggTexture::WM_unspecified; 00039 _wrap_v = EggTexture::WM_unspecified; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: TexturePosition::Copy Constructor 00044 // Access: Public 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 TexturePosition:: 00048 TexturePosition(const TexturePosition ©) : 00049 _margin(copy._margin), 00050 _x(copy._x), 00051 _y(copy._y), 00052 _x_size(copy._x_size), 00053 _y_size(copy._y_size), 00054 _min_uv(copy._min_uv), 00055 _max_uv(copy._max_uv), 00056 _wrap_u(copy._wrap_u), 00057 _wrap_v(copy._wrap_v) 00058 { 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: TexturePosition::Copy Assignment Operator 00063 // Access: Public 00064 // Description: 00065 //////////////////////////////////////////////////////////////////// 00066 void TexturePosition:: 00067 operator = (const TexturePosition ©) { 00068 _margin = copy._margin; 00069 _x = copy._x; 00070 _y = copy._y; 00071 _x_size = copy._x_size; 00072 _y_size = copy._y_size; 00073 _min_uv = copy._min_uv; 00074 _max_uv = copy._max_uv; 00075 _wrap_u = copy._wrap_u; 00076 _wrap_v = copy._wrap_v; 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function: TexturePosition::register_with_read_factory 00081 // Access: Public, Static 00082 // Description: Registers the current object as something that can be 00083 // read from a Bam file. 00084 //////////////////////////////////////////////////////////////////// 00085 void TexturePosition:: 00086 register_with_read_factory() { 00087 BamReader::get_factory()-> 00088 register_factory(get_class_type(), make_TexturePosition); 00089 } 00090 00091 //////////////////////////////////////////////////////////////////// 00092 // Function: TexturePosition::write_datagram 00093 // Access: Public, Virtual 00094 // Description: Fills the indicated datagram up with a binary 00095 // representation of the current object, in preparation 00096 // for writing to a Bam file. 00097 //////////////////////////////////////////////////////////////////// 00098 void TexturePosition:: 00099 write_datagram(BamWriter *writer, Datagram &datagram) { 00100 TypedWritable::write_datagram(writer, datagram); 00101 datagram.add_int32(_margin); 00102 datagram.add_int32(_x); 00103 datagram.add_int32(_y); 00104 datagram.add_int32(_x_size); 00105 datagram.add_int32(_y_size); 00106 datagram.add_float64(_min_uv[0]); 00107 datagram.add_float64(_min_uv[1]); 00108 datagram.add_float64(_max_uv[0]); 00109 datagram.add_float64(_max_uv[1]); 00110 datagram.add_int32((int)_wrap_u); 00111 datagram.add_int32((int)_wrap_v); 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: TexturePosition::make_TexturePosition 00116 // Access: Protected 00117 // Description: This method is called by the BamReader when an object 00118 // of this type is encountered in a Bam file; it should 00119 // allocate and return a new object with all the data 00120 // read. 00121 //////////////////////////////////////////////////////////////////// 00122 TypedWritable* TexturePosition:: 00123 make_TexturePosition(const FactoryParams ¶ms) { 00124 TexturePosition *me = new TexturePosition; 00125 DatagramIterator scan; 00126 BamReader *manager; 00127 00128 parse_params(params, scan, manager); 00129 me->fillin(scan, manager); 00130 return me; 00131 } 00132 00133 //////////////////////////////////////////////////////////////////// 00134 // Function: TexturePosition::fillin 00135 // Access: Protected 00136 // Description: Reads the binary data from the given datagram 00137 // iterator, which was written by a previous call to 00138 // write_datagram(). 00139 //////////////////////////////////////////////////////////////////// 00140 void TexturePosition:: 00141 fillin(DatagramIterator &scan, BamReader *manager) { 00142 TypedWritable::fillin(scan, manager); 00143 _margin = scan.get_int32(); 00144 _x = scan.get_int32(); 00145 _y = scan.get_int32(); 00146 _x_size = scan.get_int32(); 00147 _y_size = scan.get_int32(); 00148 _min_uv[0] = scan.get_float64(); 00149 _min_uv[1] = scan.get_float64(); 00150 _max_uv[0] = scan.get_float64(); 00151 _max_uv[1] = scan.get_float64(); 00152 _wrap_u = (EggTexture::WrapMode)scan.get_int32(); 00153 _wrap_v = (EggTexture::WrapMode)scan.get_int32(); 00154 }