42 LVecBase3 pos, hpr, scale, shear;
43 decompose_matrix(_default_value, pos, hpr, scale, shear);
56 if (_forced_channel !=
nullptr) {
58 channel->get_value(0, _value);
64 if (cdata->_blend.empty()) {
66 if (restore_initial_pose) {
67 _value = _default_value;
70 }
else if (_effective_control !=
nullptr &&
71 !cdata->_frame_blend_flag) {
74 channel->get_value(_effective_control->get_frame(), _value);
80 switch (cdata->_blend_type) {
81 case PartBundle::BT_linear:
84 LMatrix4 net_value = LMatrix4::zeros_mat();
85 PN_stdfloat net_effect = 0.0f;
87 PartBundle::ChannelBlend::const_iterator cbi;
88 for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) {
90 PN_stdfloat effect = (*cbi).second;
91 nassertv(effect != 0.0f);
94 nassertv(channel_index >= 0 && channel_index < (
int)_channels.size());
96 if (channel !=
nullptr) {
98 channel->get_value(control->
get_frame(), v);
100 if (!cdata->_frame_blend_flag) {
102 net_value += v * effect;
105 PN_stdfloat frac = (PN_stdfloat)control->
get_frac();
106 net_value += v * (effect * (1.0f - frac));
109 net_value += v * (effect * frac);
111 net_effect += effect;
115 if (net_effect == 0.0f) {
116 if (restore_initial_pose) {
117 _value = _default_value;
120 _value = net_value / net_effect;
125 case PartBundle::BT_normalized_linear:
132 LMatrix4 net_value = LMatrix4::zeros_mat();
133 LVecBase3 scale(0.0f, 0.0f, 0.0f);
134 LVecBase3 shear(0.0f, 0.0f, 0.0f);
135 PN_stdfloat net_effect = 0.0f;
137 PartBundle::ChannelBlend::const_iterator cbi;
138 for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) {
140 PN_stdfloat effect = (*cbi).second;
141 nassertv(effect != 0.0f);
145 if (channel_index >= 0 && channel_index < (
int)_channels.size()) {
146 channel = DCAST(
ChannelType, _channels[channel_index]);
148 if (channel !=
nullptr) {
151 LVecBase3 iscale, ishear;
156 if (!cdata->_frame_blend_flag) {
158 net_value += v * effect;
159 scale += iscale * effect;
160 shear += ishear * effect;
163 PN_stdfloat frac = (PN_stdfloat)control->
get_frac();
164 PN_stdfloat e0 = effect * (1.0f - frac);
166 scale += iscale * e0;
167 shear += ishear * e0;
173 PN_stdfloat e1 = effect * frac;
175 scale += iscale * e1;
176 shear += ishear * e1;
178 net_effect += effect;
182 if (net_effect == 0.0f) {
183 if (restore_initial_pose) {
184 _value = _default_value;
188 net_value /= net_effect;
194 LVector3 false_scale, false_shear, hpr, translate;
195 decompose_matrix(net_value, false_scale, false_shear, hpr, translate);
196 compose_matrix(_value, scale, shear, hpr, translate);
201 case PartBundle::BT_componentwise:
204 LVecBase3 scale(0.0f, 0.0f, 0.0f);
205 LVecBase3 hpr(0.0f, 0.0f, 0.0f);
206 LVecBase3 pos(0.0f, 0.0f, 0.0f);
207 LVecBase3 shear(0.0f, 0.0f, 0.0f);
208 PN_stdfloat net_effect = 0.0f;
210 PartBundle::ChannelBlend::const_iterator cbi;
211 for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) {
213 PN_stdfloat effect = (*cbi).second;
214 nassertv(effect != 0.0f);
218 if (channel_index >= 0 && channel_index < (
int)_channels.size()) {
219 channel = DCAST(
ChannelType, _channels[channel_index]);
221 if (channel !=
nullptr) {
223 LVecBase3 iscale, ihpr, ipos, ishear;
229 if (!cdata->_frame_blend_flag) {
231 scale += iscale * effect;
232 hpr += ihpr * effect;
233 pos += ipos * effect;
234 shear += ishear * effect;
237 PN_stdfloat frac = (PN_stdfloat)control->
get_frac();
238 PN_stdfloat e0 = effect * (1.0f - frac);
240 scale += iscale * e0;
243 shear += ishear * e0;
247 channel->
get_hpr(next_frame, ihpr);
248 channel->
get_pos(next_frame, ipos);
250 PN_stdfloat e1 = effect * frac;
252 scale += iscale * e1;
255 shear += ishear * e1;
257 net_effect += effect;
261 if (net_effect == 0.0f) {
262 if (restore_initial_pose) {
263 _value = _default_value;
272 compose_matrix(_value, scale, shear, hpr, pos);
277 case PartBundle::BT_componentwise_quat:
280 LVecBase3 scale(0.0f, 0.0f, 0.0f);
281 LQuaternion quat(0.0f, 0.0f, 0.0f, 0.0f);
282 LVecBase3 pos(0.0f, 0.0f, 0.0f);
283 LVecBase3 shear(0.0f, 0.0f, 0.0f);
284 PN_stdfloat net_effect = 0.0f;
286 PartBundle::ChannelBlend::const_iterator cbi;
287 for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) {
289 PN_stdfloat effect = (*cbi).second;
290 nassertv(effect != 0.0f);
294 if (channel_index >= 0 && channel_index < (
int)_channels.size()) {
295 channel = DCAST(
ChannelType, _channels[channel_index]);
297 if (channel !=
nullptr) {
299 LVecBase3 iscale, ipos, ishear;
306 if (!cdata->_frame_blend_flag) {
308 scale += iscale * effect;
309 quat += iquat * effect;
310 pos += ipos * effect;
311 shear += ishear * effect;
315 PN_stdfloat frac = (PN_stdfloat)control->
get_frac();
316 PN_stdfloat e0 = effect * (1.0f - frac);
318 scale += iscale * e0;
321 shear += ishear * e0;
325 channel->
get_quat(next_frame, iquat);
326 channel->
get_pos(next_frame, ipos);
328 PN_stdfloat e1 = effect * frac;
330 scale += iscale * e1;
333 shear += ishear * e1;
335 net_effect += effect;
339 if (net_effect == 0.0f) {
340 if (restore_initial_pose) {
341 _value = _default_value;
353 _value = LMatrix4::scale_shear_mat(scale, shear) * quat;
354 _value.set_row(3, pos);
383 _forced_channel = chan;
397 me->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Parent class for all animation channels.
An animation channel that accepts a matrix each frame from some dynamic input provided by code.
set_value_node
Specifies a node whose transform will be queried each frame to implicitly specify the transform of th...
A specialization on AnimChannel to add all the special matrix component operations.
virtual void get_scale(int frame, LVecBase3 &scale)
Returns the x, y, and z scale components associated with the current frame.
virtual void get_hpr(int frame, LVecBase3 &hpr)
Returns the h, p, and r components associated with the current frame.
virtual void get_quat(int frame, LQuaternion &quat)
Returns the rotation component associated with the current frame, expressed as a quaternion.
virtual void get_pos(int frame, LVecBase3 &pos)
Returns the x, y, and z translation components associated with the current frame.
virtual void get_value_no_scale_shear(int frame, ValueType &value)
Returns the value associated with the current frame, with no scale or share components.
virtual void get_shear(int frame, LVecBase3 &shear)
Returns the a, b, and c shear components associated with the current frame.
Controls the timing of a character animation.
int get_channel_index() const
Returns the particular channel index associated with this AnimControl.
get_frame
Returns the current integer frame number.
get_next_frame
Returns the current integer frame number + 1, constrained to the range 0 <= f < get_num_frames().
get_frac
Returns the fractional part of the current frame.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A class to retrieve the individual data elements previously stored in a Datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
This is a particular kind of MovingPart that accepts a matrix each frame.
virtual void get_blend_value(const PartBundle *root)
Attempts to blend the various matrix values indicated, and sets the _value member to the resulting ma...
static TypedWritable * make_MovingPartMatrix(const FactoryParams ¶ms)
Factory method to generate a MovingPartMatrix object.
virtual AnimChannelBase * make_default_channel() const
Creates and returns a new AnimChannel that is not part of any hierarchy, but that returns the default...
virtual bool apply_control(PandaNode *node)
Specifies a node to influence this particular joint so that it will always hold the node's transform.
static void register_with_read_factory()
Factory method to generate a MovingPartMatrix object.
virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale)
Freezes this particular joint so that it will always hold the specified transform.
A basic node of the scene graph or data graph.
This is the root of a MovingPart hierarchy.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.