Add the ability to look-at in model-space.
This is a much simpler attempt to solve the same problem as #76060, but without breaking any compatibility. * Adds a description of what model space is in the Vector3 enums (MODEL_* constants). This has the proper axes laid out for imported 3D assets. * Adds the option to `look_at` using model_space, which uses Vector3.MODEL_FRONT as forward vector. The attempt of this PR is to still break the assumption that there is a single direction of forward (which is not the case in Godot) and make it easier to understand where 3D models are facing, as well as orienting them via look_at.
This commit is contained in:
parent
d5c1b9f883
commit
5fdc1232ef
11 changed files with 55 additions and 22 deletions
|
|
@ -77,20 +77,20 @@ void Transform3D::rotate_basis(const Vector3 &p_axis, real_t p_angle) {
|
|||
basis.rotate(p_axis, p_angle);
|
||||
}
|
||||
|
||||
Transform3D Transform3D::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
|
||||
Transform3D Transform3D::looking_at(const Vector3 &p_target, const Vector3 &p_up, bool p_use_model_front) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(origin.is_equal_approx(p_target), Transform3D(), "The transform's origin and target can't be equal.");
|
||||
#endif
|
||||
Transform3D t = *this;
|
||||
t.basis = Basis::looking_at(p_target - origin, p_up);
|
||||
t.basis = Basis::looking_at(p_target - origin, p_up, p_use_model_front);
|
||||
return t;
|
||||
}
|
||||
|
||||
void Transform3D::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
|
||||
void Transform3D::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up, bool p_use_model_front) {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_MSG(p_eye.is_equal_approx(p_target), "The eye and target vectors can't be equal.");
|
||||
#endif
|
||||
basis = Basis::looking_at(p_target - p_eye, p_up);
|
||||
basis = Basis::looking_at(p_target - p_eye, p_up, p_use_model_front);
|
||||
origin = p_eye;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue