Merge pull request #264 from SHADE-DP/SP3-141-Camera-System

Added a target offset for camera arm
This commit is contained in:
XiaoQiDigipen 2022-11-23 18:29:06 +08:00 committed by GitHub
commit 29b50bd255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 3 deletions

View File

@ -8,6 +8,7 @@ namespace SHADE
SHCameraArmComponent::SHCameraArmComponent() SHCameraArmComponent::SHCameraArmComponent()
:pitch(0.0f), yaw(0.0f), armLength(1.0f),offset(), dirty(true), lookAtCameraOrigin(true) :pitch(0.0f), yaw(0.0f), armLength(1.0f),offset(), dirty(true), lookAtCameraOrigin(true)
, targetOffset(0.0f)
{ {
} }
@ -33,6 +34,11 @@ namespace SHADE
return armLength; return armLength;
} }
SHVec3 SHCameraArmComponent::GetTargetOffset() const noexcept
{
return targetOffset;
}
void SHCameraArmComponent::SetPitch(float pitch) noexcept void SHCameraArmComponent::SetPitch(float pitch) noexcept
{ {
this->pitch = pitch; this->pitch = pitch;
@ -51,6 +57,11 @@ namespace SHADE
dirty = true; dirty = true;
} }
void SHCameraArmComponent::SetTargetOffset(SHVec3 offset) noexcept
{
this->targetOffset = offset;
}
}//namespace SHADE }//namespace SHADE
@ -63,6 +74,8 @@ RTTR_REGISTRATION
.property("Arm Pitch", &SHCameraArmComponent::GetPitch, &SHCameraArmComponent::SetPitch) .property("Arm Pitch", &SHCameraArmComponent::GetPitch, &SHCameraArmComponent::SetPitch)
.property("Arm Yaw", &SHCameraArmComponent::GetYaw, &SHCameraArmComponent::SetYaw) .property("Arm Yaw", &SHCameraArmComponent::GetYaw, &SHCameraArmComponent::SetYaw)
.property("Arm Length", &SHCameraArmComponent::GetArmLength, &SHCameraArmComponent::SetArmLength) .property("Arm Length", &SHCameraArmComponent::GetArmLength, &SHCameraArmComponent::SetArmLength)
.property("Look At Camera Origin", &SHCameraArmComponent::lookAtCameraOrigin); .property("Look At Camera Origin", &SHCameraArmComponent::lookAtCameraOrigin)
.property("Target Offset", &SHCameraArmComponent::GetTargetOffset, &SHCameraArmComponent::SetTargetOffset)
;
} }

View File

@ -17,7 +17,7 @@ namespace SHADE
bool dirty; bool dirty;
SHVec3 offset; SHVec3 offset;
SHVec3 targetOffset;
public: public:
friend class SHCameraSystem; friend class SHCameraSystem;
SHCameraArmComponent(); SHCameraArmComponent();
@ -30,11 +30,13 @@ namespace SHADE
float GetPitch() const noexcept; float GetPitch() const noexcept;
float GetYaw() const noexcept; float GetYaw() const noexcept;
float GetArmLength() const noexcept; float GetArmLength() const noexcept;
SHVec3 GetTargetOffset() const noexcept;
//Setters //Setters
void SetPitch(float pitch) noexcept; void SetPitch(float pitch) noexcept;
void SetYaw(float yaw) noexcept; void SetYaw(float yaw) noexcept;
void SetArmLength(float length) noexcept; void SetArmLength(float length) noexcept;
void SetTargetOffset(SHVec3 offset)noexcept;
protected: protected:

View File

@ -182,7 +182,7 @@ namespace SHADE
{ {
camera.offset = arm->GetOffset(); camera.offset = arm->GetOffset();
if (arm->lookAtCameraOrigin) if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position); CameraLookAt(camera, camera.position + arm->GetTargetOffset());
} }
} }

View File

@ -48,4 +48,15 @@ namespace SHADE
{ {
GetNativeComponent()->lookAtCameraOrigin = val; GetNativeComponent()->lookAtCameraOrigin = val;
} }
Vector3 CameraArm::TargetOffset::get()
{
return Convert::ToCLI(GetNativeComponent()->GetTargetOffset());
}
void CameraArm::TargetOffset::set(Vector3 val)
{
GetNativeComponent()->SetTargetOffset(Convert::ToNative(val));
}
} }

View File

@ -36,5 +36,11 @@ namespace SHADE
void set(bool val); void set(bool val);
} }
property Vector3 TargetOffset
{
Vector3 get();
void set(Vector3 val);
}
}; };
} }