Open 3D Engine AzFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzFramework::TransformComponent Class Reference

Fundamental component that describes the entity in 3D space. More...

#include <TransformComponent.h>

Inherits AZ::Component, AZ::EntityBus::Handler, AZ::TransformBus::Handler, AZ::TransformNotificationBus::Handler, and AZ::TransformHierarchyInformationBus::Handler.

Public Types

using ParentActivationTransformMode = AZ::TransformConfig::ParentActivationTransformMode
 

Public Member Functions

 AZ_COMPONENT (TransformComponent, AZ::TransformComponentTypeId, AZ::TransformInterface)
 
 TransformComponent (const TransformComponent &copy)
 
void BindTransformChangedEventHandler (AZ::TransformChangedEvent::Handler &handler) override
 
void BindParentChangedEventHandler (AZ::ParentChangedEvent::Handler &handler) override
 
void BindChildChangedEventHandler (AZ::ChildChangedEvent::Handler &handler) override
 
void NotifyChildChangedEvent (AZ::ChildChangeType changeType, AZ::EntityId entityId) override
 
const AZ::Transform & GetLocalTM () override
 Returns true if the tm was set to the local transform.
 
const AZ::Transform & GetWorldTM () override
 Returns true if the tm was set to the world transform.
 
void GetLocalAndWorld (AZ::Transform &localTM, AZ::Transform &worldTM) override
 Returns both local and world transforms.
 
AZ::EntityId GetParentId () override
 Returns parent EntityId.
 
AZ::TransformInterface * GetParent () override
 Returns parent interface if available.
 
void SetLocalTM (const AZ::Transform &tm) override
 Sets the local transform and notifies all interested parties.
 
void SetWorldTM (const AZ::Transform &tm) override
 Sets the world transform and notifies all interested parties.
 
void SetParent (AZ::EntityId id) override
 
void SetParentRelative (AZ::EntityId id) override
 

Protected Member Functions

void Activate () override
 
void Deactivate () override
 
bool ReadInConfig (const AZ::ComponentConfig *baseConfig) override
 
bool WriteOutConfig (AZ::ComponentConfig *outBaseConfig) const override
 
void SetWorldTranslation (const AZ::Vector3 &newPosition) override
 
void SetLocalTranslation (const AZ::Vector3 &newPosition) override
 
AZ::Vector3 GetWorldTranslation () override
 
AZ::Vector3 GetLocalTranslation () override
 
void MoveEntity (const AZ::Vector3 &offset) override
 
void SetWorldX (float x) override
 
void SetWorldY (float y) override
 
void SetWorldZ (float z) override
 
float GetWorldX () override
 
float GetWorldY () override
 
float GetWorldZ () override
 
void SetLocalX (float x) override
 
void SetLocalY (float y) override
 
void SetLocalZ (float z) override
 
float GetLocalX () override
 
float GetLocalY () override
 
float GetLocalZ () override
 
void SetWorldRotation (const AZ::Vector3 &eulerAnglesRadian) override
 
void SetWorldRotationQuaternion (const AZ::Quaternion &quaternion) override
 
AZ::Vector3 GetWorldRotation () override
 
AZ::Quaternion GetWorldRotationQuaternion () override
 
void SetLocalRotation (const AZ::Vector3 &eulerAnglesRadian) override
 
void SetLocalRotationQuaternion (const AZ::Quaternion &quaternion) override
 
void RotateAroundLocalX (float eulerAngleRadian) override
 
void RotateAroundLocalY (float eulerAngleRadian) override
 
void RotateAroundLocalZ (float eulerAngleRadian) override
 
AZ::Vector3 GetLocalRotation () override
 
AZ::Quaternion GetLocalRotationQuaternion () override
 
AZ::Vector3 GetLocalScale () override
 
void SetLocalUniformScale (float scale) override
 
float GetLocalUniformScale () override
 
float GetWorldUniformScale () override
 
AZStd::vector< AZ::EntityId > GetChildren () override
 
AZStd::vector< AZ::EntityId > GetAllDescendants () override
 
