| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <memory> |
| 4 |
|
| 5 |
enum TransformModifierType |
| 6 |
{ |
| 7 |
TRANSFORM_PRIMITIVE, |
| 8 |
TRANSFORM_COMPONENT, |
| 9 |
}; |
| 10 |
|
| 11 |
// Forward-declare the math objects |
| 12 |
template<typename Element> class BasicVector3; |
| 13 |
typedef BasicVector3<double> Vector3; |
| 14 |
template<typename Element> class BasicVector4; |
| 15 |
typedef BasicVector4<double> Vector4; |
| 16 |
class Quaternion; |
| 17 |
class Matrix4; |
| 18 |
|
| 19 |
/** |
| 20 |
* @brief Interface for a node which can be transformed via GUI operations. |
| 21 |
* |
| 22 |
* This interface is designed for nodes which can be translated, rotated and |
| 23 |
* scaled via manipulators or other mouse operations. A number of incremental |
| 24 |
* transforms can be accumulated, which are then "committed" via |
| 25 |
* freezeTransform() or abandoned via revertTransform(). Typically the |
| 26 |
* uncommitted live transform will affect rendering (so the user can see the |
| 27 |
* effect of the manipulation), but will not be saved into entity spawnargs |
| 28 |
* until the transform is frozen. |
| 29 |
*/ |
| 30 |
class ITransformable |
| 31 |
{ |
| 32 |
public: |
| 33 |
virtual ~ITransformable() {} |
| 34 |
virtual void setType(TransformModifierType type) = 0; |
| 35 |
virtual void setTranslation(const Vector3& value) = 0; |
| 36 |
virtual void setRotation(const Quaternion& value) = 0; |
| 37 |
|
| 38 |
// Rotation around a certain point in world space, which usually results |
| 39 |
// in a local rotation and a translation of the object, unless the pivot conincides |
| 40 |
// with the object's rotation center. The localToWorld matrix should be obtained from the node being transformed |
| 41 |
virtual void setRotation(const Quaternion& value, const Vector3& worldPivot, const Matrix4& localToWorld) = 0; |
| 42 |
|
| 43 |
virtual void setScale(const Vector3& value) = 0; |
| 44 |
virtual void freezeTransform() = 0; |
| 45 |
virtual void revertTransform() = 0; |
| 46 |
|
| 47 |
// For pivoted rotations the code needs to know the object center |
| 48 |
// before the operation started. |
| 49 |
virtual const Vector3& getUntransformedOrigin() = 0; |
| 50 |
}; |
| 51 |
typedef std::shared_ptr<ITransformable> ITransformablePtr; |