Panda3D
modelRoot.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 modelRoot.cxx
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #include "modelRoot.h"
15 
16 TypeHandle ModelRoot::_type_handle;
17 
18 
19 /**
20  * Returns a newly-allocated Node that is a shallow copy of this one. It will
21  * be a different Node pointer, but its internal data may or may not be shared
22  * with that of the original Node.
23  */
25 make_copy() const {
26  return new ModelRoot(*this);
27 }
28 
29 /**
30  * Tells the BamReader how to create objects of type ModelRoot.
31  */
32 void ModelRoot::
34  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
35 }
36 
37 /**
38  * Writes the contents of this object to the datagram for shipping out to a
39  * Bam file.
40  */
41 void ModelRoot::
43  ModelNode::write_datagram(manager, dg);
44 }
45 
46 /**
47  * This function is called by the BamReader's factory when a new object of
48  * type ModelRoot is encountered in the Bam file. It should create the
49  * ModelRoot and extract its information from the file.
50  */
51 TypedWritable *ModelRoot::
52 make_from_bam(const FactoryParams &params) {
53  ModelRoot *node = new ModelRoot("");
54  DatagramIterator scan;
55  BamReader *manager;
56 
57  parse_params(params, scan, manager);
58  node->fillin(scan, manager);
59 
60  return node;
61 }
62 
63 /**
64  * This internal function is called by make_from_bam to read in all of the
65  * relevant data from the BamFile for the new ModelRoot.
66  */
67 void ModelRoot::
68 fillin(DatagramIterator &scan, BamReader *manager) {
69  ModelNode::fillin(scan, manager);
70 }
A node of this type is created automatically at the root of each model file that is loaded.
Definition: modelRoot.h:27
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
static void register_with_read_factory()
Tells the BamReader how to create objects of type ModelRoot.
Definition: modelRoot.cxx:33
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: modelNode.cxx:175
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: modelRoot.cxx:25
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
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
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: modelRoot.cxx:42
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
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
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