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

58 lines
1.2 KiB
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 )
{
2024-08-04 09:08:12 +00:00
return -node.GlobalBasis.Z;
2024-05-19 15:59:41 +00:00
}
public static Vector3 GetGlobalUp( Node3D node )
{
return node.GlobalBasis.Y;
}
public static Vector3 GetGlobalRight( Node3D node )
{
return node.GlobalBasis.X;
}
2024-07-25 05:40:31 +00:00
public static Vector3 GetYPlaneForward( Node3D node )
{
var forward = GetGlobalForward( node );
forward.Y = 0;
return forward.Normalized();
}
public static Vector3 GetYPlaneRight( Node3D node )
{
var right = GetGlobalRight( node );
right.Y = 0;
return right.Normalized();
}
2024-05-19 15:59:41 +00:00
}
}