8 glm::vec3 axisDirection =
axisDir(axis);
9 glm::vec3 localAxisDirection = target->
getRotationQuat() * axisDirection;
11 float t = glm::dot(-(ray.
origin - initialHitPoint), ray.
dir);
13 glm::vec3 delta = (ray.
origin + ray.
dir * t) - initialHitPoint;
15 float scaleAmount = glm::dot(delta, localAxisDirection);
16 target->
setScale(originalScale + axisDirection * scaleAmount);
20 initialHitPoint = initHitPos;
25 glm::mat4 model(1.0f);
26 model = glm::translate(model, target->
getPosition());
29 model = glm::scale(model, glm::vec3(thickness, length, thickness));
Axis
Cardinal axes for handle orientation.
constexpr glm::vec3 axisDir(Axis a)
Converts an axis enum to its corresponding unit vector.
static glm::mat4 rotateFromYToAxis(Axis axis)
Computes rotation matrix to align mesh from +Y to target axis.
void setDragState(glm::vec3 initHitPos) override
Initializes the drag operation state.
void onDrag(const Math::Ray &ray) override
Handles continuous dragging motion.
ScaleHandle(SceneObject *tgt, Axis ax)
glm::mat4 getModelMatrix() const override
Gets the model transformation matrix for rendering this handle.
void setScale(const glm::vec3 &scl)
glm::vec3 getPosition() const
glm::vec3 getScale() const
glm::quat getRotationQuat() const
glm::vec3 origin
Starting point of the ray in world space.
glm::vec3 dir
Direction vector (should be normalized)
Represents a ray in 3D space.