Panda3D

userVertexSlider.cxx

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