mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
applyFreezeMatrix
This commit is contained in:
parent
02352ab5e6
commit
4e931c0922
@ -28,7 +28,9 @@ TypeHandle AnimChannelMatrixFixed::_type_handle;
|
||||
AnimChannelMatrixFixed::
|
||||
AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) :
|
||||
AnimChannel<ACMatrixSwitchType>(parent, copy),
|
||||
_transform(copy._transform)
|
||||
_pos(copy._pos),
|
||||
_hpr(copy._hpr),
|
||||
_scale(copy._scale)
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,9 +40,9 @@ AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) :
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AnimChannelMatrixFixed::
|
||||
AnimChannelMatrixFixed(const string &name, const TransformState *transform) :
|
||||
AnimChannelMatrixFixed(const string &name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) :
|
||||
AnimChannel<ACMatrixSwitchType>(name),
|
||||
_transform(transform)
|
||||
_pos(pos), _hpr(hpr), _scale(scale)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ has_changed(int, double, int, double) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_value(int, LMatrix4f &value) {
|
||||
value = _transform->get_mat();
|
||||
compose_matrix(value, _scale, LVecBase3f::zero(), _hpr, _pos);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -72,13 +74,9 @@ get_value(int, LMatrix4f &value) {
|
||||
// without any scale or shear information.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_value_no_scale_shear(int frame, LMatrix4f &mat) {
|
||||
if (_transform->has_scale() || _transform->has_shear()) {
|
||||
compose_matrix(mat, LVecBase3f(1.0f, 1.0f, 1.0f),
|
||||
_transform->get_hpr(), _transform->get_pos());
|
||||
} else {
|
||||
mat = _transform->get_mat();
|
||||
}
|
||||
get_value_no_scale_shear(int, LMatrix4f &mat) {
|
||||
compose_matrix(mat, LVecBase3f(1.0f, 1.0f, 1.0f), LVecBase3f::zero(),
|
||||
_hpr, _pos);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -88,7 +86,7 @@ get_value_no_scale_shear(int frame, LMatrix4f &mat) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_scale(int, LVecBase3f &scale) {
|
||||
scale = _transform->get_scale();
|
||||
scale = _scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -100,7 +98,7 @@ get_scale(int, LVecBase3f &scale) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_hpr(int, LVecBase3f &hpr) {
|
||||
hpr = _transform->get_hpr();
|
||||
hpr = _hpr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -112,7 +110,7 @@ get_hpr(int, LVecBase3f &hpr) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_quat(int, LQuaternionf &quat) {
|
||||
quat = _transform->get_quat();
|
||||
quat.set_hpr(_hpr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -124,7 +122,7 @@ get_quat(int, LQuaternionf &quat) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_pos(int, LVecBase3f &pos) {
|
||||
pos = _transform->get_pos();
|
||||
pos = _pos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -136,7 +134,7 @@ get_pos(int, LVecBase3f &pos) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AnimChannelMatrixFixed::
|
||||
get_shear(int, LVecBase3f &shear) {
|
||||
shear = _transform->get_shear();
|
||||
shear = LVecBase3f::zero();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -147,5 +145,5 @@ get_shear(int, LVecBase3f &shear) {
|
||||
void AnimChannelMatrixFixed::
|
||||
output(ostream &out) const {
|
||||
AnimChannel<ACMatrixSwitchType>::output(out);
|
||||
out << " = " << *_transform;
|
||||
out << ": pos " << _pos << " hpr " << _hpr << " scale " << _scale;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ protected:
|
||||
AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©);
|
||||
|
||||
public:
|
||||
AnimChannelMatrixFixed(const string &name, const TransformState *transform);
|
||||
AnimChannelMatrixFixed(const string &name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale);
|
||||
|
||||
virtual bool has_changed(int last_frame, double last_frac,
|
||||
int this_frame, double this_frac);
|
||||
@ -47,7 +47,7 @@ public:
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
private:
|
||||
CPT(TransformState) _transform;
|
||||
LVecBase3f _pos, _hpr, _scale;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
|
@ -48,7 +48,9 @@ MovingPartMatrix::
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AnimChannelBase *MovingPartMatrix::
|
||||
make_initial_channel() const {
|
||||
return new AnimChannelMatrixFixed(get_name(), TransformState::make_mat(_initial_value));
|
||||
LVecBase3f pos, hpr, scale, shear;
|
||||
decompose_matrix(_initial_value, pos, hpr, scale, shear);
|
||||
return new AnimChannelMatrixFixed(get_name(), pos, hpr, scale);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -373,7 +375,7 @@ get_blend_value(const PartBundle *root) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MovingPartMatrix::apply_freeze
|
||||
// Function: MovingPartMatrix::apply_freeze_matrix
|
||||
// Access: Public, Virtual
|
||||
// Description: Freezes this particular joint so that it will always
|
||||
// hold the specified transform. Returns true if this
|
||||
@ -382,8 +384,8 @@ get_blend_value(const PartBundle *root) {
|
||||
// PartBundle::freeze_joint().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool MovingPartMatrix::
|
||||
apply_freeze(const TransformState *transform) {
|
||||
_forced_channel = new AnimChannelMatrixFixed(get_name(), transform);
|
||||
apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) {
|
||||
_forced_channel = new AnimChannelMatrixFixed(get_name(), pos, hpr, scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
virtual AnimChannelBase *make_initial_channel() const;
|
||||
virtual void get_blend_value(const PartBundle *root);
|
||||
|
||||
virtual bool apply_freeze(const TransformState *transform);
|
||||
virtual bool apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale);
|
||||
virtual bool apply_control(PandaNode *node);
|
||||
|
||||
protected:
|
||||
|
@ -115,7 +115,7 @@ get_blend_value(const PartBundle *root) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MovingPartScalar::apply_freeze
|
||||
// Function: MovingPartScalar::apply_freeze_scalar
|
||||
// Access: Public, Virtual
|
||||
// Description: Freezes this particular joint so that it will always
|
||||
// hold the specified transform. Returns true if this
|
||||
@ -124,8 +124,8 @@ get_blend_value(const PartBundle *root) {
|
||||
// PartBundle::freeze_joint().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool MovingPartScalar::
|
||||
apply_freeze(const TransformState *transform) {
|
||||
_forced_channel = new AnimChannelFixed<ACScalarSwitchType>(get_name(), transform->get_pos()[0]);
|
||||
apply_freeze_scalar(float value) {
|
||||
_forced_channel = new AnimChannelFixed<ACScalarSwitchType>(get_name(), value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
virtual void get_blend_value(const PartBundle *root);
|
||||
|
||||
virtual bool apply_freeze(const TransformState *transform);
|
||||
virtual bool apply_freeze_scalar(float value);
|
||||
virtual bool apply_control(PandaNode *node);
|
||||
|
||||
protected:
|
||||
|
@ -421,6 +421,58 @@ freeze_joint(const string &joint_name, const TransformState *transform) {
|
||||
return child->apply_freeze(transform);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartBundle::freeze_joint
|
||||
// Access: Published
|
||||
// Description: Specifies that the joint with the indicated name
|
||||
// should be frozen with the specified transform. It
|
||||
// will henceforth always hold this fixed transform,
|
||||
// regardless of any animations that may subsequently be
|
||||
// bound to the joint.
|
||||
//
|
||||
// Returns true if the joint is successfully frozen, or
|
||||
// false if the named child is not a joint (or slider)
|
||||
// or does not exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PartBundle::
|
||||
freeze_joint(const string &joint_name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) {
|
||||
PartGroup *child = find_child(joint_name);
|
||||
if (child == (PartGroup *)NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CDWriter cdata(_cycler, false);
|
||||
cdata->_anim_changed = true;
|
||||
|
||||
return child->apply_freeze_matrix(pos, hpr, scale);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartBundle::freeze_joint
|
||||
// Access: Published
|
||||
// Description: Specifies that the joint with the indicated name
|
||||
// should be frozen with the specified transform. It
|
||||
// will henceforth always hold this fixed transform,
|
||||
// regardless of any animations that may subsequently be
|
||||
// bound to the joint.
|
||||
//
|
||||
// Returns true if the joint is successfully frozen, or
|
||||
// false if the named child is not a joint (or slider)
|
||||
// or does not exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PartBundle::
|
||||
freeze_joint(const string &joint_name, float value) {
|
||||
PartGroup *child = find_child(joint_name);
|
||||
if (child == (PartGroup *)NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CDWriter cdata(_cycler, false);
|
||||
cdata->_anim_changed = true;
|
||||
|
||||
return child->apply_freeze_scalar(value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartBundle::control_joint
|
||||
// Access: Published
|
||||
|
@ -136,6 +136,8 @@ PUBLISHED:
|
||||
void wait_pending();
|
||||
|
||||
bool freeze_joint(const string &joint_name, const TransformState *transform);
|
||||
bool freeze_joint(const string &joint_name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale);
|
||||
bool freeze_joint(const string &joint_name, float value);
|
||||
bool control_joint(const string &joint_name, PandaNode *node);
|
||||
bool release_joint(const string &joint_name);
|
||||
|
||||
|
@ -148,7 +148,7 @@ find_child(const string &name) const {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartGroup::apply_freeze
|
||||
// Access: Published, Virtual
|
||||
// Access: Published
|
||||
// Description: Freezes this particular joint so that it will always
|
||||
// hold the specified transform. Returns true if this
|
||||
// is a joint that can be so frozen, false otherwise.
|
||||
@ -159,9 +159,42 @@ find_child(const string &name) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PartGroup::
|
||||
apply_freeze(const TransformState *transform) {
|
||||
return apply_freeze_matrix(transform->get_pos(), transform->get_hpr(), transform->get_scale()) || apply_freeze_scalar(transform->get_pos()[0]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartGroup::apply_freeze_matrix
|
||||
// Access: Published, Virtual
|
||||
// Description: Freezes this particular joint so that it will always
|
||||
// hold the specified transform. Returns true if this
|
||||
// is a joint that can be so frozen, false otherwise.
|
||||
//
|
||||
// This is normally only called internally by
|
||||
// PartBundle::freeze_joint(), but you may also call it
|
||||
// directly.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PartGroup::
|
||||
apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartGroup::apply_freeze_scalar
|
||||
// Access: Published, Virtual
|
||||
// Description: Freezes this particular joint so that it will always
|
||||
// hold the specified transform. Returns true if this
|
||||
// is a joint that can be so frozen, false otherwise.
|
||||
//
|
||||
// This is normally only called internally by
|
||||
// PartBundle::freeze_joint(), but you may also call it
|
||||
// directly.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PartGroup::
|
||||
apply_freeze_scalar(float value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PartGroup::apply_control
|
||||
// Access: Published, Virtual
|
||||
|
@ -77,7 +77,9 @@ PUBLISHED:
|
||||
|
||||
PartGroup *find_child(const string &name) const;
|
||||
|
||||
virtual bool apply_freeze(const TransformState *transform);
|
||||
bool apply_freeze(const TransformState *transform);
|
||||
virtual bool apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale);
|
||||
virtual bool apply_freeze_scalar(float value);
|
||||
virtual bool apply_control(PandaNode *node);
|
||||
virtual bool clear_forced_channel();
|
||||
virtual AnimChannelBase *get_forced_channel() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user