mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 04:33:04 -04:00
add get_quat(), set_quat()
This commit is contained in:
parent
6c2e2ac2e1
commit
adad34118e
@ -665,6 +665,33 @@ get_hpr(float roll) const {
|
|||||||
return get_hpr();
|
return get_hpr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::set_quat
|
||||||
|
// Access: Published
|
||||||
|
// Description: Sets the rotation component of the transform,
|
||||||
|
// leaving translation and scale untouched.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePath::
|
||||||
|
set_quat(const LQuaternionf &quat) {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
CPT(TransformState) transform = get_transform();
|
||||||
|
nassertv(transform->has_quat());
|
||||||
|
set_transform(transform->set_quat(quat));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::get_quat
|
||||||
|
// Access: Published
|
||||||
|
// Description: Retrieves the rotation component of the transform.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
LQuaternionf NodePath::
|
||||||
|
get_quat() const {
|
||||||
|
nassertr_always(!is_empty(), LQuaternionf::ident_quat());
|
||||||
|
CPT(TransformState) transform = get_transform();
|
||||||
|
nassertr(transform->has_quat(), LQuaternionf::ident_quat());
|
||||||
|
return transform->get_quat();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::set_scale
|
// Function: NodePath::set_scale
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -767,6 +794,20 @@ set_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr,
|
|||||||
(pos, hpr, scale));
|
(pos, hpr, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::set_pos_quat_scale
|
||||||
|
// Access: Published
|
||||||
|
// Description: Completely replaces the transform with new
|
||||||
|
// translation, rotation, and scale components.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePath::
|
||||||
|
set_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat,
|
||||||
|
const LVecBase3f &scale) {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
set_transform(TransformState::make_pos_quat_scale
|
||||||
|
(pos, quat, scale));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::set_mat
|
// Function: NodePath::set_mat
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -1035,6 +1076,54 @@ get_hpr(const NodePath &other, float roll) const {
|
|||||||
return hpr;
|
return hpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::set_quat
|
||||||
|
// Access: Published
|
||||||
|
// Description: Sets the rotation component of the transform,
|
||||||
|
// relative to the other node.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePath::
|
||||||
|
set_quat(const NodePath &other, const LQuaternionf &quat) {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
CPT(TransformState) rel_transform = get_transform(other);
|
||||||
|
nassertv(rel_transform->has_quat());
|
||||||
|
|
||||||
|
CPT(TransformState) orig_transform = get_transform();
|
||||||
|
if (orig_transform->has_components()) {
|
||||||
|
// If we had a componentwise transform before we started, we
|
||||||
|
// should be careful to preserve the other two components. We
|
||||||
|
// wouldn't need to do this, except for the possibility of
|
||||||
|
// numerical error or decompose ambiguity.
|
||||||
|
const LVecBase3f &orig_pos = orig_transform->get_pos();
|
||||||
|
const LVecBase3f &orig_scale = orig_transform->get_scale();
|
||||||
|
|
||||||
|
set_transform(other, rel_transform->set_quat(quat));
|
||||||
|
const TransformState *new_transform = get_transform();
|
||||||
|
if (new_transform->has_components()) {
|
||||||
|
set_pos_quat_scale(orig_pos, new_transform->get_quat(), orig_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// If we didn't have a componentwise transform already, never
|
||||||
|
// mind.
|
||||||
|
set_transform(other, rel_transform->set_quat(quat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::get_quat
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the relative orientation of the bottom node
|
||||||
|
// as seen from the other node.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
LQuaternionf NodePath::
|
||||||
|
get_quat(const NodePath &other) const {
|
||||||
|
nassertr_always(!is_empty(), LQuaternionf::ident_quat());
|
||||||
|
CPT(TransformState) transform = get_transform(other);
|
||||||
|
nassertr(transform->has_quat(), LQuaternionf::ident_quat());
|
||||||
|
return transform->get_quat();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::set_scale
|
// Function: NodePath::set_scale
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -1181,6 +1270,22 @@ set_pos_hpr_scale(const NodePath &other,
|
|||||||
(pos, hpr, scale));
|
(pos, hpr, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::set_pos_quat_scale
|
||||||
|
// Access: Published
|
||||||
|
// Description: Completely replaces the transform with new
|
||||||
|
// translation, rotation, and scale components, relative
|
||||||
|
// to the other node.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePath::
|
||||||
|
set_pos_quat_scale(const NodePath &other,
|
||||||
|
const LVecBase3f &pos, const LQuaternionf &quat,
|
||||||
|
const LVecBase3f &scale) {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
set_transform(other, TransformState::make_pos_quat_scale
|
||||||
|
(pos, quat, scale));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::get_mat
|
// Function: NodePath::get_mat
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -254,6 +254,9 @@ PUBLISHED:
|
|||||||
INLINE float get_p() const;
|
INLINE float get_p() const;
|
||||||
INLINE float get_r() const;
|
INLINE float get_r() const;
|
||||||
|
|
||||||
|
void set_quat(const LQuaternionf &quat);
|
||||||
|
LQuaternionf get_quat() const;
|
||||||
|
|
||||||
INLINE void set_scale(float scale);
|
INLINE void set_scale(float scale);
|
||||||
INLINE void set_scale(float sx, float sy, float sz);
|
INLINE void set_scale(float sx, float sy, float sz);
|
||||||
void set_scale(const LVecBase3f &scale);
|
void set_scale(const LVecBase3f &scale);
|
||||||
@ -271,15 +274,18 @@ PUBLISHED:
|
|||||||
const LVecBase3f &hpr);
|
const LVecBase3f &hpr);
|
||||||
|
|
||||||
INLINE void set_hpr_scale(float h, float p, float r,
|
INLINE void set_hpr_scale(float h, float p, float r,
|
||||||
float sx, float sy, float sz);
|
float sx, float sy, float sz);
|
||||||
void set_hpr_scale(const LVecBase3f &hpr,
|
void set_hpr_scale(const LVecBase3f &hpr,
|
||||||
const LVecBase3f &scale);
|
const LVecBase3f &scale);
|
||||||
INLINE void set_pos_hpr_scale(float x, float y, float z,
|
INLINE void set_pos_hpr_scale(float x, float y, float z,
|
||||||
float h, float p, float r,
|
float h, float p, float r,
|
||||||
float sx, float sy, float sz);
|
float sx, float sy, float sz);
|
||||||
void set_pos_hpr_scale(const LVecBase3f &pos,
|
void set_pos_hpr_scale(const LVecBase3f &pos,
|
||||||
const LVecBase3f &hpr,
|
const LVecBase3f &hpr,
|
||||||
const LVecBase3f &scale);
|
const LVecBase3f &scale);
|
||||||
|
void set_pos_quat_scale(const LVecBase3f &pos,
|
||||||
|
const LQuaternionf &quat,
|
||||||
|
const LVecBase3f &scale);
|
||||||
|
|
||||||
void set_mat(const LMatrix4f &mat);
|
void set_mat(const LMatrix4f &mat);
|
||||||
INLINE void clear_mat();
|
INLINE void clear_mat();
|
||||||
@ -330,6 +336,9 @@ PUBLISHED:
|
|||||||
INLINE float get_p(const NodePath &other) const;
|
INLINE float get_p(const NodePath &other) const;
|
||||||
INLINE float get_r(const NodePath &other) const;
|
INLINE float get_r(const NodePath &other) const;
|
||||||
|
|
||||||
|
void set_quat(const NodePath &other, const LQuaternionf &quat);
|
||||||
|
LQuaternionf get_quat(const NodePath &other) const;
|
||||||
|
|
||||||
INLINE void set_scale(const NodePath &other, float sx, float sy, float sz);
|
INLINE void set_scale(const NodePath &other, float sx, float sy, float sz);
|
||||||
void set_scale(const NodePath &other, const LVecBase3f &scale);
|
void set_scale(const NodePath &other, const LVecBase3f &scale);
|
||||||
void set_sx(const NodePath &other, float sx);
|
void set_sx(const NodePath &other, float sx);
|
||||||
@ -360,6 +369,10 @@ PUBLISHED:
|
|||||||
const LVecBase3f &pos,
|
const LVecBase3f &pos,
|
||||||
const LVecBase3f &hpr,
|
const LVecBase3f &hpr,
|
||||||
const LVecBase3f &scale);
|
const LVecBase3f &scale);
|
||||||
|
void set_pos_quat_scale(const NodePath &other,
|
||||||
|
const LVecBase3f &pos,
|
||||||
|
const LQuaternionf &quat,
|
||||||
|
const LVecBase3f &scale);
|
||||||
|
|
||||||
const LMatrix4f &get_mat(const NodePath &other) const;
|
const LMatrix4f &get_mat(const NodePath &other) const;
|
||||||
void set_mat(const NodePath &other, const LMatrix4f &mat);
|
void set_mat(const NodePath &other, const LMatrix4f &mat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user