|
@@ -1,6 +1,6 @@
|
|
using System;
|
|
using System;
|
|
-using System.IO;
|
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
@@ -44,7 +44,8 @@ namespace MeidoPhotoStudio.Plugin
|
|
Toe1R, Toe11R, Toe1NubR,
|
|
Toe1R, Toe11R, Toe1NubR,
|
|
Toe2R, Toe21R, Toe2NubR
|
|
Toe2R, Toe21R, Toe2NubR
|
|
}
|
|
}
|
|
- private static readonly Dictionary<AttachPoint, Bone> PointToBone = new Dictionary<AttachPoint, Bone>()
|
|
|
|
|
|
+
|
|
|
|
+ private static readonly Dictionary<AttachPoint, Bone> PointToBone = new()
|
|
{
|
|
{
|
|
[AttachPoint.Head] = Bone.Head,
|
|
[AttachPoint.Head] = Bone.Head,
|
|
[AttachPoint.Neck] = Bone.HeadNub,
|
|
[AttachPoint.Neck] = Bone.HeadNub,
|
|
@@ -68,11 +69,17 @@ namespace MeidoPhotoStudio.Plugin
|
|
[AttachPoint.Spine0a] = Bone.Spine0a,
|
|
[AttachPoint.Spine0a] = Bone.Spine0a,
|
|
[AttachPoint.Spine0] = Bone.Spine
|
|
[AttachPoint.Spine0] = Bone.Spine
|
|
};
|
|
};
|
|
|
|
+
|
|
private static readonly Bone[] SpineBones =
|
|
private static readonly Bone[] SpineBones =
|
|
{
|
|
{
|
|
Bone.Neck, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Hip, Bone.ThighL, Bone.ThighR
|
|
Bone.Neck, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Hip, Bone.ThighL, Bone.ThighR
|
|
};
|
|
};
|
|
|
|
+
|
|
private static bool cubeActive;
|
|
private static bool cubeActive;
|
|
|
|
+ private static bool cubeSmall;
|
|
|
|
+ private static EventHandler CubeActiveChange;
|
|
|
|
+ private static EventHandler CubeSmallChange;
|
|
|
|
+
|
|
public static bool CubeActive
|
|
public static bool CubeActive
|
|
{
|
|
{
|
|
get => cubeActive;
|
|
get => cubeActive;
|
|
@@ -85,7 +92,7 @@ namespace MeidoPhotoStudio.Plugin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- private static bool cubeSmall;
|
|
|
|
|
|
+
|
|
public static bool CubeSmall
|
|
public static bool CubeSmall
|
|
{
|
|
{
|
|
get => cubeSmall;
|
|
get => cubeSmall;
|
|
@@ -98,51 +105,119 @@ namespace MeidoPhotoStudio.Plugin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- private static EventHandler CubeActiveChange;
|
|
|
|
- private static EventHandler CubeSmallChange;
|
|
|
|
|
|
+
|
|
private readonly Meido meido;
|
|
private readonly Meido meido;
|
|
- private readonly Dictionary<Bone, DragPointMeido> DragPoints = new Dictionary<Bone, DragPointMeido>();
|
|
|
|
- private Dictionary<Bone, Transform> BoneTransform = new Dictionary<Bone, Transform>();
|
|
|
|
|
|
+ private readonly Dictionary<Bone, DragPointMeido> DragPoints = new();
|
|
|
|
+
|
|
|
|
+ public event EventHandler<MeidoUpdateEventArgs> SelectMaid;
|
|
|
|
+
|
|
|
|
+ private Dictionary<Bone, Transform> BoneTransform = new();
|
|
private DragPointBody dragBody;
|
|
private DragPointBody dragBody;
|
|
private DragPointBody dragCube;
|
|
private DragPointBody dragCube;
|
|
private bool initialized;
|
|
private bool initialized;
|
|
- public event EventHandler<MeidoUpdateEventArgs> SelectMaid;
|
|
|
|
private bool isBone;
|
|
private bool isBone;
|
|
|
|
+ private bool active = true;
|
|
|
|
+
|
|
public bool IsBone
|
|
public bool IsBone
|
|
{
|
|
{
|
|
get => isBone;
|
|
get => isBone;
|
|
set
|
|
set
|
|
{
|
|
{
|
|
- if (!initialized) return;
|
|
|
|
- if (isBone != value)
|
|
|
|
- {
|
|
|
|
- isBone = value;
|
|
|
|
- foreach (DragPointMeido dragPoint in DragPoints.Values) dragPoint.IsBone = isBone;
|
|
|
|
- foreach (Bone bone in SpineBones) DragPoints[bone].gameObject.SetActive(isBone);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!initialized)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (isBone == value)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ isBone = value;
|
|
|
|
+
|
|
|
|
+ foreach (var dragPoint in DragPoints.Values)
|
|
|
|
+ dragPoint.IsBone = isBone;
|
|
|
|
+
|
|
|
|
+ foreach (var bone in SpineBones)
|
|
|
|
+ DragPoints[bone].gameObject.SetActive(isBone);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- private bool active = true;
|
|
|
|
|
|
+
|
|
public bool Active
|
|
public bool Active
|
|
{
|
|
{
|
|
get => active;
|
|
get => active;
|
|
set
|
|
set
|
|
{
|
|
{
|
|
- if (!initialized) return;
|
|
|
|
- if (active != value)
|
|
|
|
- {
|
|
|
|
- active = value;
|
|
|
|
- foreach (DragPointMeido dragPoint in DragPoints.Values) dragPoint.gameObject.SetActive(active);
|
|
|
|
- foreach (Bone bone in SpineBones) DragPoints[bone].gameObject.SetActive(active && IsBone);
|
|
|
|
- DragPointHead head = (DragPointHead)DragPoints[Bone.Head];
|
|
|
|
- head.gameObject.SetActive(true);
|
|
|
|
- head.IsIK = !active;
|
|
|
|
- dragBody.IsIK = !active;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!initialized)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (active == value)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ active = value;
|
|
|
|
+
|
|
|
|
+ foreach (var dragPoint in DragPoints.Values)
|
|
|
|
+ dragPoint.gameObject.SetActive(active);
|
|
|
|
+
|
|
|
|
+ foreach (var bone in SpineBones)
|
|
|
|
+ DragPoints[bone].gameObject.SetActive(active && IsBone);
|
|
|
|
+
|
|
|
|
+ var head = (DragPointHead)DragPoints[Bone.Head];
|
|
|
|
+
|
|
|
|
+ head.gameObject.SetActive(true);
|
|
|
|
+ head.IsIK = !active;
|
|
|
|
+ dragBody.IsIK = !active;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static DragPointLimb[] MakeArmChain(Transform lower, Meido meido)
|
|
|
|
+ {
|
|
|
|
+ var limbDragPointSize = Vector3.one * 0.12f;
|
|
|
|
+
|
|
|
|
+ var realLower = CMT.SearchObjName(meido.Body.goSlot[0].obj_tr, lower.name, false);
|
|
|
|
+
|
|
|
|
+ var dragPoints = new DragPointLimb[3];
|
|
|
|
+
|
|
|
|
+ for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
|
|
+ {
|
|
|
|
+ var joint = lower;
|
|
|
|
+ var positionJoint = realLower;
|
|
|
|
+
|
|
|
|
+ dragPoints[i] = DragPoint.Make<DragPointLimb>(PrimitiveType.Sphere, limbDragPointSize);
|
|
|
|
+ dragPoints[i].Initialize(meido, () => positionJoint.position, () => Vector3.zero);
|
|
|
|
+ dragPoints[i].Set(joint);
|
|
|
|
+ dragPoints[i].AddGizmo();
|
|
|
|
+ dragPoints[i].Gizmo.SetAlternateTarget(positionJoint);
|
|
|
|
+
|
|
|
|
+ lower = lower.parent;
|
|
|
|
+ realLower = realLower.parent;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return dragPoints;
|
|
}
|
|
}
|
|
|
|
|
|
- public MeidoDragPointManager(Meido meido) => this.meido = meido;
|
|
|
|
|
|
+ private static DragPointFinger[] MakeFingerChain(Transform lower, Meido meido)
|
|
|
|
+ {
|
|
|
|
+ var fingerDragPointSize = Vector3.one * 0.01f;
|
|
|
|
+
|
|
|
|
+ var dragPoints = new DragPointFinger[3];
|
|
|
|
+
|
|
|
|
+ var realLower = CMT.SearchObjName(meido.Body.goSlot[0].obj_tr, lower.parent.name, false);
|
|
|
|
+
|
|
|
|
+ for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
|
|
+ {
|
|
|
|
+ var joint = lower;
|
|
|
|
+ var positionJoint = realLower;
|
|
|
|
+
|
|
|
|
+ dragPoints[i] = DragPoint.Make<DragPointFinger>(PrimitiveType.Sphere, fingerDragPointSize);
|
|
|
|
+ dragPoints[i].Initialize(meido, () => positionJoint.position, () => Vector3.zero);
|
|
|
|
+ dragPoints[i].Set(joint);
|
|
|
|
+
|
|
|
|
+ lower = lower.parent;
|
|
|
|
+ realLower = realLower.parent;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dragPoints;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public MeidoDragPointManager(Meido meido) =>
|
|
|
|
+ this.meido = meido;
|
|
|
|
|
|
public void Deserialize(BinaryReader reader)
|
|
public void Deserialize(BinaryReader reader)
|
|
{
|
|
{
|
|
@@ -153,7 +228,8 @@ namespace MeidoPhotoStudio.Plugin
|
|
for (var bone = Bone.Finger0L; bone <= upperBone; ++bone)
|
|
for (var bone = Bone.Finger0L; bone <= upperBone; ++bone)
|
|
BoneTransform[bone].localRotation = reader.ReadQuaternion();
|
|
BoneTransform[bone].localRotation = reader.ReadQuaternion();
|
|
|
|
|
|
- var bones = sixtyFourFlag ? new[]
|
|
|
|
|
|
+ var bones = sixtyFourFlag
|
|
|
|
+ ? new[]
|
|
{
|
|
{
|
|
Bone.Pelvis, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Neck, Bone.UpperArmL,
|
|
Bone.Pelvis, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Neck, Bone.UpperArmL,
|
|
Bone.UpperArmR, Bone.ForearmL, Bone.ForearmR, Bone.ThighL, Bone.ThighR, Bone.CalfL, Bone.CalfR,
|
|
Bone.UpperArmR, Bone.ForearmL, Bone.ForearmR, Bone.ThighL, Bone.ThighR, Bone.CalfL, Bone.CalfR,
|
|
@@ -206,42 +282,27 @@ namespace MeidoPhotoStudio.Plugin
|
|
GameMain.Instance.StartCoroutine(ApplyHipPosition(reader.ReadVector3()));
|
|
GameMain.Instance.StartCoroutine(ApplyHipPosition(reader.ReadVector3()));
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
- Somebody smarter than me please help me find a way to do this better T_T
|
|
|
|
- inb4 for loop.
|
|
|
|
- */
|
|
|
|
- private System.Collections.IEnumerator ApplyHipPosition(Vector3 hipPosition)
|
|
|
|
- {
|
|
|
|
- BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
- yield return new WaitForEndOfFrame();
|
|
|
|
- BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
- yield return new WaitForEndOfFrame();
|
|
|
|
- BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Transform GetAttachPointTransform(AttachPoint point)
|
|
|
|
- => point == AttachPoint.None ? null : BoneTransform[PointToBone[point]];
|
|
|
|
-
|
|
|
|
public void Flip()
|
|
public void Flip()
|
|
{
|
|
{
|
|
meido.Stop = true;
|
|
meido.Stop = true;
|
|
- Bone[] single = new[] { Bone.Pelvis, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Neck };
|
|
|
|
- Bone[] pair = new[] {
|
|
|
|
|
|
+
|
|
|
|
+ var single = new[] { Bone.Pelvis, Bone.Spine, Bone.Spine0a, Bone.Spine1, Bone.Spine1a, Bone.Neck };
|
|
|
|
+ var pair = new[] {
|
|
Bone.ClavicleL, Bone.ClavicleR, Bone.UpperArmL, Bone.UpperArmR, Bone.ForearmL, Bone.ForearmR,
|
|
Bone.ClavicleL, Bone.ClavicleR, Bone.UpperArmL, Bone.UpperArmR, Bone.ForearmL, Bone.ForearmR,
|
|
Bone.ThighL, Bone.ThighR, Bone.CalfL, Bone.CalfR, Bone.HandL, Bone.HandR, Bone.FootL, Bone.FootR
|
|
Bone.ThighL, Bone.ThighR, Bone.CalfL, Bone.CalfR, Bone.HandL, Bone.HandR, Bone.FootL, Bone.FootR
|
|
};
|
|
};
|
|
|
|
|
|
- List<Vector3> singleRotations = single.Select(bone => BoneTransform[bone].eulerAngles).ToList();
|
|
|
|
- List<Vector3> pairRotations = pair.Select(bone => BoneTransform[bone].eulerAngles).ToList();
|
|
|
|
|
|
+ var singleRotations = single.Select(bone => BoneTransform[bone].eulerAngles).ToList();
|
|
|
|
+ var pairRotations = pair.Select(bone => BoneTransform[bone].eulerAngles).ToList();
|
|
|
|
|
|
- Transform hip = BoneTransform[Bone.Hip];
|
|
|
|
- Vector3 vecHip = hip.eulerAngles;
|
|
|
|
|
|
+ var hip = BoneTransform[Bone.Hip];
|
|
|
|
+ var vecHip = hip.eulerAngles;
|
|
|
|
|
|
- Transform hipL = meido.Maid.body0.GetBone("Hip_L");
|
|
|
|
- Vector3 vecHipL = hipL.eulerAngles;
|
|
|
|
|
|
+ var hipL = meido.Maid.body0.GetBone("Hip_L");
|
|
|
|
+ var vecHipL = hipL.eulerAngles;
|
|
|
|
|
|
- Transform hipR = meido.Maid.body0.GetBone("Hip_R");
|
|
|
|
- Vector3 vecHipR = hipR.eulerAngles;
|
|
|
|
|
|
+ var hipR = meido.Maid.body0.GetBone("Hip_R");
|
|
|
|
+ var vecHipR = hipR.eulerAngles;
|
|
|
|
|
|
hip.rotation = Quaternion.Euler(
|
|
hip.rotation = Quaternion.Euler(
|
|
360f - (vecHip.x + 270f) - 270f, 360f - (vecHip.y + 90f) - 90f, 360f - vecHip.z
|
|
360f - (vecHip.x + 270f) - 270f, 360f - (vecHip.y + 90f) - 90f, 360f - vecHip.z
|
|
@@ -250,120 +311,82 @@ namespace MeidoPhotoStudio.Plugin
|
|
hipL.rotation = FlipRotation(vecHipR);
|
|
hipL.rotation = FlipRotation(vecHipR);
|
|
hipR.rotation = FlipRotation(vecHipL);
|
|
hipR.rotation = FlipRotation(vecHipL);
|
|
|
|
|
|
- for (int i = 0; i < single.Length; i++)
|
|
|
|
|
|
+ for (var i = 0; i < single.Length; i++)
|
|
{
|
|
{
|
|
- Bone bone = single[i];
|
|
|
|
|
|
+ var bone = single[i];
|
|
|
|
+
|
|
BoneTransform[bone].rotation = FlipRotation(singleRotations[i]);
|
|
BoneTransform[bone].rotation = FlipRotation(singleRotations[i]);
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < pair.Length; i += 2)
|
|
|
|
|
|
+ for (var i = 0; i < pair.Length; i += 2)
|
|
{
|
|
{
|
|
- Bone boneA = pair[i];
|
|
|
|
- Bone boneB = pair[i + 1];
|
|
|
|
|
|
+ var boneA = pair[i];
|
|
|
|
+ var boneB = pair[i + 1];
|
|
|
|
+
|
|
BoneTransform[boneA].rotation = FlipRotation(pairRotations[i + 1]);
|
|
BoneTransform[boneA].rotation = FlipRotation(pairRotations[i + 1]);
|
|
BoneTransform[boneB].rotation = FlipRotation(pairRotations[i]);
|
|
BoneTransform[boneB].rotation = FlipRotation(pairRotations[i]);
|
|
}
|
|
}
|
|
|
|
|
|
- byte[] leftHand = SerializeHand(right: false);
|
|
|
|
- byte[] rightHand = SerializeHand(right: true);
|
|
|
|
|
|
+ var leftHand = SerializeHand(right: false);
|
|
|
|
+ var rightHand = SerializeHand(right: true);
|
|
|
|
+
|
|
DeserializeHand(leftHand, right: true, true);
|
|
DeserializeHand(leftHand, right: true, true);
|
|
DeserializeHand(rightHand, right: false, true);
|
|
DeserializeHand(rightHand, right: false, true);
|
|
|
|
+
|
|
leftHand = SerializeFoot(right: false);
|
|
leftHand = SerializeFoot(right: false);
|
|
rightHand = SerializeFoot(right: true);
|
|
rightHand = SerializeFoot(right: true);
|
|
|
|
+
|
|
DeserializeFoot(leftHand, right: true, true);
|
|
DeserializeFoot(leftHand, right: true, true);
|
|
DeserializeFoot(rightHand, right: false, true);
|
|
DeserializeFoot(rightHand, right: false, true);
|
|
}
|
|
}
|
|
|
|
|
|
- private Quaternion FlipRotation(Vector3 rotation)
|
|
|
|
- {
|
|
|
|
- return Quaternion.Euler(360f - rotation.x, 360f - (rotation.y + 90f) - 90f, rotation.z);
|
|
|
|
- }
|
|
|
|
|
|
+ public Transform GetAttachPointTransform(AttachPoint point) =>
|
|
|
|
+ point == AttachPoint.None ? null : BoneTransform[PointToBone[point]];
|
|
|
|
|
|
public byte[] SerializeHand(bool right)
|
|
public byte[] SerializeHand(bool right)
|
|
{
|
|
{
|
|
- Bone start = right ? Bone.Finger0R : Bone.Finger0L;
|
|
|
|
- Bone end = right ? Bone.Finger4R : Bone.Finger4L;
|
|
|
|
|
|
+ var start = right ? Bone.Finger0R : Bone.Finger0L;
|
|
|
|
+ var end = right ? Bone.Finger4R : Bone.Finger4L;
|
|
|
|
+
|
|
return SerializeFinger(start, end);
|
|
return SerializeFinger(start, end);
|
|
}
|
|
}
|
|
|
|
|
|
public void DeserializeHand(byte[] handBinary, bool right, bool mirroring = false)
|
|
public void DeserializeHand(byte[] handBinary, bool right, bool mirroring = false)
|
|
{
|
|
{
|
|
- Bone start = right ? Bone.Finger0R : Bone.Finger0L;
|
|
|
|
- Bone end = right ? Bone.Finger4R : Bone.Finger4L;
|
|
|
|
|
|
+ var start = right ? Bone.Finger0R : Bone.Finger0L;
|
|
|
|
+ var end = right ? Bone.Finger4R : Bone.Finger4L;
|
|
|
|
+
|
|
DeserializeFinger(start, end, handBinary, mirroring);
|
|
DeserializeFinger(start, end, handBinary, mirroring);
|
|
}
|
|
}
|
|
|
|
|
|
public byte[] SerializeFoot(bool right)
|
|
public byte[] SerializeFoot(bool right)
|
|
{
|
|
{
|
|
- Bone start = right ? Bone.Toe0R : Bone.Toe0L;
|
|
|
|
- Bone end = right ? Bone.Toe2R : Bone.Toe2L;
|
|
|
|
|
|
+ var start = right ? Bone.Toe0R : Bone.Toe0L;
|
|
|
|
+ var end = right ? Bone.Toe2R : Bone.Toe2L;
|
|
|
|
+
|
|
return SerializeFinger(start, end);
|
|
return SerializeFinger(start, end);
|
|
}
|
|
}
|
|
|
|
|
|
public void DeserializeFoot(byte[] footBinary, bool right, bool mirroring = false)
|
|
public void DeserializeFoot(byte[] footBinary, bool right, bool mirroring = false)
|
|
{
|
|
{
|
|
- Bone start = right ? Bone.Toe0R : Bone.Toe0L;
|
|
|
|
- Bone end = right ? Bone.Toe2R : Bone.Toe2L;
|
|
|
|
- DeserializeFinger(start, end, footBinary, mirroring);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private byte[] SerializeFinger(Bone start, Bone end)
|
|
|
|
- {
|
|
|
|
- int joints = BoneTransform[start].name.Split(' ')[2].StartsWith("Finger") ? 4 : 3;
|
|
|
|
-
|
|
|
|
- byte[] buf;
|
|
|
|
-
|
|
|
|
- using (MemoryStream memoryStream = new MemoryStream())
|
|
|
|
- using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
|
|
|
|
- {
|
|
|
|
- for (Bone bone = start; bone <= end; bone += joints)
|
|
|
|
- {
|
|
|
|
- for (int i = 0; i < joints - 1; i++)
|
|
|
|
- {
|
|
|
|
- binaryWriter.WriteQuaternion(BoneTransform[bone + i].localRotation);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- buf = memoryStream.ToArray();
|
|
|
|
- }
|
|
|
|
|
|
+ var start = right ? Bone.Toe0R : Bone.Toe0L;
|
|
|
|
+ var end = right ? Bone.Toe2R : Bone.Toe2L;
|
|
|
|
|
|
- return buf;
|
|
|
|
|
|
+ DeserializeFinger(start, end, footBinary, mirroring);
|
|
}
|
|
}
|
|
|
|
|
|
- private void DeserializeFinger(Bone start, Bone end, byte[] fingerBinary, bool mirroring = false)
|
|
|
|
|
|
+ public void Destroy()
|
|
{
|
|
{
|
|
- int joints = BoneTransform[start].name.Split(' ')[2].StartsWith("Finger") ? 4 : 3;
|
|
|
|
-
|
|
|
|
- int mirror = mirroring ? -1 : 1;
|
|
|
|
|
|
+ foreach (var dragPoint in DragPoints.Values)
|
|
|
|
+ if (dragPoint != null)
|
|
|
|
+ UnityEngine.Object.Destroy(dragPoint.gameObject);
|
|
|
|
|
|
- using MemoryStream memoryStream = new MemoryStream(fingerBinary);
|
|
|
|
- using BinaryReader binaryReader = new BinaryReader(memoryStream);
|
|
|
|
|
|
+ if (dragCube != null)
|
|
|
|
+ UnityEngine.Object.Destroy(dragCube.gameObject);
|
|
|
|
|
|
- for (Bone bone = start; bone <= end; bone += joints)
|
|
|
|
- {
|
|
|
|
- for (int i = 0; i < joints - 1; i++)
|
|
|
|
- {
|
|
|
|
- BoneTransform[bone + i].localRotation = new Quaternion
|
|
|
|
- (
|
|
|
|
- binaryReader.ReadSingle() * mirror,
|
|
|
|
- binaryReader.ReadSingle() * mirror,
|
|
|
|
- binaryReader.ReadSingle(),
|
|
|
|
- binaryReader.ReadSingle()
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (dragBody != null)
|
|
|
|
+ UnityEngine.Object.Destroy(dragBody.gameObject);
|
|
|
|
|
|
- public void Destroy()
|
|
|
|
- {
|
|
|
|
- foreach (DragPointMeido dragPoint in DragPoints.Values)
|
|
|
|
- {
|
|
|
|
- if (dragPoint != null)
|
|
|
|
- {
|
|
|
|
- GameObject.Destroy(dragPoint.gameObject);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (dragCube != null) GameObject.Destroy(dragCube.gameObject);
|
|
|
|
- if (dragBody != null) GameObject.Destroy(dragBody.gameObject);
|
|
|
|
BoneTransform.Clear();
|
|
BoneTransform.Clear();
|
|
DragPoints.Clear();
|
|
DragPoints.Clear();
|
|
CubeActiveChange -= OnCubeActive;
|
|
CubeActiveChange -= OnCubeActive;
|
|
@@ -373,15 +396,81 @@ namespace MeidoPhotoStudio.Plugin
|
|
|
|
|
|
public void Initialize()
|
|
public void Initialize()
|
|
{
|
|
{
|
|
- if (initialized) return;
|
|
|
|
|
|
+ if (initialized)
|
|
|
|
+ return;
|
|
|
|
+
|
|
initialized = true;
|
|
initialized = true;
|
|
CubeActiveChange += OnCubeActive;
|
|
CubeActiveChange += OnCubeActive;
|
|
CubeSmallChange += OnCubeSmall;
|
|
CubeSmallChange += OnCubeSmall;
|
|
|
|
+
|
|
InitializeBones();
|
|
InitializeBones();
|
|
InitializeDragPoints();
|
|
InitializeDragPoints();
|
|
SetDragPointScale(meido.Maid.transform.localScale.x);
|
|
SetDragPointScale(meido.Maid.transform.localScale.x);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void SetDragPointScale(float scale)
|
|
|
|
+ {
|
|
|
|
+ foreach (var dragPoint in DragPoints.Values)
|
|
|
|
+ dragPoint.DragPointScale = scale;
|
|
|
|
+
|
|
|
|
+ dragBody.DragPointScale = scale;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ Somebody smarter than me please help me find a way to do this better T_T
|
|
|
|
+ inb4 for loop.
|
|
|
|
+ */
|
|
|
|
+ private System.Collections.IEnumerator ApplyHipPosition(Vector3 hipPosition)
|
|
|
|
+ {
|
|
|
|
+ BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
+
|
|
|
|
+ yield return new WaitForEndOfFrame();
|
|
|
|
+
|
|
|
|
+ BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
+
|
|
|
|
+ yield return new WaitForEndOfFrame();
|
|
|
|
+
|
|
|
|
+ BoneTransform[Bone.Hip].position = hipPosition;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Quaternion FlipRotation(Vector3 rotation) =>
|
|
|
|
+ Quaternion.Euler(360f - rotation.x, 360f - (rotation.y + 90f) - 90f, rotation.z);
|
|
|
|
+
|
|
|
|
+ private byte[] SerializeFinger(Bone start, Bone end)
|
|
|
|
+ {
|
|
|
|
+ var joints = BoneTransform[start].name.Split(' ')[2].StartsWith("Finger") ? 4 : 3;
|
|
|
|
+
|
|
|
|
+ byte[] buf;
|
|
|
|
+
|
|
|
|
+ using var memoryStream = new MemoryStream();
|
|
|
|
+ using var binaryWriter = new BinaryWriter(memoryStream);
|
|
|
|
+
|
|
|
|
+ for (var bone = start; bone <= end; bone += joints)
|
|
|
|
+ for (var i = 0; i < joints - 1; i++)
|
|
|
|
+ binaryWriter.WriteQuaternion(BoneTransform[bone + i].localRotation);
|
|
|
|
+
|
|
|
|
+ buf = memoryStream.ToArray();
|
|
|
|
+
|
|
|
|
+ return buf;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void DeserializeFinger(Bone start, Bone end, byte[] fingerBinary, bool mirroring = false)
|
|
|
|
+ {
|
|
|
|
+ var joints = BoneTransform[start].name.Split(' ')[2].StartsWith("Finger") ? 4 : 3;
|
|
|
|
+ var mirror = mirroring ? -1 : 1;
|
|
|
|
+
|
|
|
|
+ using var memoryStream = new MemoryStream(fingerBinary);
|
|
|
|
+ using var binaryReader = new BinaryReader(memoryStream);
|
|
|
|
+
|
|
|
|
+ for (var bone = start; bone <= end; bone += joints)
|
|
|
|
+ for (var i = 0; i < joints - 1; i++)
|
|
|
|
+ BoneTransform[bone + i].localRotation =
|
|
|
|
+ new(
|
|
|
|
+ binaryReader.ReadSingle() * mirror, binaryReader.ReadSingle() * mirror,
|
|
|
|
+ binaryReader.ReadSingle(), binaryReader.ReadSingle()
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
private void InitializeDragPoints()
|
|
private void InitializeDragPoints()
|
|
{
|
|
{
|
|
dragCube = DragPoint.Make<DragPointBody>(PrimitiveType.Cube, Vector3.one * 0.12f);
|
|
dragCube = DragPoint.Make<DragPointBody>(PrimitiveType.Cube, Vector3.one * 0.12f);
|
|
@@ -395,6 +484,7 @@ namespace MeidoPhotoStudio.Plugin
|
|
dragCube.gameObject.SetActive(CubeActive);
|
|
dragCube.gameObject.SetActive(CubeActive);
|
|
|
|
|
|
dragBody = DragPoint.Make<DragPointBody>(PrimitiveType.Capsule, new Vector3(0.2f, 0.3f, 0.24f));
|
|
dragBody = DragPoint.Make<DragPointBody>(PrimitiveType.Capsule, new Vector3(0.2f, 0.3f, 0.24f));
|
|
|
|
+
|
|
dragBody.Initialize(
|
|
dragBody.Initialize(
|
|
() => new Vector3(
|
|
() => new Vector3(
|
|
(BoneTransform[Bone.Hip].position.x + BoneTransform[Bone.Spine0a].position.x) / 2f,
|
|
(BoneTransform[Bone.Hip].position.x + BoneTransform[Bone.Spine0a].position.x) / 2f,
|
|
@@ -407,18 +497,20 @@ namespace MeidoPhotoStudio.Plugin
|
|
BoneTransform[Bone.Spine0a].eulerAngles.z + 90f
|
|
BoneTransform[Bone.Spine0a].eulerAngles.z + 90f
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
+
|
|
dragBody.Set(meido.Maid.transform);
|
|
dragBody.Set(meido.Maid.transform);
|
|
dragBody.Select += OnSelectBody;
|
|
dragBody.Select += OnSelectBody;
|
|
dragBody.EndScale += OnSetDragPointScale;
|
|
dragBody.EndScale += OnSetDragPointScale;
|
|
|
|
|
|
// Neck Dragpoint
|
|
// Neck Dragpoint
|
|
- DragPointHead dragNeck = DragPoint.Make<DragPointHead>(
|
|
|
|
|
|
+ var dragNeck = DragPoint.Make<DragPointHead>(
|
|
PrimitiveType.Sphere, new Vector3(0.2f, 0.24f, 0.2f)
|
|
PrimitiveType.Sphere, new Vector3(0.2f, 0.24f, 0.2f)
|
|
);
|
|
);
|
|
|
|
+
|
|
dragNeck.Initialize(meido,
|
|
dragNeck.Initialize(meido,
|
|
() => new Vector3(
|
|
() => new Vector3(
|
|
BoneTransform[Bone.Head].position.x,
|
|
BoneTransform[Bone.Head].position.x,
|
|
- ((BoneTransform[Bone.Head].position.y * 1.2f) + (BoneTransform[Bone.HeadNub].position.y * 0.8f)) / 2f,
|
|
|
|
|
|
+ (BoneTransform[Bone.Head].position.y * 1.2f + BoneTransform[Bone.HeadNub].position.y * 0.8f) / 2f,
|
|
BoneTransform[Bone.Head].position.z
|
|
BoneTransform[Bone.Head].position.z
|
|
),
|
|
),
|
|
() => new Vector3(
|
|
() => new Vector3(
|
|
@@ -427,13 +519,15 @@ namespace MeidoPhotoStudio.Plugin
|
|
BoneTransform[Bone.Head].eulerAngles.z + 90f
|
|
BoneTransform[Bone.Head].eulerAngles.z + 90f
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
+
|
|
dragNeck.Set(BoneTransform[Bone.Neck]);
|
|
dragNeck.Set(BoneTransform[Bone.Neck]);
|
|
dragNeck.Select += OnSelectFace;
|
|
dragNeck.Select += OnSelectFace;
|
|
|
|
|
|
DragPoints[Bone.Head] = dragNeck;
|
|
DragPoints[Bone.Head] = dragNeck;
|
|
|
|
|
|
// Head Dragpoint
|
|
// Head Dragpoint
|
|
- DragPointSpine dragHead = DragPoint.Make<DragPointSpine>(PrimitiveType.Sphere, Vector3.one * 0.045f);
|
|
|
|
|
|
+ var dragHead = DragPoint.Make<DragPointSpine>(PrimitiveType.Sphere, Vector3.one * 0.045f);
|
|
|
|
+
|
|
dragHead.Initialize(meido, () => BoneTransform[Bone.Head].position, () => Vector3.zero);
|
|
dragHead.Initialize(meido, () => BoneTransform[Bone.Head].position, () => Vector3.zero);
|
|
dragHead.Set(BoneTransform[Bone.Head]);
|
|
dragHead.Set(BoneTransform[Bone.Head]);
|
|
dragHead.AddGizmo();
|
|
dragHead.AddGizmo();
|
|
@@ -441,12 +535,13 @@ namespace MeidoPhotoStudio.Plugin
|
|
DragPoints[Bone.HeadNub] = dragHead;
|
|
DragPoints[Bone.HeadNub] = dragHead;
|
|
|
|
|
|
// Torso Dragpoint
|
|
// Torso Dragpoint
|
|
- Transform spineTrans1 = BoneTransform[Bone.Spine1];
|
|
|
|
- Transform spineTrans2 = BoneTransform[Bone.Spine1a];
|
|
|
|
|
|
+ var spineTrans1 = BoneTransform[Bone.Spine1];
|
|
|
|
+ var spineTrans2 = BoneTransform[Bone.Spine1a];
|
|
|
|
|
|
- DragPointTorso dragTorso = DragPoint.Make<DragPointTorso>(
|
|
|
|
|
|
+ var dragTorso = DragPoint.Make<DragPointTorso>(
|
|
PrimitiveType.Capsule, new Vector3(0.2f, 0.19f, 0.24f)
|
|
PrimitiveType.Capsule, new Vector3(0.2f, 0.19f, 0.24f)
|
|
);
|
|
);
|
|
|
|
+
|
|
dragTorso.Initialize(meido,
|
|
dragTorso.Initialize(meido,
|
|
() => new Vector3(
|
|
() => new Vector3(
|
|
spineTrans1.position.x,
|
|
spineTrans1.position.x,
|
|
@@ -459,15 +554,16 @@ namespace MeidoPhotoStudio.Plugin
|
|
spineTrans1.eulerAngles.z + 90f
|
|
spineTrans1.eulerAngles.z + 90f
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
+
|
|
dragTorso.Set(BoneTransform[Bone.Spine1a]);
|
|
dragTorso.Set(BoneTransform[Bone.Spine1a]);
|
|
|
|
|
|
DragPoints[Bone.Torso] = dragTorso;
|
|
DragPoints[Bone.Torso] = dragTorso;
|
|
|
|
|
|
// Pelvis Dragpoint
|
|
// Pelvis Dragpoint
|
|
- Transform pelvisTrans = BoneTransform[Bone.Pelvis];
|
|
|
|
- Transform spineTrans = BoneTransform[Bone.Spine];
|
|
|
|
|
|
+ var pelvisTrans = BoneTransform[Bone.Pelvis];
|
|
|
|
+ var spineTrans = BoneTransform[Bone.Spine];
|
|
|
|
|
|
- DragPointPelvis dragPelvis = DragPoint.Make<DragPointPelvis>(
|
|
|
|
|
|
+ var dragPelvis = DragPoint.Make<DragPointPelvis>(
|
|
PrimitiveType.Capsule, new Vector3(0.2f, 0.15f, 0.24f)
|
|
PrimitiveType.Capsule, new Vector3(0.2f, 0.15f, 0.24f)
|
|
);
|
|
);
|
|
dragPelvis.Initialize(meido,
|
|
dragPelvis.Initialize(meido,
|
|
@@ -491,20 +587,24 @@ namespace MeidoPhotoStudio.Plugin
|
|
InitializeMuneDragPoint(left: false);
|
|
InitializeMuneDragPoint(left: false);
|
|
|
|
|
|
var armDragPointL = MakeArmChain(BoneTransform[Bone.HandL], meido);
|
|
var armDragPointL = MakeArmChain(BoneTransform[Bone.HandL], meido);
|
|
|
|
+
|
|
DragPoints[Bone.UpperArmL] = armDragPointL[0];
|
|
DragPoints[Bone.UpperArmL] = armDragPointL[0];
|
|
DragPoints[Bone.ForearmL] = armDragPointL[1];
|
|
DragPoints[Bone.ForearmL] = armDragPointL[1];
|
|
DragPoints[Bone.HandL] = armDragPointL[2];
|
|
DragPoints[Bone.HandL] = armDragPointL[2];
|
|
|
|
|
|
var armDragPointR = MakeArmChain(BoneTransform[Bone.HandR], meido);
|
|
var armDragPointR = MakeArmChain(BoneTransform[Bone.HandR], meido);
|
|
|
|
+
|
|
DragPoints[Bone.UpperArmR] = armDragPointR[0];
|
|
DragPoints[Bone.UpperArmR] = armDragPointR[0];
|
|
DragPoints[Bone.ForearmR] = armDragPointR[1];
|
|
DragPoints[Bone.ForearmR] = armDragPointR[1];
|
|
DragPoints[Bone.HandR] = armDragPointR[2];
|
|
DragPoints[Bone.HandR] = armDragPointR[2];
|
|
|
|
|
|
var legDragPointL = MakeLegChain(BoneTransform[Bone.FootL]);
|
|
var legDragPointL = MakeLegChain(BoneTransform[Bone.FootL]);
|
|
|
|
+
|
|
DragPoints[Bone.CalfL] = legDragPointL[0];
|
|
DragPoints[Bone.CalfL] = legDragPointL[0];
|
|
DragPoints[Bone.FootL] = legDragPointL[1];
|
|
DragPoints[Bone.FootL] = legDragPointL[1];
|
|
|
|
|
|
var legDragPointR = MakeLegChain(BoneTransform[Bone.FootR]);
|
|
var legDragPointR = MakeLegChain(BoneTransform[Bone.FootR]);
|
|
|
|
+
|
|
DragPoints[Bone.CalfR] = legDragPointR[0];
|
|
DragPoints[Bone.CalfR] = legDragPointR[0];
|
|
DragPoints[Bone.FootR] = legDragPointR[1];
|
|
DragPoints[Bone.FootR] = legDragPointR[1];
|
|
|
|
|
|
@@ -512,8 +612,8 @@ namespace MeidoPhotoStudio.Plugin
|
|
|
|
|
|
for (var bone = Bone.Finger4NubR; bone >= Bone.Finger0L; bone -= 4)
|
|
for (var bone = Bone.Finger4NubR; bone >= Bone.Finger0L; bone -= 4)
|
|
{
|
|
{
|
|
- var i = 2;
|
|
|
|
var chain = MakeFingerChain(BoneTransform[bone], meido);
|
|
var chain = MakeFingerChain(BoneTransform[bone], meido);
|
|
|
|
+ var i = 2;
|
|
|
|
|
|
for (var joint = bone - 1; joint > bone - 4; joint--)
|
|
for (var joint = bone - 1; joint > bone - 4; joint--)
|
|
{
|
|
{
|
|
@@ -521,59 +621,40 @@ namespace MeidoPhotoStudio.Plugin
|
|
i--;
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
MakeToeChain(Bone.Toe0L, Bone.Toe2R);
|
|
MakeToeChain(Bone.Toe0L, Bone.Toe2R);
|
|
}
|
|
}
|
|
|
|
|
|
private void InitializeMuneDragPoint(bool left)
|
|
private void InitializeMuneDragPoint(bool left)
|
|
{
|
|
{
|
|
- Bone mune = left ? Bone.MuneL : Bone.MuneR;
|
|
|
|
- Bone sub = left ? Bone.MuneSubL : Bone.MuneSubR;
|
|
|
|
- DragPointMune muneDragPoint = DragPoint.Make<DragPointMune>(PrimitiveType.Sphere, Vector3.one * 0.12f);
|
|
|
|
|
|
+ var mune = left ? Bone.MuneL : Bone.MuneR;
|
|
|
|
+ var sub = left ? Bone.MuneSubL : Bone.MuneSubR;
|
|
|
|
+ var muneDragPoint = DragPoint.Make<DragPointMune>(PrimitiveType.Sphere, Vector3.one * 0.12f);
|
|
|
|
+
|
|
muneDragPoint.Initialize(meido,
|
|
muneDragPoint.Initialize(meido,
|
|
() => (BoneTransform[mune].position + BoneTransform[sub].position) / 2f,
|
|
() => (BoneTransform[mune].position + BoneTransform[sub].position) / 2f,
|
|
() => Vector3.zero
|
|
() => Vector3.zero
|
|
);
|
|
);
|
|
|
|
+
|
|
muneDragPoint.Set(BoneTransform[sub]);
|
|
muneDragPoint.Set(BoneTransform[sub]);
|
|
DragPoints[mune] = muneDragPoint;
|
|
DragPoints[mune] = muneDragPoint;
|
|
}
|
|
}
|
|
|
|
|
|
private DragPointLimb[] MakeLegChain(Transform lower)
|
|
private DragPointLimb[] MakeLegChain(Transform lower)
|
|
{
|
|
{
|
|
- Vector3 limbDragPointSize = Vector3.one * 0.12f;
|
|
|
|
- DragPointLimb[] dragPoints = new DragPointLimb[2];
|
|
|
|
- for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
|
|
- {
|
|
|
|
- Transform joint = lower;
|
|
|
|
- dragPoints[i] = DragPoint.Make<DragPointLimb>(PrimitiveType.Sphere, limbDragPointSize);
|
|
|
|
- dragPoints[i].Initialize(meido, () => joint.position, () => Vector3.zero);
|
|
|
|
- dragPoints[i].Set(joint);
|
|
|
|
- dragPoints[i].AddGizmo();
|
|
|
|
- lower = lower.parent;
|
|
|
|
- }
|
|
|
|
- return dragPoints;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private static DragPointLimb[] MakeArmChain(Transform lower, Meido meido)
|
|
|
|
- {
|
|
|
|
var limbDragPointSize = Vector3.one * 0.12f;
|
|
var limbDragPointSize = Vector3.one * 0.12f;
|
|
|
|
|
|
- var realLower = CMT.SearchObjName(meido.Body.goSlot[0].obj_tr, lower.name, false);
|
|
|
|
-
|
|
|
|
- var dragPoints = new DragPointLimb[3];
|
|
|
|
|
|
+ var dragPoints = new DragPointLimb[2];
|
|
|
|
|
|
for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
{
|
|
{
|
|
var joint = lower;
|
|
var joint = lower;
|
|
- var positionJoint = realLower;
|
|
|
|
|
|
|
|
dragPoints[i] = DragPoint.Make<DragPointLimb>(PrimitiveType.Sphere, limbDragPointSize);
|
|
dragPoints[i] = DragPoint.Make<DragPointLimb>(PrimitiveType.Sphere, limbDragPointSize);
|
|
- dragPoints[i].Initialize(meido, () => positionJoint.position, () => Vector3.zero);
|
|
|
|
|
|
+ dragPoints[i].Initialize(meido, () => joint.position, () => Vector3.zero);
|
|
dragPoints[i].Set(joint);
|
|
dragPoints[i].Set(joint);
|
|
dragPoints[i].AddGizmo();
|
|
dragPoints[i].AddGizmo();
|
|
- dragPoints[i].Gizmo.SetAlternateTarget(positionJoint);
|
|
|
|
-
|
|
|
|
lower = lower.parent;
|
|
lower = lower.parent;
|
|
- realLower = realLower.parent;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return dragPoints;
|
|
return dragPoints;
|
|
@@ -581,14 +662,17 @@ namespace MeidoPhotoStudio.Plugin
|
|
|
|
|
|
private void MakeToeChain(Bone start, Bone end)
|
|
private void MakeToeChain(Bone start, Bone end)
|
|
{
|
|
{
|
|
- Vector3 fingerDragPointSize = Vector3.one * 0.01f;
|
|
|
|
const int joints = 3;
|
|
const int joints = 3;
|
|
- for (Bone bone = start; bone <= end; bone += joints)
|
|
|
|
|
|
+
|
|
|
|
+ var fingerDragPointSize = Vector3.one * 0.01f;
|
|
|
|
+
|
|
|
|
+ for (var bone = start; bone <= end; bone += joints)
|
|
{
|
|
{
|
|
- for (int i = 1; i < joints; i++)
|
|
|
|
|
|
+ for (var i = 1; i < joints; i++)
|
|
{
|
|
{
|
|
- Transform trans = BoneTransform[bone + i];
|
|
|
|
- DragPointFinger chain = DragPoint.Make<DragPointFinger>(PrimitiveType.Sphere, fingerDragPointSize);
|
|
|
|
|
|
+ var trans = BoneTransform[bone + i];
|
|
|
|
+ var chain = DragPoint.Make<DragPointFinger>(PrimitiveType.Sphere, fingerDragPointSize);
|
|
|
|
+
|
|
chain.Initialize(meido, () => trans.position, () => Vector3.zero);
|
|
chain.Initialize(meido, () => trans.position, () => Vector3.zero);
|
|
chain.Set(trans);
|
|
chain.Set(trans);
|
|
DragPoints[bone + i] = chain;
|
|
DragPoints[bone + i] = chain;
|
|
@@ -596,42 +680,21 @@ namespace MeidoPhotoStudio.Plugin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private static DragPointFinger[] MakeFingerChain(Transform lower, Meido meido)
|
|
|
|
|
|
+ private void InitializeSpineDragPoint(params Bone[] bones)
|
|
{
|
|
{
|
|
- var fingerDragPointSize = Vector3.one * 0.01f;
|
|
|
|
|
|
+ var spineDragPointSize = DragPointMeido.boneScale;
|
|
|
|
|
|
- var dragPoints = new DragPointFinger[3];
|
|
|
|
-
|
|
|
|
- var realLower = CMT.SearchObjName(meido.Body.goSlot[0].obj_tr, lower.parent.name, false);
|
|
|
|
-
|
|
|
|
- for (var i = dragPoints.Length - 1; i >= 0; i--)
|
|
|
|
|
|
+ foreach (var bone in bones)
|
|
{
|
|
{
|
|
- var joint = lower;
|
|
|
|
- var positionJoint = realLower;
|
|
|
|
-
|
|
|
|
- dragPoints[i] = DragPoint.Make<DragPointFinger>(PrimitiveType.Sphere, fingerDragPointSize);
|
|
|
|
- dragPoints[i].Initialize(meido, () => positionJoint.position, () => Vector3.zero);
|
|
|
|
- dragPoints[i].Set(joint);
|
|
|
|
|
|
+ var spine = BoneTransform[bone];
|
|
|
|
+ var primitive = bone == Bone.Hip ? PrimitiveType.Cube : PrimitiveType.Sphere;
|
|
|
|
+ var dragPoint = DragPoint.Make<DragPointSpine>(primitive, spineDragPointSize);
|
|
|
|
|
|
- lower = lower.parent;
|
|
|
|
- realLower = realLower.parent;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return dragPoints;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void InitializeSpineDragPoint(params Bone[] bones)
|
|
|
|
- {
|
|
|
|
- Vector3 spineDragPointSize = DragPointMeido.boneScale;
|
|
|
|
- foreach (Bone bone in bones)
|
|
|
|
- {
|
|
|
|
- Transform spine = BoneTransform[bone];
|
|
|
|
- PrimitiveType primitive = bone == Bone.Hip ? PrimitiveType.Cube : PrimitiveType.Sphere;
|
|
|
|
- DragPointSpine dragPoint = DragPoint.Make<DragPointSpine>(primitive, spineDragPointSize);
|
|
|
|
dragPoint.Initialize(meido,
|
|
dragPoint.Initialize(meido,
|
|
() => spine.position,
|
|
() => spine.position,
|
|
() => Vector3.zero
|
|
() => Vector3.zero
|
|
);
|
|
);
|
|
|
|
+
|
|
dragPoint.Set(spine);
|
|
dragPoint.Set(spine);
|
|
dragPoint.AddGizmo();
|
|
dragPoint.AddGizmo();
|
|
DragPoints[bone] = dragPoint;
|
|
DragPoints[bone] = dragPoint;
|
|
@@ -639,42 +702,27 @@ namespace MeidoPhotoStudio.Plugin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void OnCubeActive(object sender, EventArgs args)
|
|
|
|
- {
|
|
|
|
|
|
+ private void OnCubeActive(object sender, EventArgs args) =>
|
|
dragCube.gameObject.SetActive(CubeActive);
|
|
dragCube.gameObject.SetActive(CubeActive);
|
|
- }
|
|
|
|
|
|
|
|
- private void OnCubeSmall(object sender, EventArgs args)
|
|
|
|
- {
|
|
|
|
|
|
+ private void OnCubeSmall(object sender, EventArgs args) =>
|
|
dragCube.DragPointScale = CubeSmall ? DragPointGeneral.smallCube : 1f;
|
|
dragCube.DragPointScale = CubeSmall ? DragPointGeneral.smallCube : 1f;
|
|
- }
|
|
|
|
|
|
|
|
- private void OnSetDragPointScale(object sender, EventArgs args)
|
|
|
|
- {
|
|
|
|
|
|
+ private void OnSetDragPointScale(object sender, EventArgs args) =>
|
|
SetDragPointScale(meido.Maid.transform.localScale.x);
|
|
SetDragPointScale(meido.Maid.transform.localScale.x);
|
|
- }
|
|
|
|
|
|
|
|
- private void OnSelectBody(object sender, EventArgs args)
|
|
|
|
- {
|
|
|
|
|
|
+ private void OnSelectBody(object sender, EventArgs args) =>
|
|
SelectMaid?.Invoke(this, new MeidoUpdateEventArgs(meido.Slot, fromMaid: true, isBody: true));
|
|
SelectMaid?.Invoke(this, new MeidoUpdateEventArgs(meido.Slot, fromMaid: true, isBody: true));
|
|
- }
|
|
|
|
|
|
|
|
- private void OnSelectFace(object sender, EventArgs args)
|
|
|
|
- {
|
|
|
|
|
|
+ private void OnSelectFace(object sender, EventArgs args) =>
|
|
SelectMaid?.Invoke(this, new MeidoUpdateEventArgs(meido.Slot, fromMaid: true, isBody: false));
|
|
SelectMaid?.Invoke(this, new MeidoUpdateEventArgs(meido.Slot, fromMaid: true, isBody: false));
|
|
- }
|
|
|
|
-
|
|
|
|
- public void SetDragPointScale(float scale)
|
|
|
|
- {
|
|
|
|
- foreach (DragPointMeido dragPoint in DragPoints.Values) dragPoint.DragPointScale = scale;
|
|
|
|
- dragBody.DragPointScale = scale;
|
|
|
|
- }
|
|
|
|
|
|
|
|
private void InitializeBones()
|
|
private void InitializeBones()
|
|
{
|
|
{
|
|
// TODO: Move to external file somehow
|
|
// TODO: Move to external file somehow
|
|
- Transform transform = meido.Body.m_Bones.transform;
|
|
|
|
- BoneTransform = new Dictionary<Bone, Transform>()
|
|
|
|
|
|
+ var transform = meido.Body.m_Bones.transform;
|
|
|
|
+
|
|
|
|
+ BoneTransform = new()
|
|
{
|
|
{
|
|
[Bone.Head] = CMT.SearchObjName(transform, "Bip01 Head"),
|
|
[Bone.Head] = CMT.SearchObjName(transform, "Bip01 Head"),
|
|
[Bone.Neck] = CMT.SearchObjName(transform, "Bip01 Neck"),
|
|
[Bone.Neck] = CMT.SearchObjName(transform, "Bip01 Neck"),
|
|
@@ -771,27 +819,27 @@ namespace MeidoPhotoStudio.Plugin
|
|
|
|
|
|
public readonly struct AttachPointInfo
|
|
public readonly struct AttachPointInfo
|
|
{
|
|
{
|
|
- private readonly AttachPoint attachPoint;
|
|
|
|
- public AttachPoint AttachPoint => attachPoint;
|
|
|
|
- public string MaidGuid { get; }
|
|
|
|
-
|
|
|
|
- private readonly int maidIndex;
|
|
|
|
- public int MaidIndex => maidIndex;
|
|
|
|
private static readonly AttachPointInfo empty = new(AttachPoint.None, string.Empty, -1);
|
|
private static readonly AttachPointInfo empty = new(AttachPoint.None, string.Empty, -1);
|
|
- public static ref readonly AttachPointInfo Empty => ref empty;
|
|
|
|
|
|
+
|
|
|
|
+ public AttachPoint AttachPoint { get; }
|
|
|
|
+ public string MaidGuid { get; }
|
|
|
|
+ public int MaidIndex { get; }
|
|
|
|
+
|
|
|
|
+ public static ref readonly AttachPointInfo Empty =>
|
|
|
|
+ ref empty;
|
|
|
|
|
|
public AttachPointInfo(AttachPoint attachPoint, Meido meido)
|
|
public AttachPointInfo(AttachPoint attachPoint, Meido meido)
|
|
{
|
|
{
|
|
- this.attachPoint = attachPoint;
|
|
|
|
|
|
+ AttachPoint = attachPoint;
|
|
MaidGuid = meido.Maid.status.guid;
|
|
MaidGuid = meido.Maid.status.guid;
|
|
- maidIndex = meido.Slot;
|
|
|
|
|
|
+ MaidIndex = meido.Slot;
|
|
}
|
|
}
|
|
|
|
|
|
public AttachPointInfo(AttachPoint attachPoint, string maidGuid, int maidIndex)
|
|
public AttachPointInfo(AttachPoint attachPoint, string maidGuid, int maidIndex)
|
|
{
|
|
{
|
|
- this.attachPoint = attachPoint;
|
|
|
|
|
|
+ AttachPoint = attachPoint;
|
|
MaidGuid = maidGuid;
|
|
MaidGuid = maidGuid;
|
|
- this.maidIndex = maidIndex;
|
|
|
|
|
|
+ MaidIndex = maidIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|