SHADE_Y3/SHADE_Managed/src/Components/RigidBody.cxx

197 lines
6.8 KiB
C++

/************************************************************************************//*!
\file RigidBody.cxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Oct 22, 2022
\brief Contains the definition of the functions of the managed RigidBody class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
// Precompiled Headers
#include "SHpch.h"
// Primary Header
#include "RigidBody.hxx"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/
RigidBody::RigidBody(Entity entity)
: Component(entity)
{}
/*---------------------------------------------------------------------------------*/
/* Properties */
/*---------------------------------------------------------------------------------*/
bool RigidBody::IsGravityEnabled::get()
{
return GetNativeComponent()->IsGravityEnabled();
}
void RigidBody::IsGravityEnabled::set(bool value)
{
return GetNativeComponent()->SetGravityEnabled(value);
}
bool RigidBody::IsAllowedToSleep::get()
{
return GetNativeComponent()->IsAllowedToSleep();
}
void RigidBody::IsAllowedToSleep::set(bool value)
{
return GetNativeComponent()->SetIsAllowedToSleep(value);
}
RigidBody::Type RigidBody::BodyType::get()
{
return static_cast<Type>(GetNativeComponent()->GetType());
}
void RigidBody::BodyType::set(Type value)
{
return GetNativeComponent()->SetType(static_cast<SHRigidBodyComponent::Type>(value));
}
float RigidBody::Mass::get()
{
return GetNativeComponent()->GetMass();
}
void RigidBody::Mass::set(float value)
{
return GetNativeComponent()->SetMass(value);
}
float RigidBody::Drag::get()
{
return GetNativeComponent()->GetDrag();
}
void RigidBody::Drag::set(float value)
{
return GetNativeComponent()->SetDrag(value);
}
float RigidBody::AngularDrag::get()
{
return GetNativeComponent()->GetAngularDrag();
}
void RigidBody::AngularDrag::set(float value)
{
return GetNativeComponent()->SetAngularDrag(value);
}
bool RigidBody::FreezePositionX::get()
{
return GetNativeComponent()->GetFreezePositionX();
}
void RigidBody::FreezePositionX::set(bool value)
{
return GetNativeComponent()->SetFreezePositionX(value);
}
bool RigidBody::FreezePositionY::get()
{
return GetNativeComponent()->GetFreezePositionY();
}
void RigidBody::FreezePositionY::set(bool value)
{
return GetNativeComponent()->SetFreezePositionY(value);
}
bool RigidBody::FreezePositionZ::get()
{
return GetNativeComponent()->GetFreezePositionZ();
}
void RigidBody::FreezePositionZ::set(bool value)
{
return GetNativeComponent()->SetFreezePositionZ(value);
}
bool RigidBody::FreezeRotationX::get()
{
return GetNativeComponent()->GetFreezeRotationX();
}
void RigidBody::FreezeRotationX::set(bool value)
{
return GetNativeComponent()->SetFreezeRotationX(value);
}
bool RigidBody::FreezeRotationY::get()
{
return GetNativeComponent()->GetFreezeRotationY();
}
void RigidBody::FreezeRotationY::set(bool value)
{
return GetNativeComponent()->SetFreezeRotationY(value);
}
bool RigidBody::FreezeRotationZ::get()
{
return GetNativeComponent()->GetFreezeRotationZ();
}
void RigidBody::FreezeRotationZ::set(bool value)
{
return GetNativeComponent()->SetFreezeRotationZ(value);
}
Vector3 RigidBody::LinearVelocity::get()
{
return Convert::ToCLI(GetNativeComponent()->GetLinearVelocity());
}
void RigidBody::LinearVelocity::set(Vector3 value)
{
return GetNativeComponent()->SetLinearVelocity(Convert::ToNative(value));
}
Vector3 RigidBody::AngularVelocity::get()
{
return Convert::ToCLI(GetNativeComponent()->GetAngularVelocity());
}
void RigidBody::AngularVelocity::set(Vector3 value)
{
return GetNativeComponent()->SetAngularVelocity(Convert::ToNative(value));
}
Vector3 RigidBody::Force::get()
{
return Convert::ToCLI(GetNativeComponent()->GetForce());
}
Vector3 RigidBody::Torque::get()
{
return Convert::ToCLI(GetNativeComponent()->GetTorque());
}
/*---------------------------------------------------------------------------------*/
/* Force Functions */
/*---------------------------------------------------------------------------------*/
void RigidBody::AddForce(Vector3 force)
{
GetNativeComponent()->AddForce(Convert::ToNative(force));
}
void RigidBody::AddForceAtLocalPos(Vector3 force, Vector3 localPos)
{
GetNativeComponent()->AddForceAtLocalPos(Convert::ToNative(force), Convert::ToNative(localPos));
}
void RigidBody::AddForceAtWorldPos(Vector3 force, Vector3 worldPos)
{
GetNativeComponent()->AddForceAtWorldPos(Convert::ToNative(force), Convert::ToNative(worldPos));
}
void RigidBody::AddRelativeForce(Vector3 relativeForce)
{
GetNativeComponent()->AddRelativeForce(Convert::ToNative(relativeForce));
}
void RigidBody::AddRelativeForceAtLocalPos(Vector3 relativeForce, Vector3 localPos)
{
GetNativeComponent()->AddRelativeForceAtLocalPos(Convert::ToNative(relativeForce), Convert::ToNative(localPos));
}
void RigidBody::AddRelativeForceAtWorldPos(Vector3 relativeForce, Vector3 worldPos)
{
GetNativeComponent()->AddRelativeForceAtWorldPos(Convert::ToNative(relativeForce), Convert::ToNative(worldPos));
}
/*---------------------------------------------------------------------------------*/
/* Torque Functions */
/*---------------------------------------------------------------------------------*/
void RigidBody::AddTorque(Vector3 torque)
{
GetNativeComponent()->AddTorque(Convert::ToNative(torque));
}
void RigidBody::AddRelativeTorque(Vector3 relativeTorque)
{
GetNativeComponent()->AddRelativeTorque(Convert::ToNative(relativeTorque));
}
}