@ -9,8 +9,8 @@
# include "SlideAlongAxisBasedOnAngle.h"
# include "SlideAlongAxisBasedOnAngle.h"
# include "StartingPointCamera/StartingPointCameraUtilities.h"
# include "StartingPointCamera/StartingPointCameraUtilities.h"
# include <AzCore/Math/Quaternion.h>
# include <AzCore/Math/Quaternion.h>
# include <AzCore/Serialization/EditContext.h>
# include <AzCore/Math/Transform.h>
# include <AzCore/Math/Transform.h>
# include <AzCore/Serialization/EditContext.h>
namespace Camera
namespace Camera
{
{
@ -32,31 +32,43 @@ namespace Camera
AZ : : EditContext * editContext = serializeContext - > GetEditContext ( ) ;
AZ : : EditContext * editContext = serializeContext - > GetEditContext ( ) ;
if ( editContext )
if ( editContext )
{
{
editContext - > Class < SlideAlongAxisBasedOnAngle > ( " SlideAlongAxisBasedOnAngle " , " Slide 0..SlideDistance along Axis based on Angle Type. Maps from 90..-90 degrees " )
editContext - > Class < SlideAlongAxisBasedOnAngle > ( " SlideAlongAxisBasedOnAngle " ,
- > ClassElement ( AZ : : Edit : : ClassElements : : EditorData , " " )
" Slide 0..SlideDistance along Axis based on Angle Type. Maps from 90..-90 degrees " )
- > DataElement ( AZ : : Edit : : UIHandlers : : ComboBox , & SlideAlongAxisBasedOnAngle : : m_axisToSlideAlong , " Axis to slide along " , " The Axis to slide along " )
- > ClassElement ( AZ : : Edit : : ClassElements : : EditorData , " " )
- > EnumAttribute ( RelativeAxisType : : ForwardBackward , " Forwards and Backwards " )
- > DataElement ( AZ : : Edit : : UIHandlers : : ComboBox , & SlideAlongAxisBasedOnAngle : : m_axisToSlideAlong , " Axis to slide along " ,
- > EnumAttribute ( RelativeAxisType : : LeftRight , " Right and Left " )
" The Axis to slide along " )
- > EnumAttribute ( RelativeAxisType : : UpDown , " Up and Down " )
- > EnumAttribute ( RelativeAxisType : : ForwardBackward , " Forwards and Backwards " )
- > DataElement ( AZ : : Edit : : UIHandlers : : ComboBox , & SlideAlongAxisBasedOnAngle : : m_angleTypeToChangeFor , " Angle Type " , " The angle type to base the slide off of " )
- > EnumAttribute ( RelativeAxisType : : LeftRight , " Right and Left " )
- > EnumAttribute ( EulerAngleType : : Pitch , " Pitch " )
- > EnumAttribute ( RelativeAxisType : : UpDown , " Up and Down " )
- > EnumAttribute ( EulerAngleType : : Roll , " Roll " )
- > DataElement ( AZ : : Edit : : UIHandlers : : ComboBox , & SlideAlongAxisBasedOnAngle : : m_angleTypeToChangeFor , " Angle Type " ,
- > EnumAttribute ( EulerAngleType : : Yaw , " Yaw " )
" The angle type to base the slide off of " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_maximumPositiveSlideDistance , " Max Positive Slide Distance " , " The maximum distance to slide in the positive " )
- > EnumAttribute ( EulerAngleType : : Pitch , " Pitch " )
- > Attribute ( AZ : : Edit : : Attributes : : Suffix , " m " )
- > EnumAttribute ( EulerAngleType : : Roll , " Roll " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_maximumNegativeSlideDistance , " Max Negative Slide Distance " , " The maximum distance to slide in the negative " )
- > EnumAttribute ( EulerAngleType : : Yaw , " Yaw " )
- > Attribute ( AZ : : Edit : : Attributes : : Suffix , " m " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_maximumPositiveSlideDistance , " Max Positive Slide Distance " ,
- > ClassElement ( AZ : : Edit : : ClassElements : : Group , " Vector Components To Ignore " )
" The maximum distance to slide in the positive " )
- > Attribute ( AZ : : Edit : : Attributes : : AutoExpand , true )
- > Attribute ( AZ : : Edit : : Attributes : : Suffix , " m " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreX , " X " , " When active, the X Component will be ignored. " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_maximumNegativeSlideDistance , " Max Negative Slide Distance " ,
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreY , " Y " , " When active, the Y Component will be ignored. " )
" The maximum distance to slide in the negative " )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreZ , " Z " , " When active, the Z Component will be ignored. " )
- > Attribute ( AZ : : Edit : : Attributes : : Suffix , " m " )
- > ClassElement ( AZ : : Edit : : ClassElements : : Group , " Vector Components To Ignore " )
- > Attribute ( AZ : : Edit : : Attributes : : AutoExpand , true )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreX , " X " , " When active, the X Component will be ignored. " )
- > Attribute ( AZ : : Edit : : Attributes : : ReadOnly , & SlideAlongAxisBasedOnAngle : : YAndZIgnored )
- > Attribute ( AZ : : Edit : : Attributes : : ChangeNotify , AZ : : Edit : : PropertyRefreshLevels : : AttributesAndValues )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreY , " Y " , " When active, the Y Component will be ignored. " )
- > Attribute ( AZ : : Edit : : Attributes : : ReadOnly , & SlideAlongAxisBasedOnAngle : : XAndZIgnored )
- > Attribute ( AZ : : Edit : : Attributes : : ChangeNotify , AZ : : Edit : : PropertyRefreshLevels : : AttributesAndValues )
- > DataElement ( 0 , & SlideAlongAxisBasedOnAngle : : m_ignoreZ , " Z " , " When active, the Z Component will be ignored. " )
- > Attribute ( AZ : : Edit : : Attributes : : ReadOnly , & SlideAlongAxisBasedOnAngle : : XAndYIgnored )
- > Attribute ( AZ : : Edit : : Attributes : : ChangeNotify , AZ : : Edit : : PropertyRefreshLevels : : AttributesAndValues )
;
;
}
}
}
}
}
}
void SlideAlongAxisBasedOnAngle : : AdjustLookAtTarget ( [[maybe_unused]] float deltaTime, [[maybe_unused]] const AZ : : Transform & targetTransform , AZ : : Transform & outLookAtTargetTransform )
void SlideAlongAxisBasedOnAngle : : AdjustLookAtTarget (
[[maybe_unused]] float deltaTime, [[maybe_unused]] const AZ : : Transform & targetTransform , AZ : : Transform & outLookAtTargetTransform )
{
{
float angle = GetEulerAngleFromTransform ( outLookAtTargetTransform , m_angleTypeToChangeFor ) ;
float angle = GetEulerAngleFromTransform ( outLookAtTargetTransform , m_angleTypeToChangeFor ) ;
float currentPositionOnRange = - angle / AZ : : Constants : : HalfPi ;
float currentPositionOnRange = - angle / AZ : : Constants : : HalfPi ;
@ -67,4 +79,20 @@ namespace Camera
outLookAtTargetTransform . SetTranslation ( outLookAtTargetTransform . GetTranslation ( ) + basis * currentPositionOnRange * slideScale ) ;
outLookAtTargetTransform . SetTranslation ( outLookAtTargetTransform . GetTranslation ( ) + basis * currentPositionOnRange * slideScale ) ;
}
}
}
bool SlideAlongAxisBasedOnAngle : : XAndYIgnored ( ) const
{
return m_ignoreX & & m_ignoreY ;
}
bool SlideAlongAxisBasedOnAngle : : XAndZIgnored ( ) const
{
return m_ignoreX & & m_ignoreZ ;
}
bool SlideAlongAxisBasedOnAngle : : YAndZIgnored ( ) const
{
return m_ignoreY & & m_ignoreZ ;
}
} // namespace Camera