Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/egg-palettize/texturePosition.cxx

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

Generated on Fri May 2 03:18:14 2003 for Panda-Tool by doxygen1.3