forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequenceNode.cxx
More file actions
185 lines (167 loc) · 5.38 KB
/
sequenceNode.cxx
File metadata and controls
185 lines (167 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file sequenceNode.cxx
* @author drose
* @date 2002-03-06
*/
#include "pandabase.h"
#include "sequenceNode.h"
#include "cullTraverser.h"
TypeHandle SequenceNode::_type_handle;
/**
*
*/
SequenceNode::
SequenceNode(const SequenceNode ©) :
SelectiveChildNode(copy),
AnimInterface(copy)
{
}
/**
* Returns the number of frames in the animation. This is a property of the
* animation and may not be directly adjusted by the user (although it may
* change without warning with certain kinds of animations, since this is a
* virtual method that may be overridden).
*/
int SequenceNode::
get_num_frames() const {
return get_num_children();
}
/**
* Returns true if it is generally safe to combine this particular kind of
* PandaNode with other kinds of PandaNodes of compatible type, adding
* children or whatever. For instance, an LODNode should not be combined with
* any other PandaNode, because its set of children is meaningful.
*/
bool SequenceNode::
safe_to_combine() const {
return false;
}
/**
* Returns true if it is generally safe to combine the children of this
* PandaNode with each other. For instance, an LODNode's children should not
* be combined with each other, because the set of children is meaningful.
*/
bool SequenceNode::
safe_to_combine_children() const {
return false;
}
/**
* Returns a newly-allocated Node that is a shallow copy of this one. It will
* be a different Node pointer, but its internal data may or may not be shared
* with that of the original Node.
*/
PandaNode *SequenceNode::
make_copy() const {
return new SequenceNode(*this);
}
/**
* This function will be called during the cull traversal to perform any
* additional operations that should be performed at cull time. This may
* include additional manipulation of render state or additional
* visible/invisible decisions, or any other arbitrary operation.
*
* Note that this function will *not* be called unless set_cull_callback() is
* called in the constructor of the derived class. It is necessary to call
* set_cull_callback() to indicated that we require cull_callback() to be
* called.
*
* By the time this function is called, the node has already passed the
* bounding-volume test for the viewing frustum, and the node's transform and
* state have already been applied to the indicated CullTraverserData object.
*
* The return value is true if this node should be visible, or false if it
* should be culled.
*/
bool SequenceNode::
cull_callback(CullTraverser *, CullTraverserData &) {
select_child(get_frame());
return true;
}
/**
* Returns the index number of the first visible child of this node, or a
* number >= get_num_children() if there are no visible children of this node.
* This is called during the cull traversal, but only if
* has_selective_visibility() has already returned true. See
* has_selective_visibility().
*/
int SequenceNode::
get_first_visible_child() const {
return get_frame();
}
/**
* Should be overridden by derived classes to return true if this kind of node
* has the special property that just one of its children is visible at any
* given time, and furthermore that the particular visible child can be
* determined without reference to any external information (such as a
* camera). At present, only SequenceNodes and SwitchNodes fall into this
* category.
*
* If this function returns true, get_visible_child() can be called to return
* the index of the currently-visible child.
*/
bool SequenceNode::
has_single_child_visibility() const {
return true;
}
/**
* Returns the index number of the currently visible child of this node. This
* is only meaningful if has_single_child_visibility() has returned true.
*/
int SequenceNode::
get_visible_child() const {
return get_frame();
}
/**
*
*/
void SequenceNode::
output(std::ostream &out) const {
out << get_type() << " " << get_name() << ": ";
AnimInterface::output(out);
}
/**
* Tells the BamReader how to create objects of type SequenceNode.
*/
void SequenceNode::
register_with_read_factory() {
BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
}
/**
* Writes the contents of this object to the datagram for shipping out to a
* Bam file.
*/
void SequenceNode::
write_datagram(BamWriter *manager, Datagram &dg) {
SelectiveChildNode::write_datagram(manager, dg);
AnimInterface::write_datagram(manager, dg);
}
/**
* This function is called by the BamReader's factory when a new object of
* type SequenceNode is encountered in the Bam file. It should create the
* SequenceNode and extract its information from the file.
*/
TypedWritable *SequenceNode::
make_from_bam(const FactoryParams ¶ms) {
SequenceNode *node = new SequenceNode("");
DatagramIterator scan;
BamReader *manager;
parse_params(params, scan, manager);
node->fillin(scan, manager);
return node;
}
/**
* This internal function is called by make_from_bam to read in all of the
* relevant data from the BamFile for the new SequenceNode.
*/
void SequenceNode::
fillin(DatagramIterator &scan, BamReader *manager) {
SelectiveChildNode::fillin(scan, manager);
AnimInterface::fillin(scan, manager);
}