Upload project files
This commit is contained in:
49
Runtime/Cloner/Fields/LinearField.cs
Normal file
49
Runtime/Cloner/Fields/LinearField.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class LinearField : FieldBase
|
||||
{
|
||||
public float length = 1.0f;
|
||||
|
||||
private float3 fieldForward;
|
||||
private float3 fieldPosition;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
fieldForward = transform.forward;
|
||||
fieldPosition = transform.position;
|
||||
}
|
||||
|
||||
public override float Operate(float3 position)
|
||||
{
|
||||
var plane = new Unity.Mathematics.Geometry.Plane(fieldForward, fieldPosition);
|
||||
var distance = plane.SignedDistanceToPoint(position) / length;
|
||||
var weight = math.saturate(distance / 2.0f + 0.5f);
|
||||
|
||||
weight = Remapping(weight);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
|
||||
var end = Vector3.forward * length;
|
||||
var start = Vector3.forward * -length;
|
||||
|
||||
Gizmos.DrawLine(start, end);
|
||||
var right = Quaternion.LookRotation(Vector3.forward) * Quaternion.Euler(0.0f, 180.0f + 30.0f, 0.0f) * Vector3.forward;
|
||||
var left = Quaternion.LookRotation(Vector3.forward) * Quaternion.Euler(0.0f, 180.0f - 30.0f, 0.0f) * Vector3.forward;
|
||||
|
||||
Gizmos.DrawLine(end, end + right * 0.5f);
|
||||
Gizmos.DrawLine(end, end + left * 0.5f);
|
||||
|
||||
Gizmos.DrawWireCube(end, Vector3.one);
|
||||
Gizmos.DrawWireCube(start, Vector3.one);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user