Added RigidBody component
This commit is contained in:
parent
885f22c984
commit
2bd633c11b
|
@ -221,6 +221,9 @@ namespace SHADE
|
|||
T GetColliderBound(int index);
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
System::Collections::Generic::List<ColliderBound^>^ subColliderList; // TODO: Update elements in this list if the list on native collider changes
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
/************************************************************************************//*!
|
||||
\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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/************************************************************************************//*!
|
||||
\file RigidBody.hxx
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Oct 22, 2022
|
||||
\brief Contains the definition of the managed Collider class with the
|
||||
declaration of functions for working with it.
|
||||
|
||||
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.
|
||||
*//*************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
// External Dependencies
|
||||
#include "Physics/Components/SHRigidBodyComponent.h"
|
||||
// Project Includes
|
||||
#include "Components/Component.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/// <summary>
|
||||
/// CLR version of the the SHADE Engine's SHRigidBodyComponent.
|
||||
/// </summary>
|
||||
public ref class RigidBody : public Component<SHRigidBodyComponent>
|
||||
{
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Constructs a RigidBody Component that represents a native
|
||||
/// SHRigidBodyComponent component tied to the specified Entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||
RigidBody(Entity entity);
|
||||
|
||||
public:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Type Definitions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
enum class Type
|
||||
{
|
||||
Static,
|
||||
Kinematic,
|
||||
Dynamic
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Properties */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
property bool IsGravityEnabled
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool IsAllowedToSleep
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property Type BodyType
|
||||
{
|
||||
Type get();
|
||||
void set(Type value);
|
||||
}
|
||||
property float Mass
|
||||
{
|
||||
float get();
|
||||
void set(float value);
|
||||
}
|
||||
property float Drag
|
||||
{
|
||||
float get();
|
||||
void set(float value);
|
||||
}
|
||||
property float AngularDrag
|
||||
{
|
||||
float get();
|
||||
void set(float value);
|
||||
}
|
||||
property bool FreezePositionX
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool FreezePositionY
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool FreezePositionZ
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool FreezeRotationX
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool FreezeRotationY
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property bool FreezeRotationZ
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
property Vector3 LinearVelocity
|
||||
{
|
||||
Vector3 get();
|
||||
void set(Vector3 value);
|
||||
}
|
||||
property Vector3 AngularVelocity
|
||||
{
|
||||
Vector3 get();
|
||||
void set(Vector3 value);
|
||||
}
|
||||
property Vector3 Force
|
||||
{
|
||||
Vector3 get();
|
||||
}
|
||||
property Vector3 Torque
|
||||
{
|
||||
Vector3 get();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Force Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void AddForce(Vector3 force);
|
||||
void AddForceAtLocalPos(Vector3 force, Vector3 localPos);
|
||||
void AddForceAtWorldPos(Vector3 force, Vector3 worldPos);
|
||||
void AddRelativeForce(Vector3 relativeForce);
|
||||
void AddRelativeForceAtLocalPos(Vector3 relativeForce, Vector3 localPos);
|
||||
void AddRelativeForceAtWorldPos(Vector3 relativeForce, Vector3 worldPos);
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Torque Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void AddTorque(Vector3 force);
|
||||
void AddRelativeTorque(Vector3 relativeForce);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue