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>
21 TypeHandle MovingPart<SwitchType>::_type_handle;
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>
33 INLINE MovingPart<SwitchType>::
34 MovingPart(const MovingPart<SwitchType> &copy) :
35 MovingPartBase(copy),
36 _value(copy._value),
37 _default_value(copy._default_value)
38 {
39 }
40
41 /**
42 *
43 */
44 template<class SwitchType>
45 INLINE MovingPart<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>
58 INLINE MovingPart<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>
68 TypeHandle MovingPart<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>
80 AnimChannelBase *MovingPart<SwitchType>::
81 make_default_channel() const {
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>
89 void MovingPart<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>
99 void MovingPart<SwitchType>::
100 write_datagram(BamWriter *manager, Datagram &me) {
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>
112 void MovingPart<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 }
animChannelFixed.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AnimChannelBase
Parent class for all animation channels.
Definition: animChannelBase.h:30
AnimChannelFixed
This template class is a special kind of AnimChannel that always returns just one fixed value.
Definition: animChannelFixed.h:29
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
MovingPartBase
This is the base class for a single animatable piece that may be bound to one channel (or more,...
Definition: movingPartBase.h:31
MovingPartBase::write_datagram
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: movingPartBase.cxx:344
MovingPart
This is the template instantiation of MovingPartBase, on the particular type of value provided by the...
Definition: movingPart.h:27
MovingPart::output_value
virtual void output_value(std::ostream &out) const
Outputs a very brief description of the channel's current value.
Definition: movingPart.I:90
MovingPart::write_datagram
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
MovingPart::get_value_type
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
Definition: movingPart.I:69
MovingPart::make_default_channel
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
PartGroup
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:43
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
datagramIterator.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagram.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.