Panda3D
modelRoot.cxx
1 // Filename: modelRoot.cxx
2 // Created by: drose (16Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "modelRoot.h"
16 
17 TypeHandle ModelRoot::_type_handle;
18 
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: ModelRoot::make_copy
22 // Access: Public, Virtual
23 // Description: Returns a newly-allocated Node that is a shallow copy
24 // of this one. It will be a different Node pointer,
25 // but its internal data may or may not be shared with
26 // that of the original Node.
27 ////////////////////////////////////////////////////////////////////
29 make_copy() const {
30  return new ModelRoot(*this);
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: ModelRoot::register_with_read_factory
35 // Access: Public, Static
36 // Description: Tells the BamReader how to create objects of type
37 // ModelRoot.
38 ////////////////////////////////////////////////////////////////////
39 void ModelRoot::
41  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: ModelRoot::write_datagram
46 // Access: Public, Virtual
47 // Description: Writes the contents of this object to the datagram
48 // for shipping out to a Bam file.
49 ////////////////////////////////////////////////////////////////////
50 void ModelRoot::
52  ModelNode::write_datagram(manager, dg);
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: ModelRoot::make_from_bam
57 // Access: Protected, Static
58 // Description: This function is called by the BamReader's factory
59 // when a new object of type ModelRoot is encountered
60 // in the Bam file. It should create the ModelRoot
61 // and extract its information from the file.
62 ////////////////////////////////////////////////////////////////////
63 TypedWritable *ModelRoot::
64 make_from_bam(const FactoryParams &params) {
65  ModelRoot *node = new ModelRoot("");
66  DatagramIterator scan;
67  BamReader *manager;
68 
69  parse_params(params, scan, manager);
70  node->fillin(scan, manager);
71 
72  return node;
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: ModelRoot::fillin
77 // Access: Protected
78 // Description: This internal function is called by make_from_bam to
79 // read in all of the relevant data from the BamFile for
80 // the new ModelRoot.
81 ////////////////////////////////////////////////////////////////////
82 void ModelRoot::
83 fillin(DatagramIterator &scan, BamReader *manager) {
84  ModelNode::fillin(scan, manager);
85 }
A node of this type is created automatically at the root of each model file that is loaded...
Definition: modelRoot.h:31
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
static void register_with_read_factory()
Tells the BamReader how to create objects of type ModelRoot.
Definition: modelRoot.cxx:40
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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:218
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: modelRoot.cxx:29
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
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:51
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:90
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:213
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:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43