TransformComponent struct in Thread

Spatial state of an entity. Attached automatically by Scene.CreateEntity — never AddComponent manually. Rotation is stored as Euler angles in radians.

Properties

TranslationThread::Vec3Local position in metres, relative to parent (or world if root). Default {0, 0, 0}.
RotationThread::Vec3Euler radians (pitch, yaw, roll). Default {0, 0, 0}.
ScaleThread::Vec3Per-axis scale. Default {1, 1, 1}.

Methods

GetTransform()Thread::Mat4Local matrix T · R · S.
GetWorldTransform(reg, e)Thread::Mat4Walks up the HierarchyComponent chain to produce a world matrix.

Example

auto& tc = GetComponent<Thread::TransformComponent>();
tc.Translation += Thread::Vec3(0.0f, 0.0f, -1.0f) * ts * 5.0f;  // forward 5 m/s
tc.Rotation.y  += ts * Thread::Math::Radians(90.0f);                  // spin 90 deg/s

TransformComponent struct w Thread

Stan przestrzenny encji. Dodawany automatycznie przez Scene.CreateEntity — nigdy nie dodawaj go ręcznie przez AddComponent. Rotacja jest przechowywana jako kąty Eulera w radianach.

Właściwości

TranslationThread::Vec3Lokalna pozycja w metrach, względem rodzica (albo świata, jeśli to korzeń). Domyślnie {0, 0, 0}.
RotationThread::Vec3Euler w radianach (pitch, yaw, roll). Domyślnie {0, 0, 0}.
ScaleThread::Vec3Skala w każdej osi. Domyślnie {1, 1, 1}.

Metody

GetTransform()Thread::Mat4Macierz lokalna T · R · S.
GetWorldTransform(reg, e)Thread::Mat4Idzie w górę łańcucha HierarchyComponent i składa macierz świata.

Przykład

auto& tc = GetComponent<Thread::TransformComponent>();
tc.Translation += Thread::Vec3(0.0f, 0.0f, -1.0f) * ts * 5.0f;  // naprzód 5 m/s
tc.Rotation.y  += ts * Thread::Math::Radians(90.0f);                  // obrót 90°/s