natiny_entity_get_rotation

C
void natiny_entity_get_rotation(NatinyEntity node, uint32_t space, float* rx, float* ry, float* rz);

Writes the orientation of a node, in degrees, into three output parameters.

Parameters

Name Type Description
node NatinyEntity Entity handle
space uint32_t NATINY_SPACE_LOCAL or NATINY_SPACE_WORLD
rx float* Receives rotation around X, in degrees; may be NULL
ry float* Receives rotation around Y, in degrees; may be NULL
rz float* Receives rotation around Z, in degrees; may be NULL

Example

C
float yaw;
natiny_entity_get_rotation(turret, NATINY_SPACE_WORLD, NULL, &yaw, NULL);
natiny_entity_set_rotation(barrel, NATINY_SPACE_WORLD, 0.0f, yaw, 0.0f);

Notes

  • Degrees, the same units natiny_entity_set_rotation and natiny_entity_rotate take.
  • The angles are applied in Y-X-Z order - yaw, then pitch, then roll - which is the order natiny_entity_set_rotation reads them in.
  • NATINY_SPACE_LOCAL returns the stored parent-relative angles, which is exactly what natiny_entity_set_rotation wrote in the same space. NATINY_SPACE_WORLD composes them with every parent's and decomposes the result.
  • A world read answers with one triple naming that orientation, not necessarily the triple that was written: past ±90° of pitch, and at gimbal lock, a different triple describes the same rotation. Compare orientations, not the numbers.
  • A handle that is not a live node writes 0 to every non-NULL output.