rj-action-library/Runtime/Math/Math3D.cs

40 lines
838 B
C#
Raw Normal View History

2024-05-19 15:59:41 +00:00
using System.Collections;
using System.Collections.Generic;
using Godot;
using System.Text;
using System;
namespace Rokojori
{
public class Math3D
{
public static Quaternion GetGlobalRotation( Node3D node )
{
return node.GlobalBasis.GetRotationQuaternion();
}
public static void SetGlobalRotation( Node3D node, Quaternion quaternion )
{
var forward = quaternion * Vector3.Forward;
var up = quaternion * Vector3.Up;
node.LookAt( node.GlobalPosition + forward, up );
}
public static Vector3 GetGlobalForward( Node3D node )
{
return node.GlobalBasis.Z;
}
public static Vector3 GetGlobalUp( Node3D node )
{
return node.GlobalBasis.Y;
}
public static Vector3 GetGlobalRight( Node3D node )
{
return node.GlobalBasis.X;
}
}
}