An transform tool for translating, rotating, and scaling objects. More...
#include <TransformController.hh>
Public Member Functions | |
TransformController () | |
Constructor. More... | |
virtual | ~TransformController () |
Destructor. More... | |
virtual bool | Active () const |
Check if the transform process is active. More... | |
virtual math::Vector3d | ActiveAxis () const |
Get the current highlighted active axis of transform. More... | |
virtual void | Attach (NodePtr _node) |
Attach the transform controller to the specified node. More... | |
virtual math::Vector3d | AxisById (unsigned int _id) const |
Get the axis of transform represented by the given node id. More... | |
virtual CameraPtr | Camera () const |
get the camera that is controlled by this view controller. More... | |
virtual void | Detach () |
Detach the transform controller from the currently attached node. More... | |
virtual TransformMode | Mode () const |
Get the current transform mode. More... | |
virtual NodePtr | Node () const |
Get the attached node. More... | |
virtual void | Rotate (const math::Quaterniond &_rotation, bool _snap=false) |
Rotate the attached node. More... | |
math::Quaterniond | RotationFrom2d (const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end) |
Helper function to compute 3d rotation from 2d translation movement. Useful for converting 2d mouse drag motion to rotation angle in world frame. Note that the camera must be set and Start() must be called before using this function. More... | |
virtual void | Scale (const math::Vector3d &_scale, bool _snap=false) |
Scale the attached node. More... | |
math::Vector3d | ScaleFrom2d (const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end) |
Helper function to compute 3d scale from 2d translation movement. Useful for converting 2d mouse drag motion to scale vector in world frame. Note that the camera must be set and Start() must be called before using this function. More... | |
virtual void | SetActiveAxis (const math::Vector3d &_axis) |
Set the active transform axis. This highlights the axis visual. More... | |
virtual void | SetCamera (const CameraPtr &_camera) |
Set the camera. More... | |
virtual void | SetTransformMode (TransformMode _mode) |
Set the transform mode. More... | |
virtual void | SetTransformSpace (TransformSpace _space) |
Set the transform space. More... | |
virtual TransformSpace | Space () const |
Get the transform space. More... | |
virtual void | Start () |
Start the transform process. To be used with helper functions that computions transforms from 2d movements. More... | |
virtual void | Stop () |
Stop the transform process. To be used with helper functions that computions transforms from 2d movements. More... | |
virtual void | Translate (const math::Vector3d &_translation, bool _snap=false) |
Translate the attached node. More... | |
math::Vector3d | TranslationFrom2d (const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end) |
Helper function to compute 3d translation from 2d translation movement. Useful for converting 2d mouse drag motion to displacement in world frame. Note that the camera must be set and Start() must be called before using this function. More... | |
virtual void | Update () |
Update the transform controller. Its visual is updated based on the current transform mode, space, and axis. More... | |
Static Public Member Functions | |
static gz::math::Vector3d | SnapPoint (const gz::math::Vector3d &_point, const double _interval=1.0, const double _sensitivity=0.4) |
Snap a point at intervals of a fixed distance. Currently used to give a snapping behavior when transforming objects. More... | |
static math::Vector3d | ToAxis (TransformAxis _axis) |
Convert a TransformAxis to a vector type. More... | |
Public Attributes | |
std::unique_ptr< TransformControllerPrivate > | dataPtr |
Private data pointer. More... | |
Protected Member Functions | |
math::Planed | CreatePlaneForTransform (const math::Vector3d &_axis, const math::Vector2d &_pt2d) |
Helper function to create a plane for transfomation. The plane is chosen based on the current transform mode and the transform axis specified. More... | |
bool | RayPlaneIntersection (RayQueryPtr _ray, const math::Planed &_plane, math::Vector3d &_result) |
Helper function to compute ray plane intersection. More... | |
Detailed Description
An transform tool for translating, rotating, and scaling objects.
Constructor & Destructor Documentation
◆ TransformController()
Constructor.
◆ ~TransformController()
|
virtual |
Destructor.
Member Function Documentation
◆ Active()
|
virtual |
Check if the transform process is active.
- Returns
- True if node is being transformed
◆ ActiveAxis()
|
virtual |
Get the current highlighted active axis of transform.
- Returns
- Active axis of transform
◆ Attach()
|
virtual |
Attach the transform controller to the specified node.
- Parameters
-
[in] _node Node that will be transformed
◆ AxisById()
|
virtual |
Get the axis of transform represented by the given node id.
- Parameters
-
[in] _id Id of the node to check
- Returns
- Transform axis
◆ Camera()
get the camera that is controlled by this view controller.
- Returns
- camera being controlled
◆ CreatePlaneForTransform()
|
protected |
Helper function to create a plane for transfomation. The plane is chosen based on the current transform mode and the transform axis specified.
- Parameters
-
[in] _axis Transformation axis used to identify the plane for projection. [in] _pt2d 2d point to help fine tune the plane created.
- Returns
- Plane created for transform
◆ Detach()
|
virtual |
Detach the transform controller from the currently attached node.
◆ Mode()
|
virtual |
Get the current transform mode.
- Returns
- Transform mode
◆ Node()
Get the attached node.
- Returns
- The node which is being transformed, nullptr if there is no node attached.
◆ RayPlaneIntersection()
|
protected |
Helper function to compute ray plane intersection.
- Parameters
-
[in] _ray Input ray [in] _plane Plane to check for intersection [out] _result Intersection point
- Returns
- True if intersection point exist, false if ray is parallel to plane
◆ Rotate()
|
virtual |
Rotate the attached node.
- Parameters
-
[in] _rotation Rotation in the current transform space [in] _snap True to snap rotation angle to fixed increments
- See also
- SetTransformSpace
◆ RotationFrom2d()
math::Quaterniond RotationFrom2d | ( | const math::Vector3d & | _axis, |
const math::Vector2d & | _start, | ||
const math::Vector2d & | _end | ||
) |
Helper function to compute 3d rotation from 2d translation movement. Useful for converting 2d mouse drag motion to rotation angle in world frame. Note that the camera must be set and Start() must be called before using this function.
- Parameters
-
[in] _axis Axis of 3d rotation. The resulting rotation is is constrained to this axis. [in] _start Starting position of the 2d translation movement [in] _end End position of the 2d translation movement
- Returns
- Rotation in the current transform space
◆ Scale()
|
virtual |
Scale the attached node.
- Parameters
-
[in] _scale Scale in the current transform space [in] _snap True to snap scale to fixed increments
- See also
- SetTransformSpace
◆ ScaleFrom2d()
math::Vector3d ScaleFrom2d | ( | const math::Vector3d & | _axis, |
const math::Vector2d & | _start, | ||
const math::Vector2d & | _end | ||
) |
Helper function to compute 3d scale from 2d translation movement. Useful for converting 2d mouse drag motion to scale vector in world frame. Note that the camera must be set and Start() must be called before using this function.
- Parameters
-
[in] _axis Axis of scale. The resulting 3d vector is constrained to this axis. [in] _start Starting position of the 2d translation movement [in] _end End position of the 2d translation movement
- Returns
- 3d scale vector in the current transform space
◆ SetActiveAxis()
|
virtual |
Set the active transform axis. This highlights the axis visual.
- Parameters
-
[in] _axis Transform axis vector
◆ SetCamera()
|
virtual |
Set the camera.
- Parameters
-
[in] _camera Camera
◆ SetTransformMode()
|
virtual |
Set the transform mode.
- Parameters
-
[in] _mode Transform mode to set to
◆ SetTransformSpace()
|
virtual |
Set the transform space.
- Parameters
-
[in] _space Transform space to set to
◆ SnapPoint()
|
static |
Snap a point at intervals of a fixed distance. Currently used to give a snapping behavior when transforming objects.
- Parameters
-
[in] _point Input point. [in] _interval Fixed distance interval at which the point is snapped. [in] _sensitivity Sensitivity of point snapping, in terms of a percentage of the interval.
- Returns
- Snapped 3D point.
◆ Space()
|
virtual |
Get the transform space.
- Returns
- Transform space
◆ Start()
|
virtual |
Start the transform process. To be used with helper functions that computions transforms from 2d movements.
- See also
- Stop
◆ Stop()
|
virtual |
Stop the transform process. To be used with helper functions that computions transforms from 2d movements.
- See also
- Stop
◆ ToAxis()
|
static |
Convert a TransformAxis to a vector type.
- Parameters
-
[in] _axis Transform axis
- Returns
- 3d axis vector
◆ Translate()
|
virtual |
Translate the attached node.
- Parameters
-
[in] _translation Translation in the current transform space [in] _snap True to snap the final position to fixed increments
- See also
- SetTransformSpace
◆ TranslationFrom2d()
math::Vector3d TranslationFrom2d | ( | const math::Vector3d & | _axis, |
const math::Vector2d & | _start, | ||
const math::Vector2d & | _end | ||
) |
Helper function to compute 3d translation from 2d translation movement. Useful for converting 2d mouse drag motion to displacement in world frame. Note that the camera must be set and Start() must be called before using this function.
- Parameters
-
[in] _axis Axis of 3d translation. The resulting 3d vector is constrained to this axis. [in] _start Starting position of the 2d translation movement [in] _end End position of the 2d translation movement
- Returns
- 3d translation vector in the current transform space
◆ Update()
|
virtual |
Update the transform controller. Its visual is updated based on the current transform mode, space, and axis.
Member Data Documentation
◆ dataPtr
std::unique_ptr<TransformControllerPrivate> dataPtr |
Private data pointer.
The documentation for this class was generated from the following file: