mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Keyframe stretching plus appendage manipulation
This commit is contained in:
parent
18c0473f39
commit
1af7f41d63
427 changed files with 7003 additions and 1147 deletions
|
@ -26,6 +26,8 @@ namespace RimWorldAnimationStudio
|
|||
public ActorCard actorCard;
|
||||
public Transform animationTimelines;
|
||||
public Transform actorBodies;
|
||||
public Toggle stretchkeyframesToggle;
|
||||
|
||||
|
||||
[Header("Prefabs")]
|
||||
public ActorBody actorBodyPrefab;
|
||||
|
@ -151,14 +153,20 @@ namespace RimWorldAnimationStudio
|
|||
Vector3 bodyPos = new Vector3(deltaPos.x, deltaPos.z, 0);
|
||||
Vector3 headPos = new Vector3(headBob.x, headBob.z, 0);
|
||||
|
||||
Vector3 appendagePos = PawnUtility.AppendageOffsetAt(bodyType, bodyFacing);
|
||||
|
||||
actorBody.transform.position = bodyPos;
|
||||
actorBody.transform.eulerAngles = new Vector3(0, 0, bodyAngle);
|
||||
|
||||
actorBody.headRenderer.transform.localPosition = headPos;
|
||||
actorBody.headRenderer.transform.eulerAngles = new Vector3(0, 0, headAngle);
|
||||
|
||||
actorBody.appendageRenderer.transform.localPosition = new Vector3(appendagePos.x, appendagePos.z, 0f);
|
||||
actorBody.appendageRenderer.transform.eulerAngles = new Vector3(0,0,clip.GenitalAngle.Evaluate(clipPercent));
|
||||
|
||||
actorBody.bodyRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Bodies/" + bodyType + bodyFacing);
|
||||
actorBody.headRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Heads/Head" + headFacing);
|
||||
actorBody.appendageRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing);
|
||||
|
||||
actorBody.bodyRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingLayerName = clip.layer;
|
||||
|
@ -351,34 +359,58 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
int.TryParse(animationClipLengthField.text, out int newstageWindowSize);
|
||||
newstageWindowSize = Mathf.Clamp(newstageWindowSize, Constants.minAnimationClipLength, Constants.maxAnimationClipLength);
|
||||
int.TryParse(animationClipLengthField.text, out int newStageWindowSize);
|
||||
newStageWindowSize = Mathf.Clamp(newStageWindowSize, Constants.minAnimationClipLength, Constants.maxAnimationClipLength);
|
||||
|
||||
Debug.Log("Resizing animation clip length to " + newstageWindowSize.ToString() + " ticks.");
|
||||
Debug.Log("Resizing animation clip length to " + newStageWindowSize.ToString() + " ticks.");
|
||||
|
||||
for (int i = 0; i < Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Count; i++)
|
||||
if (stretchkeyframesToggle.isOn)
|
||||
{ StretchKeyframes(newStageWindowSize); }
|
||||
|
||||
else
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[i];
|
||||
List<PawnKeyframe> keyframes = clip.keyframes.Where(x => x.atTick > newstageWindowSize)?.ToList();
|
||||
for (int i = 0; i < Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Count; i++)
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[i];
|
||||
List<PawnKeyframe> keyframes = clip.keyframes.Where(x => x.atTick > newStageWindowSize)?.ToList();
|
||||
|
||||
if (keyframes.NullOrEmpty())
|
||||
{ continue; }
|
||||
if (keyframes.NullOrEmpty())
|
||||
{ continue; }
|
||||
|
||||
foreach (PawnKeyframe keyframe in keyframes)
|
||||
{
|
||||
RemovePawnKeyframe(i, keyframe.keyframeID);
|
||||
foreach (PawnKeyframe keyframe in keyframes)
|
||||
{
|
||||
RemovePawnKeyframe(i, keyframe.keyframeID);
|
||||
|
||||
if (Workspace.animationDef.animationStages[Workspace.stageID].animationClips[i].keyframes.Count <= 2)
|
||||
{ break; }
|
||||
if (Workspace.animationDef.animationStages[Workspace.stageID].animationClips[i].keyframes.Count <= 2)
|
||||
{ break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
animationClipLengthField.text = newstageWindowSize.ToString();
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].stageWindowSize = newstageWindowSize;
|
||||
animationClipLengthField.text = newStageWindowSize.ToString();
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].stageWindowSize = newStageWindowSize;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
}
|
||||
|
||||
public void StretchKeyframes(int newStageWindowSize)
|
||||
{
|
||||
float scale = (float)newStageWindowSize / Workspace.StageWindowSize;
|
||||
|
||||
foreach (PawnAnimationClip clip in Workspace.animationDef.animationStages[Workspace.stageID].animationClips)
|
||||
{
|
||||
foreach (PawnKeyframe keyframe in clip.keyframes)
|
||||
{
|
||||
if (keyframe.atTick == 1) continue;
|
||||
|
||||
keyframe.tickDuration = Mathf.RoundToInt(keyframe.tickDuration * scale);
|
||||
keyframe.atTick = null;
|
||||
}
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCycleNormalFieldChange()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue