Panda3D

userVertexTransform.cxx

00001 // Filename: userVertexTransform.cxx
00002 // Created by:  drose (24Mar05)
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 "userVertexTransform.h"
00016 #include "bamReader.h"
00017 #include "bamWriter.h"
00018 
00019 TypeHandle UserVertexTransform::_type_handle;
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //     Function: UserVertexTransform::Constructor
00023 //       Access: Published
00024 //  Description: 
00025 ////////////////////////////////////////////////////////////////////
00026 UserVertexTransform::
00027 UserVertexTransform(const string &name) :
00028   _name(name)
00029 {
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: UserVertexTransform::get_matrix
00034 //       Access: Published, Virtual
00035 //  Description: Returns the transform's matrix.
00036 ////////////////////////////////////////////////////////////////////
00037 void UserVertexTransform::
00038 get_matrix(LMatrix4 &matrix) const {
00039   CDReader cdata(_cycler);
00040   matrix = cdata->_matrix;
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: UserVertexTransform::output
00045 //       Access: Published, Virtual
00046 //  Description: 
00047 ////////////////////////////////////////////////////////////////////
00048 void UserVertexTransform::
00049 output(ostream &out) const {
00050   out << get_type() << " " << get_name();
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: UserVertexTransform::CData::make_copy
00055 //       Access: Public, Virtual
00056 //  Description:
00057 ////////////////////////////////////////////////////////////////////
00058 CycleData *UserVertexTransform::CData::
00059 make_copy() const {
00060   return new CData(*this);
00061 }
00062 
00063 ////////////////////////////////////////////////////////////////////
00064 //     Function: UserVertexTransform::register_with_read_factory
00065 //       Access: Public, Static
00066 //  Description: Tells the BamReader how to create objects of type
00067 //               UserVertexTransform.
00068 ////////////////////////////////////////////////////////////////////
00069 void UserVertexTransform::
00070 register_with_read_factory() {
00071   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //     Function: UserVertexTransform::write_datagram
00076 //       Access: Public, Virtual
00077 //  Description: Writes the contents of this object to the datagram
00078 //               for shipping out to a Bam file.
00079 ////////////////////////////////////////////////////////////////////
00080 void UserVertexTransform::
00081 write_datagram(BamWriter *manager, Datagram &dg) {
00082   VertexTransform::write_datagram(manager, dg);
00083 
00084   manager->write_cdata(dg, _cycler);
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: UserVertexTransform::make_from_bam
00089 //       Access: Protected, Static
00090 //  Description: This function is called by the BamReader's factory
00091 //               when a new object of type UserVertexTransform is encountered
00092 //               in the Bam file.  It should create the UserVertexTransform
00093 //               and extract its information from the file.
00094 ////////////////////////////////////////////////////////////////////
00095 TypedWritable *UserVertexTransform::
00096 make_from_bam(const FactoryParams &params) {
00097   UserVertexTransform *object = new UserVertexTransform("");
00098   DatagramIterator scan;
00099   BamReader *manager;
00100 
00101   parse_params(params, scan, manager);
00102   object->fillin(scan, manager);
00103 
00104   return object;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: UserVertexTransform::fillin
00109 //       Access: Protected
00110 //  Description: This internal function is called by make_from_bam to
00111 //               read in all of the relevant data from the BamFile for
00112 //               the new UserVertexTransform.
00113 ////////////////////////////////////////////////////////////////////
00114 void UserVertexTransform::
00115 fillin(DatagramIterator &scan, BamReader *manager) {
00116   VertexTransform::fillin(scan, manager);
00117 
00118   manager->read_cdata(scan, _cycler);
00119 }
00120 
00121 ////////////////////////////////////////////////////////////////////
00122 //     Function: UserVertexTransform::CData::write_datagram
00123 //       Access: Public, Virtual
00124 //  Description: Writes the contents of this object to the datagram
00125 //               for shipping out to a Bam file.
00126 ////////////////////////////////////////////////////////////////////
00127 void UserVertexTransform::CData::
00128 write_datagram(BamWriter *manager, Datagram &dg) const {
00129   _matrix.write_datagram(dg);
00130 }
00131 
00132 ////////////////////////////////////////////////////////////////////
00133 //     Function: UserVertexTransform::CData::fillin
00134 //       Access: Public, Virtual
00135 //  Description: This internal function is called by make_from_bam to
00136 //               read in all of the relevant data from the BamFile for
00137 //               the new UserVertexTransform.
00138 ////////////////////////////////////////////////////////////////////
00139 void UserVertexTransform::CData::
00140 fillin(DatagramIterator &scan, BamReader *manager) {
00141   _matrix.read_datagram(scan);
00142 }
 All Classes Functions Variables Enumerations