2025-01-03 12:09:23 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
public enum TransformTarget
|
|
|
|
{
|
|
|
|
Global_Position,
|
|
|
|
Global_Rotation,
|
|
|
|
Local_Position,
|
|
|
|
Local_Rotation,
|
|
|
|
Local_Scale
|
|
|
|
}
|
|
|
|
|
2025-01-08 18:46:17 +00:00
|
|
|
|
|
|
|
|
2025-01-03 12:09:23 +00:00
|
|
|
public class TransformTargets
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
public static TransformTarget Position( bool global = true )
|
|
|
|
{
|
|
|
|
return global ? TransformTarget.Global_Position : TransformTarget.Local_Position;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static TransformTarget Rotation( bool global = true )
|
|
|
|
{
|
|
|
|
return global ? TransformTarget.Global_Rotation : TransformTarget.Local_Rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static TransformTarget Scale()
|
|
|
|
{
|
|
|
|
return TransformTarget.Local_Scale;
|
|
|
|
}
|
|
|
|
|
2025-01-03 12:09:23 +00:00
|
|
|
public static AnimationMember ToAnimationMember( TransformTarget target )
|
|
|
|
{
|
|
|
|
if ( TransformTarget.Local_Position == target || TransformTarget.Global_Position == target )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
return AnimationMember.Position;
|
2025-01-03 12:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( TransformTarget.Local_Rotation == target || TransformTarget.Global_Rotation == target )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
return AnimationMember.Rotation;
|
2025-01-03 12:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( TransformTarget.Local_Scale == target )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
return AnimationMember.Scale;
|
2025-01-03 12:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Vector3 Get( Node3D target, TransformTarget transformTarget )
|
|
|
|
{
|
|
|
|
if ( TransformTarget.Global_Position == transformTarget )
|
|
|
|
{
|
|
|
|
return target.GlobalPosition;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Global_Rotation == transformTarget )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
// RJLog.Log( "GlobalRotation => ", target.GlobalRotation );
|
2025-01-03 12:09:23 +00:00
|
|
|
return target.GlobalRotation;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Position == transformTarget )
|
|
|
|
{
|
|
|
|
return target.Position;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Rotation == transformTarget )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
// RJLog.Log( "Rotation => ", target.Rotation );
|
2025-01-03 12:09:23 +00:00
|
|
|
return target.Rotation;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Scale == transformTarget )
|
|
|
|
{
|
|
|
|
return target.Scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Vector3.Zero;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Set( Vector3 value, Node3D target, TransformTarget transformTarget )
|
|
|
|
{
|
|
|
|
if ( TransformTarget.Global_Position == transformTarget )
|
|
|
|
{
|
|
|
|
target.GlobalPosition = value;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Global_Rotation == transformTarget )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
var rotation = target.GlobalRotation;
|
2025-01-03 12:09:23 +00:00
|
|
|
target.GlobalRotation = value;
|
2025-01-08 18:46:17 +00:00
|
|
|
// RJLog.Log( "GlobalRotation = ", rotation, ">>", value, target.GlobalRotation );
|
2025-01-03 12:09:23 +00:00
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Position == transformTarget )
|
|
|
|
{
|
|
|
|
target.Position = value;
|
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Rotation == transformTarget )
|
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
var rotation = target.Rotation;
|
2025-01-03 12:09:23 +00:00
|
|
|
target.Rotation = value;
|
2025-01-08 18:46:17 +00:00
|
|
|
// RJLog.Log( "Rotation = ", rotation, ">>", value, target.Rotation );
|
2025-01-03 12:09:23 +00:00
|
|
|
}
|
|
|
|
else if ( TransformTarget.Local_Scale == transformTarget )
|
|
|
|
{
|
|
|
|
target.Scale = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|