Panda3D
 All Classes Functions Variables Enumerations
characterVertexSlider.cxx
00001 // Filename: characterVertexSlider.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 "characterVertexSlider.h"
00016 #include "datagram.h"
00017 #include "datagramIterator.h"
00018 #include "bamReader.h"
00019 #include "bamWriter.h"
00020 
00021 TypeHandle CharacterVertexSlider::_type_handle;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: CharacterVertexSlider::Default Constructor
00025 //       Access: Private
00026 //  Description: Constructs an invalid object; used only by the bam
00027 //               loader.
00028 ////////////////////////////////////////////////////////////////////
00029 CharacterVertexSlider::
00030 CharacterVertexSlider() :
00031   VertexSlider(InternalName::get_root())
00032 {
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: CharacterVertexSlider::Constructor
00037 //       Access: Published
00038 //  Description: Constructs a new object that converts vertices from
00039 //               the indicated joint's coordinate space, into the
00040 //               other indicated joint's space.
00041 ////////////////////////////////////////////////////////////////////
00042 CharacterVertexSlider::
00043 CharacterVertexSlider(CharacterSlider *char_slider) :
00044   VertexSlider(InternalName::make(char_slider->get_name())),
00045   _char_slider(char_slider)
00046 {
00047   // Tell the char_slider that we need to be informed when it moves.
00048   _char_slider->_vertex_sliders.insert(this);
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: CharacterVertexSlider::Destructor
00053 //       Access: Published, Virtual
00054 //  Description: 
00055 ////////////////////////////////////////////////////////////////////
00056 CharacterVertexSlider::
00057 ~CharacterVertexSlider() {
00058   // Tell the char_slider to stop informing us about its motion.
00059   _char_slider->_vertex_sliders.erase(this);
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: CharacterVertexSlider::get_slider
00064 //       Access: Published, Virtual
00065 //  Description: Returns the current slider value.
00066 ////////////////////////////////////////////////////////////////////
00067 PN_stdfloat CharacterVertexSlider::
00068 get_slider() const {
00069   return _char_slider->_value;
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: CharacterVertexSlider::register_with_read_factory
00074 //       Access: Public, Static
00075 //  Description: Tells the BamReader how to create objects of type
00076 //               CharacterVertexSlider.
00077 ////////////////////////////////////////////////////////////////////
00078 void CharacterVertexSlider::
00079 register_with_read_factory() {
00080   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: CharacterVertexSlider::write_datagram
00085 //       Access: Public, Virtual
00086 //  Description: Writes the contents of this object to the datagram
00087 //               for shipping out to a Bam file.
00088 ////////////////////////////////////////////////////////////////////
00089 void CharacterVertexSlider::
00090 write_datagram(BamWriter *manager, Datagram &dg) {
00091   VertexSlider::write_datagram(manager, dg);
00092 
00093   manager->write_pointer(dg, _char_slider);
00094 }
00095 
00096 ////////////////////////////////////////////////////////////////////
00097 //     Function: CharacterVertexSlider::complete_pointers
00098 //       Access: Public, Virtual
00099 //  Description: Receives an array of pointers, one for each time
00100 //               manager->read_pointer() was called in fillin().
00101 //               Returns the number of pointers processed.
00102 ////////////////////////////////////////////////////////////////////
00103 int CharacterVertexSlider::
00104 complete_pointers(TypedWritable **p_list, BamReader *manager) {
00105   int pi = VertexSlider::complete_pointers(p_list, manager);
00106 
00107   _char_slider = DCAST(CharacterSlider, p_list[pi++]);    
00108   _char_slider->_vertex_sliders.insert(this);
00109   _name = InternalName::make(_char_slider->get_name());
00110 
00111   return pi;
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: CharacterVertexSlider::make_from_bam
00116 //       Access: Protected, Static
00117 //  Description: This function is called by the BamReader's factory
00118 //               when a new object of type CharacterVertexSlider is encountered
00119 //               in the Bam file.  It should create the CharacterVertexSlider
00120 //               and extract its information from the file.
00121 ////////////////////////////////////////////////////////////////////
00122 TypedWritable *CharacterVertexSlider::
00123 make_from_bam(const FactoryParams &params) {
00124   CharacterVertexSlider *object = new CharacterVertexSlider;
00125   DatagramIterator scan;
00126   BamReader *manager;
00127 
00128   parse_params(params, scan, manager);
00129   object->fillin(scan, manager);
00130 
00131   return object;
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: CharacterVertexSlider::fillin
00136 //       Access: Protected
00137 //  Description: This internal function is called by make_from_bam to
00138 //               read in all of the relevant data from the BamFile for
00139 //               the new CharacterVertexSlider.
00140 ////////////////////////////////////////////////////////////////////
00141 void CharacterVertexSlider::
00142 fillin(DatagramIterator &scan, BamReader *manager) {
00143   VertexSlider::fillin(scan, manager);
00144 
00145   manager->read_pointer(scan);
00146 }
 All Classes Functions Variables Enumerations