Panda3D
userVertexTransform.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file userVertexTransform.cxx
10  * @author drose
11  * @date 2005-03-24
12  */
13 
14 #include "userVertexTransform.h"
15 #include "bamReader.h"
16 #include "bamWriter.h"
17 
18 TypeHandle UserVertexTransform::_type_handle;
19 
20 /**
21  *
22  */
23 UserVertexTransform::
24 UserVertexTransform(const std::string &name) :
25  _name(name)
26 {
27 }
28 
29 /**
30  * Returns the transform's matrix.
31  */
33 get_matrix(LMatrix4 &matrix) const {
34  CDReader cdata(_cycler);
35  matrix = cdata->_matrix;
36 }
37 
38 /**
39  *
40  */
41 void UserVertexTransform::
42 output(std::ostream &out) const {
43  out << get_type() << " " << get_name();
44 }
45 
46 /**
47  *
48  */
49 CycleData *UserVertexTransform::CData::
50 make_copy() const {
51  return new CData(*this);
52 }
53 
54 /**
55  * Tells the BamReader how to create objects of type UserVertexTransform.
56  */
59  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
60 }
61 
62 /**
63  * Writes the contents of this object to the datagram for shipping out to a
64  * Bam file.
65  */
69 
70  manager->write_cdata(dg, _cycler);
71 }
72 
73 /**
74  * This function is called by the BamReader's factory when a new object of
75  * type UserVertexTransform is encountered in the Bam file. It should create
76  * the UserVertexTransform and extract its information from the file.
77  */
78 TypedWritable *UserVertexTransform::
79 make_from_bam(const FactoryParams &params) {
80  UserVertexTransform *object = new UserVertexTransform("");
81  DatagramIterator scan;
82  BamReader *manager;
83 
84  parse_params(params, scan, manager);
85  object->fillin(scan, manager);
86 
87  return object;
88 }
89 
90 /**
91  * This internal function is called by make_from_bam to read in all of the
92  * relevant data from the BamFile for the new UserVertexTransform.
93  */
94 void UserVertexTransform::
95 fillin(DatagramIterator &scan, BamReader *manager) {
96  VertexTransform::fillin(scan, manager);
97 
98  manager->read_cdata(scan, _cycler);
99 }
100 
101 /**
102  * Writes the contents of this object to the datagram for shipping out to a
103  * Bam file.
104  */
105 void UserVertexTransform::CData::
106 write_datagram(BamWriter *manager, Datagram &dg) const {
107  _matrix.write_datagram(dg);
108 }
109 
110 /**
111  * This internal function is called by make_from_bam to read in all of the
112  * relevant data from the BamFile for the new UserVertexTransform.
113  */
114 void UserVertexTransform::CData::
115 fillin(DatagramIterator &scan, BamReader *manager) {
116  _matrix.read_datagram(scan);
117 }
const std::string & get_name() const
Returns the name passed to the constructor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
Definition: bamReader.cxx:695
virtual void get_matrix(LMatrix4 &matrix) const
Returns the transform's matrix.
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:47
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
Definition: bamWriter.cxx:425
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition: bamReader.I:275
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:73
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
This is a specialization on VertexTransform that allows the user to specify any arbitrary transform m...
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void register_with_read_factory()
Tells the BamReader how to create objects of type UserVertexTransform.