92 lines
2.2 KiB
C#
92 lines
2.2 KiB
C#
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
|
|
}
|
|
|
|
public class TransformTargets
|
|
{
|
|
public static AnimationMember ToAnimationMember( TransformTarget target )
|
|
{
|
|
if ( TransformTarget.Local_Position == target || TransformTarget.Global_Position == target )
|
|
{
|
|
return AnimationManager.position;
|
|
}
|
|
|
|
if ( TransformTarget.Local_Rotation == target || TransformTarget.Global_Rotation == target )
|
|
{
|
|
return AnimationManager.rotation;
|
|
}
|
|
|
|
if ( TransformTarget.Local_Scale == target )
|
|
{
|
|
return AnimationManager.scale;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static Vector3 Get( Node3D target, TransformTarget transformTarget )
|
|
{
|
|
if ( TransformTarget.Global_Position == transformTarget )
|
|
{
|
|
return target.GlobalPosition;
|
|
}
|
|
else if ( TransformTarget.Global_Rotation == transformTarget )
|
|
{
|
|
return target.GlobalRotation;
|
|
}
|
|
else if ( TransformTarget.Local_Position == transformTarget )
|
|
{
|
|
return target.Position;
|
|
}
|
|
else if ( TransformTarget.Local_Rotation == transformTarget )
|
|
{
|
|
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 )
|
|
{
|
|
target.GlobalRotation = value;
|
|
}
|
|
else if ( TransformTarget.Local_Position == transformTarget )
|
|
{
|
|
target.Position = value;
|
|
}
|
|
else if ( TransformTarget.Local_Rotation == transformTarget )
|
|
{
|
|
target.Rotation = value;
|
|
}
|
|
else if ( TransformTarget.Local_Scale == transformTarget )
|
|
{
|
|
target.Scale = value;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
} |