SlideAlongAxisBasedOnAngle.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "StartingPointCamera/StartingPointCameraConstants.h"
  10. #include <AzCore/Math/Transform.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzCore/RTTI/ReflectContext.h>
  13. #include <CameraFramework/ICameraLookAtBehavior.h>
  14. namespace Camera
  15. {
  16. //////////////////////////////////////////////////////////////////////////
  17. /// This will slide the look at target along a desired axis based on a
  18. /// particular Euler angle. As an example setting this up with ForwardBackward
  19. /// and Pitch, the more the target pitches the further forward it will slide.
  20. /// This will have the behavior that when looking down you will be looking
  21. /// down ahead of the target instead of directly at the top. A similar result
  22. /// will occur when looking up. This could also be used for peeking around
  23. /// corners. This is primarily useful for third person cameras.
  24. //////////////////////////////////////////////////////////////////////////
  25. class SlideAlongAxisBasedOnAngle
  26. : public ICameraLookAtBehavior
  27. {
  28. public:
  29. ~SlideAlongAxisBasedOnAngle() override = default;
  30. AZ_RTTI(SlideAlongAxisBasedOnAngle, "{8DDA8D0B-5BC3-437E-894B-5144E6E81236}", ICameraLookAtBehavior);
  31. AZ_CLASS_ALLOCATOR(SlideAlongAxisBasedOnAngle, AZ::SystemAllocator);
  32. static void Reflect(AZ::ReflectContext* reflection);
  33. //////////////////////////////////////////////////////////////////////////
  34. // ICameraLookAtBehavior
  35. void AdjustLookAtTarget(float deltaTime, const AZ::Transform& targetTransform, AZ::Transform& outLookAtTargetTransform) override;
  36. void Activate(AZ::EntityId) override {}
  37. void Deactivate() override {}
  38. bool XAndYIgnored() const;
  39. bool XAndZIgnored() const;
  40. bool YAndZIgnored() const;
  41. private:
  42. //////////////////////////////////////////////////////////////////////////
  43. // Reflected data
  44. RelativeAxisType m_axisToSlideAlong = ForwardBackward;
  45. EulerAngleType m_angleTypeToChangeFor = Pitch;
  46. float m_maximumPositiveSlideDistance = 0.0f;
  47. float m_maximumNegativeSlideDistance = 0.0f;
  48. bool m_ignoreX = false;
  49. bool m_ignoreY = false;
  50. bool m_ignoreZ = false;
  51. };
  52. } // namespace Camera