Panda3D
Loading...
Searching...
No Matches
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
18TypeHandle UserVertexTransform::_type_handle;
19
20/**
21 *
22 */
23UserVertexTransform::
24UserVertexTransform(const std::string &name) :
25 _name(name)
26{
27}
28
29/**
30 * Returns the transform's matrix.
31 */
33get_matrix(LMatrix4 &matrix) const {
34 CDReader cdata(_cycler);
35 matrix = cdata->_matrix;
36}
37
38/**
39 *
40 */
41void UserVertexTransform::
42output(std::ostream &out) const {
43 out << get_type() << " " << get_name();
44}
45
46/**
47 *
48 */
49CycleData *UserVertexTransform::CData::
50make_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 */
67write_datagram(BamWriter *manager, Datagram &dg) {
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 */
78TypedWritable *UserVertexTransform::
79make_from_bam(const FactoryParams &params) {
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 */
94void UserVertexTransform::
95fillin(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 */
105void UserVertexTransform::CData::
106write_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 */
114void UserVertexTransform::CData::
115fillin(DatagramIterator &scan, BamReader *manager) {
116 _matrix.read_datagram(scan);
117}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
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.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
This is a specialization on VertexTransform that allows the user to specify any arbitrary transform m...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void register_with_read_factory()
Tells the BamReader how to create objects of type UserVertexTransform.
const std::string & get_name() const
Returns the name passed to the constructor.
virtual void get_matrix(LMatrix4 &matrix) const
Returns the transform's matrix.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.