Added LookAt & Forward to C# Transforms
This commit is contained in:
parent
7202551838
commit
0aaf5b7e79
|
@ -1,16 +1,12 @@
|
||||||
/************************************************************************************//*!
|
/****************************************************************************************
|
||||||
\file Transform.cxx
|
* \file Transform.cxx
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
||||||
\par email: kahwei.tng\@digipen.edu
|
* \brief Implementation for the managed Transform class.
|
||||||
\date Sep 23, 2022
|
*
|
||||||
\brief Contains the definition of the functions of the managed Transform class.
|
* \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or
|
||||||
|
* disclosure of this file or its contents without the prior written consent
|
||||||
Note: This file is written in C++17/CLI.
|
* of DigiPen Institute of Technology is prohibited.
|
||||||
|
****************************************************************************************/
|
||||||
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
|
// Precompiled Headers
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
// Primary Header
|
// Primary Header
|
||||||
|
@ -18,80 +14,116 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
Transform::Transform(Entity entity)
|
||||||
|
: Component(entity)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
Vector3 Transform::LocalPosition::get()
|
Vector3 Transform::LocalPosition::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetLocalPosition());
|
return Convert::ToCLI(GetNativeComponent()->GetLocalPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::LocalPosition::set(Vector3 val)
|
void Transform::LocalPosition::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetLocalPosition(Convert::ToNative(val));
|
GetNativeComponent()->SetLocalPosition(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Transform::LocalRotation::get()
|
Quaternion Transform::LocalRotation::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
|
return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::LocalRotation::set(Quaternion val)
|
void Transform::LocalRotation::set(Quaternion val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetLocalOrientation(Convert::ToNative(val));
|
GetNativeComponent()->SetLocalOrientation(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transform::LocalEulerAngles::get()
|
Vector3 Transform::LocalEulerAngles::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetLocalRotation());
|
return Convert::ToCLI(GetNativeComponent()->GetLocalRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::LocalEulerAngles::set(Vector3 val)
|
void Transform::LocalEulerAngles::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetLocalRotation(Convert::ToNative(val));
|
GetNativeComponent()->SetLocalRotation(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transform::LocalScale::get()
|
Vector3 Transform::LocalScale::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetLocalScale());
|
return Convert::ToCLI(GetNativeComponent()->GetLocalScale());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::LocalScale::set(Vector3 val)
|
void Transform::LocalScale::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetLocalScale(Convert::ToNative(val));
|
GetNativeComponent()->SetLocalScale(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transform::GlobalPosition::get()
|
Vector3 Transform::GlobalPosition::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetWorldPosition());
|
return Convert::ToCLI(GetNativeComponent()->GetWorldPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::GlobalPosition::set(Vector3 val)
|
void Transform::GlobalPosition::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWorldPosition(Convert::ToNative(val));
|
GetNativeComponent()->SetWorldPosition(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Transform::GlobalRotation::get()
|
Quaternion Transform::GlobalRotation::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
|
return Convert::ToCLI(GetNativeComponent()->GetLocalOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::GlobalRotation::set(Quaternion val)
|
void Transform::GlobalRotation::set(Quaternion val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWorldOrientation(Convert::ToNative(val));
|
GetNativeComponent()->SetWorldOrientation(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transform::GlobalEulerAngles::get()
|
Vector3 Transform::GlobalEulerAngles::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetWorldRotation());
|
return Convert::ToCLI(GetNativeComponent()->GetWorldRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::GlobalEulerAngles::set(Vector3 val)
|
void Transform::GlobalEulerAngles::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWorldRotation(Convert::ToNative(val));
|
GetNativeComponent()->SetWorldRotation(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transform::GlobalScale::get()
|
Vector3 Transform::GlobalScale::get()
|
||||||
{
|
{
|
||||||
return Convert::ToCLI(GetNativeComponent()->GetWorldScale());
|
return Convert::ToCLI(GetNativeComponent()->GetWorldScale());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::GlobalScale::set(Vector3 val)
|
void Transform::GlobalScale::set(Vector3 val)
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWorldScale(Convert::ToNative(val));
|
GetNativeComponent()->SetWorldScale(Convert::ToNative(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
Vector3 Transform::Forward::get()
|
||||||
/* Constructors */
|
{
|
||||||
/*---------------------------------------------------------------------------------*/
|
const SHVec3 DIRECTION = SHVec3::Rotate(SHVec3::UnitZ, Convert::ToNative(GlobalRotation));
|
||||||
Transform::Transform(Entity entity)
|
return Convert::ToCLI(DIRECTION);
|
||||||
: Component(entity)
|
}
|
||||||
{}
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Usage Function Definitions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void Transform::LookAt(Vector3 target)
|
||||||
|
{
|
||||||
|
GlobalRotation.SetLookRotation(target - GlobalPosition, Vector3::Up);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Transform::LookAt(Vector3 target, Vector3 up)
|
||||||
|
{
|
||||||
|
GlobalRotation.SetLookRotation(target - GlobalPosition, up);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
/************************************************************************************//*!
|
/****************************************************************************************
|
||||||
\file Transform.hxx
|
* \file Transform.hxx
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
||||||
\par email: kahwei.tng\@digipen.edu
|
* \brief Interface for the managed Transform class.
|
||||||
\date Sep 23, 2022
|
*
|
||||||
\brief Contains the definition of the managed Transform class with the
|
* \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or
|
||||||
declaration of functions for working with it.
|
* disclosure of this file or its contents without the prior written consent
|
||||||
|
* of DigiPen Institute of Technology is prohibited.
|
||||||
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
|
#pragma once
|
||||||
|
|
||||||
// Project Includes
|
// Project Includes
|
||||||
|
@ -28,6 +23,87 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ref class Transform : public Component<SHTransformComponent>
|
public ref class Transform : public Component<SHTransformComponent>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Local position stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 LocalPosition
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local rotation quaternion stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Quaternion LocalRotation
|
||||||
|
{
|
||||||
|
Quaternion get();
|
||||||
|
void set(Quaternion val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local euler angle rotations stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 LocalEulerAngles
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local scale stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 LocalScale
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Global position stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 GlobalPosition
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Global rotation quaternion stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Quaternion GlobalRotation
|
||||||
|
{
|
||||||
|
Quaternion get();
|
||||||
|
void set(Quaternion val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Global euler angle rotations stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 GlobalEulerAngles
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Global scale stored by this Transform.
|
||||||
|
/// </summary>
|
||||||
|
property Vector3 GlobalScale
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
void set(Vector3 val);
|
||||||
|
}
|
||||||
|
|
||||||
|
property Vector3 Forward
|
||||||
|
{
|
||||||
|
Vector3 get();
|
||||||
|
}
|
||||||
|
|
||||||
internal:
|
internal:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
|
@ -41,72 +117,22 @@ namespace SHADE
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Local position stored by this Transform.
|
/// Rotates the transform to look at a target.
|
||||||
|
/// This function
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property Vector3 LocalPosition
|
/// <param name="target"> The target to look at. </param>
|
||||||
{
|
void LookAt(Vector3 target);
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Local rotation quaternion stored by this Transform.
|
/// Rotates the transform to look at a target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property Quaternion LocalRotation
|
/// <param name="target"> The target to look at. </param>
|
||||||
{
|
/// <param name="up"> The up vector to rotate about. </param>
|
||||||
Quaternion get();
|
void LookAt(Vector3 target, Vector3 up);
|
||||||
void set(Quaternion val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Local euler angle rotations stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Vector3 LocalEulerAngles
|
|
||||||
{
|
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Local scale stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Vector3 LocalScale
|
|
||||||
{
|
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Global position stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Vector3 GlobalPosition
|
|
||||||
{
|
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Global rotation quaternion stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Quaternion GlobalRotation
|
|
||||||
{
|
|
||||||
Quaternion get();
|
|
||||||
void set(Quaternion val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Global euler angle rotations stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Vector3 GlobalEulerAngles
|
|
||||||
{
|
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Global scale stored by this Transform.
|
|
||||||
/// </summary>
|
|
||||||
property Vector3 GlobalScale
|
|
||||||
{
|
|
||||||
Vector3 get();
|
|
||||||
void set(Vector3 val);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue