CameraRigComponent.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <AzCore/Math/Transform.h>
  12. namespace Camera
  13. {
  14. class ICameraLookAtBehavior;
  15. class ICameraTargetAcquirer;
  16. class ICameraTransformBehavior;
  17. //////////////////////////////////////////////////////////////////////////
  18. /// The CameraRigComponent holds a recipe of behaviors.
  19. /// It will first attempt to acquire a target by iterating over the LookTargetAquirers until one returns true
  20. /// Next it will pass a modifiable lookAt Transform to all LookAtBehaviors in order, giving each a pass at further modifying the LookAt Transform
  21. /// Finally it will pass a modifiable transform to all Transform behaviors in turn, giving each a chance to further modify the transform
  22. //////////////////////////////////////////////////////////////////////////
  23. class CameraRigComponent
  24. : public AZ::Component
  25. , public AZ::TickBus::Handler
  26. {
  27. public:
  28. AZ_COMPONENT(CameraRigComponent, "{286BF97A-1B4A-4EE1-944F-C13B2396227B}");
  29. ~CameraRigComponent() override;
  30. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  32. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  33. static void Reflect(AZ::ReflectContext* reflection);
  34. //////////////////////////////////////////////////////////////////////////
  35. // AZ::Component
  36. void Init() override;
  37. void Activate() override;
  38. void Deactivate() override;
  39. //////////////////////////////////////////////////////////////////////////
  40. //////////////////////////////////////////////////////////////////////////
  41. // AZ::TickBus::Handler
  42. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  43. //////////////////////////////////////////////////////////////////////////
  44. private:
  45. AZStd::vector<ICameraTargetAcquirer*> m_targetAcquirers;
  46. AZStd::vector<ICameraLookAtBehavior*> m_lookAtBehaviors;
  47. AZStd::vector<ICameraTransformBehavior*> m_transformBehaviors;
  48. AZ::Transform m_initialTransform;
  49. };
  50. } // Camera