!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / CryEngine / CrySchematyc2 / BaseEnv / Components / BaseEnv_EntityTransformComponentBase.cpp
blob0f4278e3e81cd2cbe7034a878b40ec2db24556fd
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
4 #include "BaseEnv/Components/BaseEnv_EntityTransformComponentBase.h"
6 namespace SchematycBaseEnv
8 const int g_emptySlot = -1;
10 const Schematyc2::SGUID g_tranformAttachmentGUID("64020f3e-1cd3-41e9-8bbb-92563378d111");
12 CEntityTransformComponentBase::CEntityTransformComponentBase()
13 : m_pParent(nullptr)
14 , m_slot(g_emptySlot)
17 bool CEntityTransformComponentBase::Init(const Schematyc2::SComponentParams& params)
19 if(!CEntityComponentBase::Init(params))
21 return false;
24 m_pParent = static_cast<CEntityTransformComponentBase*>(params.pParent);
25 return true;
28 void CEntityTransformComponentBase::Shutdown()
30 FreeSlot();
33 void CEntityTransformComponentBase::SetSlot(int slot, const STransform& transform)
35 m_slot = slot;
37 if(m_pParent)
39 CEntityComponentBase::GetEntity().SetParentSlot(m_pParent->GetSlot(), slot);
42 Matrix34 slotTM = Matrix34::CreateRotationXYZ(transform.rot);
43 Matrix33 matScale;
44 matScale.SetScale(transform.scale);
46 slotTM = slotTM * matScale;
47 slotTM.SetTranslation(transform.pos);
49 CEntityComponentBase::GetEntity().SetSlotLocalTM(slot, slotTM);
52 int CEntityTransformComponentBase::GetSlot() const
54 return m_slot;
57 bool CEntityTransformComponentBase::SlotIsValid() const
59 return m_slot != g_emptySlot;
62 void CEntityTransformComponentBase::FreeSlot()
64 if(m_slot != g_emptySlot)
66 CEntityComponentBase::GetEntity().FreeSlot(m_slot);
67 m_slot = g_emptySlot;
71 Matrix34 CEntityTransformComponentBase::GetWorldTM() const
73 return CEntityComponentBase::GetEntity().GetSlotWorldTM(m_slot);