|
|
@@ -665,6 +665,33 @@ get_hpr(float roll) const {
|
|
|
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
|
|
|
// Access: Published
|
|
|
@@ -767,6 +794,20 @@ set_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr,
|
|
|
(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
|
|
|
// Access: Published
|
|
|
@@ -1035,6 +1076,54 @@ get_hpr(const NodePath &other, float roll) const {
|
|
|
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
|
|
|
// Access: Published
|
|
|
@@ -1181,6 +1270,22 @@ set_pos_hpr_scale(const NodePath &other,
|
|
|
(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
|
|
|
// Access: Published
|