1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
4 #include "CameraProxy.h"
5 #include <CryNetwork/ISerialize.h>
7 CRYREGISTER_CLASS(CEntityComponentCamera
);
9 //////////////////////////////////////////////////////////////////////////
10 CEntityComponentCamera::CEntityComponentCamera()
12 m_componentFlags
.Add(EEntityComponentFlags::Legacy
);
13 m_componentFlags
.Add(EEntityComponentFlags::NoSave
);
16 //////////////////////////////////////////////////////////////////////////
17 void CEntityComponentCamera::Initialize()
19 UpdateMaterialCamera();
22 //////////////////////////////////////////////////////////////////////////
23 void CEntityComponentCamera::ProcessEvent(const SEntityEvent
& event
)
27 case ENTITY_EVENT_INIT
:
28 case ENTITY_EVENT_XFORM
:
30 UpdateMaterialCamera();
36 //////////////////////////////////////////////////////////////////////////
37 uint64
CEntityComponentCamera::GetEventMask() const
39 return BIT64(ENTITY_EVENT_XFORM
) | BIT64(ENTITY_EVENT_INIT
);
42 //////////////////////////////////////////////////////////////////////////
43 void CEntityComponentCamera::UpdateMaterialCamera()
45 float fov
= m_camera
.GetFov();
46 m_camera
= GetISystem()->GetViewCamera();
47 Matrix34 wtm
= m_pEntity
->GetWorldTM();
48 wtm
.OrthonormalizeFast();
49 m_camera
.SetMatrix(wtm
);
50 m_camera
.SetFrustum(m_camera
.GetViewSurfaceX(), m_camera
.GetViewSurfaceZ(), fov
, m_camera
.GetNearPlane(), m_camera
.GetFarPlane(), m_camera
.GetPixelAspectRatio());
52 IMaterial
* pMaterial
= m_pEntity
->GetMaterial();
54 pMaterial
->SetCamera(m_camera
);
57 //////////////////////////////////////////////////////////////////////////
58 void CEntityComponentCamera::SetCamera(CCamera
& cam
)
61 UpdateMaterialCamera();
64 //////////////////////////////////////////////////////////////////////////
65 void CEntityComponentCamera::GameSerialize(TSerialize ser
)