Panda3D
movingPart.I
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 movingPart.I
10  * @author drose
11  * @date 1999-02-22
12  */
13 
14 #include "animChannelFixed.h"
15 #include "datagram.h"
16 #include "datagramIterator.h"
17 #include "bamReader.h"
18 #include "bamWriter.h"
19 
20 template<class SwitchType>
22 
23 // We don't need to explicitly call MovingPart::init_type(), because it is an
24 // abstract class and therefore must have derived objects. Its derived
25 // objects will call init_type() for us.
26 
27 
28 
29 /**
30  * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this.
31  */
32 template<class SwitchType>
35  MovingPartBase(copy),
36  _value(copy._value),
37  _default_value(copy._default_value)
38 {
39 }
40 
41 /**
42  *
43  */
44 template<class SwitchType>
46 MovingPart(PartGroup *parent, const std::string &name,
47  const ValueType &default_value) :
48  MovingPartBase(parent, name),
49  _value(default_value),
50  _default_value(default_value)
51 {
52 }
53 
54 /**
55  *
56  */
57 template<class SwitchType>
59 MovingPart() {
60 }
61 
62 /**
63  * Returns the TypeHandle associated with the ValueType we are concerned with.
64  * This is provided to allow a bit of run-time checking that joints and
65  * channels are matching properly in type.
66  */
67 template<class SwitchType>
69 get_value_type() const {
70  return get_type_handle(ValueType);
71 }
72 
73 
74 
75 /**
76  * Creates and returns a new AnimChannel that is not part of any hierarchy,
77  * but that returns the default value associated with this part.
78  */
79 template<class SwitchType>
82  return new AnimChannelFixed<SwitchType>(get_name(), _default_value);
83 }
84 
85 /**
86  * Outputs a very brief description of the channel's current value.
87  */
88 template<class SwitchType>
90 output_value(std::ostream &out) const {
91  SwitchType::output_value(out, _value);
92 }
93 
94 /**
95  * Function to write the important information in the particular object to a
96  * Datagram
97  */
98 template<class SwitchType>
101  MovingPartBase::write_datagram(manager, me);
102  SwitchType::write_datagram(me, _value);
103  SwitchType::write_datagram(me, _default_value);
104 }
105 
106 /**
107  * Function that reads out of the datagram (or asks manager to read) all of
108  * the data that is needed to re-create this object and stores it in the
109  * appropiate place
110  */
111 template<class SwitchType>
113 fillin(DatagramIterator &scan, BamReader *manager) {
114  MovingPartBase::fillin(scan, manager);
115  SwitchType::read_datagram(scan, _value);
116  SwitchType::read_datagram(scan, _default_value);
117 }
virtual AnimChannelBase * make_default_channel() const
Creates and returns a new AnimChannel that is not part of any hierarchy, but that returns the default...
Definition: movingPart.I:81
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the template instantiation of MovingPartBase, on the particular type of value provided by the...
Definition: movingPart.h:27
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for a single animatable piece that may be bound to one channel (or more,...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
Definition: movingPart.I:100
virtual void output_value(std::ostream &out) const
Outputs a very brief description of the channel's current value.
Definition: movingPart.I:90
Parent class for all animation channels.
This template class is a special kind of AnimChannel that always returns just one fixed value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
Definition: movingPart.I:69
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:43