AZStd::vector< AZ::EntityId > GetEntityAndAllDescendants () override
 
bool IsStaticTransform () override
 
AZ::OnParentChangedBehavior GetOnParentChangedBehavior () override
 
void SetOnParentChangedBehavior (AZ::OnParentChangedBehavior onParentChangedBehavior) override
 
void SetParentImpl (AZ::EntityId parentId, bool isKeepWorldTM)
 
void SetLocalTMImpl (const AZ::Transform &tm)
 
void SetWorldTMImpl (const AZ::Transform &tm)
 
void OnTransformChangedImpl (const AZ::Transform &parentLocalTM, const AZ::Transform &parentWorldTM)
 
void ComputeLocalTM ()
 
void ComputeWorldTM ()
 
bool AreMoveRequestsAllowed () const
 Returns whether external calls are currently allowed to move the transform.
 
void GatherChildren (AZStd::vector< AZ::EntityId > &children) override
 
void OnTransformChanged (const AZ::Transform &parentLocalTM, const AZ::Transform &parentWorldTM) override
 
void OnEntityActivated (const AZ::EntityId &parentEntityId) override
 Called when the parent entity activates.
 
void OnEntityDeactivated (const AZ::EntityId &parentEntityId) override
 Called when the parent entity deactivates.
 

Static Protected Member Functions

static void GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &provided)
 ComponentDescriptor::GetProvidedServices
 
static void Reflect (AZ::ReflectContext *reflection)
 ComponentDescriptor::Reflect
 

Protected Attributes

AZ::TransformChangedEvent m_transformChangedEvent
 Event used to signal when a transform changes.
 
AZ::ParentChangedEvent m_parentChangedEvent
 Event used to signal when a transforms parent changes.
 
AZ::ChildChangedEvent m_childChangedEvent
 Event used to signal when a transform has a child entity added or removed.
 
AZ::Transform m_localTM = AZ::Transform::CreateIdentity()
 Local transform relative to parent transform (same as worldTM if no parent).
 
AZ::Transform m_worldTM = AZ::Transform::CreateIdentity()
 World transform including parent transform (same as localTM if no parent).
 
AZ::EntityId m_parentId
 If valid, this transform is parented to m_parentId.
 
AZ::TransformInterface * m_parentTM = nullptr
 Cached - pointer to parent transform, to avoid extra calls. Valid only when if it's present.
 
AZ::TransformNotificationBus::BusPtr m_notificationBus
 Cached bus pointer to the notification bus.
 
ParentActivationTransformMode m_parentActivationTransformMode = ParentActivationTransformMode::MaintainOriginalRelativeTransform
 
bool m_parentActive = false
 Keeps track of the state of the parent entity.
 
bool m_onNewParentKeepWorldTM = true
 If set, recompute localTM instead of worldTM when parent becomes active.
 
bool m_isStatic = false
 
AZ::OnParentChangedBehavior m_onParentChangedBehavior = AZ::OnParentChangedBehavior::Update
 Behavior for this entity's transform when its parent's transform changes.
 

Friends

class AzToolsFramework::Components::TransformComponent
 

Detailed Description

Fundamental component that describes the entity in 3D space.

Member Function Documentation

◆ OnTransformChanged()

void AzFramework::TransformComponent::OnTransformChanged ( const AZ::Transform &  parentLocalTM,
const AZ::Transform &  parentWorldTM 
)
overrideprotected

Methods implementing parent support.

◆ SetParent()

void AzFramework::TransformComponent::SetParent ( AZ::EntityId  id)
override

Set parent entity and notifies all interested parties. The object localTM will be moved into parent space so we will preserve the same worldTM.

◆ SetParentRelative()

void AzFramework::TransformComponent::SetParentRelative ( AZ::EntityId  id)
override

Set the parent entity and notifies all interested parties. This will use worldTM as a localTM and move the transform relative to the parent.

Member Data Documentation

◆ m_isStatic

bool AzFramework::TransformComponent::m_isStatic = false
protected

If true, the transform is static and doesn't move while entity is active.


The documentation for this class was generated from the following file: