# 3D Node Transformations

#### <a class="anchor" id="bkmrk--97"></a>3D Node Manipulation Example

To illustrate basic node transformation operations, the *NodeManipulationWidget\_3D* and the *DisplayPositionWidget3D* part of the Tutorial Widgets can be used. An usage example for *NodeManipulationWidget\_3D* widget is presented in **NodeManipulationSolution\_3D** solution provided in the content folder of *cgi\_studio\_player*.

**Please consider:**

<div class="contents" id="bkmrk-the-widget-property-"><div class="contents"><div class="textblock">- The widget property *Node* is derived from a base class and provides the node associated to the widget (e.g. the root node for content managed by the widget).
- Only if the widget is *enabled* (this property is also derived from a base class), the setter methods of the widget properties will take effect.
- If a widget property setter changes a node property of the associated node, the visual effect can be seen, but note that the static node properties maintained by SceneComposer are not changed accordingly!
- Widget dynamics are never reflected to static scene structure. It is recommended to use SceneComposer only for property configuration and dynamics only in the Player.

</div></div></div>#### <a class="anchor" id="bkmrk--98"></a>Translations

Once the NodeManipulationWidget\_3D is linked to a node from the static scene tree and enabled, the position coordinates can be set in the Player for this property to change the position.

```
        // Set node position
        node->SetPosition(m_position);
        // end Set node position
```

Use TranslateX property to move the node on the x axis with a delta value only. [Candera::Transformable::Translate](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a34a94f1d107b2b9e163065ca26682853) adds the given Vector to the actual position .

```
       // Translate node on x axis
        node->Translate(Vector3(m_translateX, 0.0F, 0.0F));
        // end Translate node on x axis
```

#### <a class="anchor" id="bkmrk--99"></a>Rotations

Similar to translation, rotation can also be applied via [Candera::Transformable::SetRotation()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#af76f9a446587115fa5cc19b0b37a64f3) or [Candera::Transformable::Rotate()](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a55429982ad46b745fb37b306475e4b6d).

```
        // Set node rotation
        node->SetRotation(m_rotation);
        // end Set node rotation
```

#### <a class="anchor" id="bkmrk--100"></a>Scaling

Again there is also a [Candera::Transformable::SetScale](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a750dce59a7a54ab4f28dd3763b879dde) and [Candera::Transformable::Scale](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a5eaf72124658e7d27ecce86ad6576029) method.

```
        // set node scale
        node->SetScale(m_scale);
        // end node scale
```

#### <a class="anchor" id="bkmrk--101"></a>Pivot Point

It is possible to change your pivot point with the [Candera::Transformable::TranslatePivotPoint](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a8de05c00892520953c933888152b0e5c) (or [Candera::Transformable::SetPivotPoint](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_transformable.html#a7a885bce1ab6cff4e26882759d1377ae)) method. The pivot point can be used to define e.g. the rotation point that the node should rotate around. It affects the scaling too.

#### <a class="anchor" id="bkmrk--102"></a>How to get the screen space coordinates of a node

With the DisplayPositionWidget3D you can retrieve the screen coordinates of an associated node. Please consider that a node and a camera have to be selected in the widget. In the solution the widget is disabled by default. To see the output of the node's display position, enabling the widget and log filter (via CgiAppLog -&gt; Info) in SceneComposer is mandatory. To get the screen space coordinates of an associated node you need the function [Candera::Math3D::TransformPointToScreen](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_math3_d.html#afb885f2eb69160b3d58ce74afb50d1b3), which transforms a point in world space into a point in screen space.

<div class="contents" id="bkmrk-first-you-need-the-w"><div class="textblock">- First you need the world position of your node. With Node::GetWorldPosition you get the screen coordinates as output. ```
            Vector3 worldPosition = node->GetWorldPosition();
    ```
- With the world position of your node and with your camera you can transform the point to screen space and you retrieve the display position as a [Candera::Vector2](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_vector2.html "The default Vector2 class."). ```
            Vector2 displayPos;
            static_cast<void>(Math3D::TransformPointToScreen(worldPosition, camera, displayPos));
    ```
- displayPos now contains the X and Y screen space coordinates of the selected node.

</div></div>