121 if (spaceTargetDirection.length() == 0.0f) {
141 Math::Quatf unitZToTarget = Math::Quatf::fromAxes(xVec, yVec, targetDirection);
145 if (localDirectionVector == Math::Vec3f{0.0f, 0.0f, -1.0f}) {
146 targetOrientation =
Math::Quatf(-unitZToTarget.y(), -unitZToTarget.z(), unitZToTarget.w(), unitZToTarget.x());
148 targetOrientation = unitZToTarget *
directionTo(localDirectionVector, Math::Vec3f{0.0f, 0.0f, 1.0f});
154 void Node::lookAt(
const Math::Vec3f& targetPosition,
const Math::Vec3f& localDirectionVector,
const Math::Vec3f& localUpVector,
TransformSpace space) {
158 origin = Math::Vec3f(0.0f);
165 setDirection(targetPosition - origin, localDirectionVector, localUpVector, space);
Quaternion< T > directionTo(const Vector< 3, T > &original, const Vector< 3, T > &expected)
Math::Vec3f _absoluteScale
void attachChild(Node &child)
std::vector< Node * > _children
void scale(const Math::Vec3f &scale)
Matrix< 4, 4, T > translate(const Vector< 3, T > &direction)
void setRotation(float angle, const Math::Vec3f &axis, TransformSpace space=TransformSpace::Local)
void translate(const Math::Vec3f &direction, TransformSpace space=TransformSpace::Local)
const Math::Vec3f & getAbsolutePosition()
constexpr Vector< 3, T > cross(const Vector< 3, T > &lhs, const Vector< 3, T > &rhs)
Math::Vec3f _absolutePosition
void rotate(float angle, const Math::Vec3f &axis, TransformSpace space=TransformSpace::Local)
const Math::Quatf & getAbsoluteRotation()
void setDirection(const Math::Vec3f &spaceTargetDirection, const Math::Vec3f &localDirectionVector, const Math::Vec3f &localUpVector, TransformSpace space=TransformSpace::Local)
Rotates the node according to the direction given in parameter.
Quaternion< T > inverse(const Quaternion< T > &lhs)
Node(const std::string &name)
Node * getNode(const std::string &name)
Quaternion< T > normalize(const Quaternion< T > &lhs)
void setPosition(const Math::Vec3f &position, TransformSpace space=TransformSpace::Local)
const Math::Vec3f & getAbsoluteScale()
void lookAt(const Math::Vec3f &targetPosition, const Math::Vec3f &localDirectionVector, const Math::Vec3f &localUpVector, TransformSpace space=TransformSpace::Local)
Rotates the node in order to look at the target position.
Math::Quatf _absoluteRotation
Matrix< 4, 4, T > scale(const Vector< 3, T > &factors)
virtual void needUpdate()
Quaternion< float > Quatf