Add animation todo to README.md

add translate x and translate y from animation step
This commit is contained in:
EliyaFishman 2022-12-03 19:47:32 +02:00
parent 870f6ff8b6
commit a4a0b31c47
4 changed files with 54 additions and 36 deletions

View file

@ -49,7 +49,6 @@ namespace Bread2Unity
AnimatorController.CreateAnimatorControllerAtPath( AnimatorController.CreateAnimatorControllerAtPath(
AssetDatabase.GenerateUniqueAssetPath( AssetDatabase.GenerateUniqueAssetPath(
$"{animationsFolderPath}/{prefabData.Name}Controller.controller")); $"{animationsFolderPath}/{prefabData.Name}Controller.controller"));
var bccadSprites = bccad.sprites;
//get all of the parts associated with the game object //get all of the parts associated with the game object
var steps = prefabData.Animations.SelectMany(animation => animation.Steps); var steps = prefabData.Animations.SelectMany(animation => animation.Steps);
@ -120,9 +119,9 @@ namespace Bread2Unity
var sprite = sprites[bccadSpritePart.RegionIndex.Index]; var sprite = sprites[bccadSpritePart.RegionIndex.Index];
var width = bccadSpritePart.StretchX / bccadPrefab.WidthRatio; var width = bccadSpritePart.StretchX / bccadPrefab.WidthRatio;
var height = bccadSpritePart.StretchY / bccadPrefab.HeightRatio; var height = bccadSpritePart.StretchY / bccadPrefab.HeightRatio;
var x = (bccadSpritePart.PosX - 512f) / var x = (bccadSpritePart.PosX + currentStep.TranslateX - 512f) /
SpriteCreator.PixelsPerUnit + sprite.bounds.size.x * 0.5f * width; SpriteCreator.PixelsPerUnit + sprite.bounds.size.x * 0.5f * width;
var y = -(bccadSpritePart.PosY - 512f) / SpriteCreator.PixelsPerUnit - var y = -(bccadSpritePart.PosY + currentStep.TranslateY- 512f) / SpriteCreator.PixelsPerUnit -
sprite.bounds.size.y * 0.5f * height; sprite.bounds.size.y * 0.5f * height;
var z = -0.00001f * partIndex; var z = -0.00001f * partIndex;
@ -176,7 +175,9 @@ namespace Bread2Unity
if ((from part in partsOfGameObject select part.RegionIndex.Index).Distinct().Count() > 1) if ((from part in partsOfGameObject select part.RegionIndex.Index).Distinct().Count() > 1)
AnimationUtility.SetObjectReferenceCurve(animationClip, spriteBinding, spriteFrames.ToArray()); AnimationUtility.SetObjectReferenceCurve(animationClip, spriteBinding, spriteFrames.ToArray());
if ((from part in partsOfGameObject select part.PosX).Distinct().Count() > 1 || if ((from part in partsOfGameObject select part.PosX).Distinct().Count() > 1 ||
(from part in partsOfGameObject select part.PosY).Distinct().Count() > 1) (from part in partsOfGameObject select part.PosY).Distinct().Count() > 1 ||
animation.Steps.Select(step => step.TranslateX).Distinct().Count() > 1 ||
animation.Steps.Select(step => step.TranslateY).Distinct().Count() > 1)
{ {
animationClip.SetCurve(child.name, typeof(Transform), "localPosition.x", xTransformCurve); animationClip.SetCurve(child.name, typeof(Transform), "localPosition.x", xTransformCurve);
animationClip.SetCurve(child.name, typeof(Transform), "localPosition.y", yTransformCurve); animationClip.SetCurve(child.name, typeof(Transform), "localPosition.y", yTransformCurve);

View file

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -12,15 +13,15 @@ namespace Bread2Unity
const string folderPath = const string folderPath =
"C:\\Users\\Eliya\\games\\3DS\\PackEnglishV12\\PackEnglishV12\\PackHack\\ExtractedRomFS\\cellanim"; "C:\\Users\\Eliya\\games\\3DS\\PackEnglishV12\\PackEnglishV12\\PackHack\\ExtractedRomFS\\cellanim";
var allFiles = Directory.GetFiles(folderPath, "*.bccad", SearchOption.AllDirectories); var allFiles = Directory.GetFiles(folderPath, "*.bccad", SearchOption.AllDirectories);
var problematicFiles = new HashSet<string>(); // var problematicFiles = new HashSet<string>();
foreach (var file in allFiles) foreach (var file in allFiles)
{ {
var bccad = BCCAD.Read(File.ReadAllBytes(file)); var bccad = BCCAD.Read(File.ReadAllBytes(file));
var name = Path.GetFileName(file); var name = Path.GetFileName(file);
for (var spriteIndex = 0; spriteIndex < bccad.sprites.Count; spriteIndex++) /*for (var spriteIndex = 0; spriteIndex < bccad.sprites.Count; spriteIndex++)
{ {
var sprite = bccad.sprites[spriteIndex]; var sprite = bccad.sprites[spriteIndex];
/*for (var partIndex = 0; partIndex < sprite.parts.Count; partIndex++) for (var partIndex = 0; partIndex < sprite.parts.Count; partIndex++)
{ {
var part = sprite.parts[partIndex]; var part = sprite.parts[partIndex];
if (part.Multicolor != Color.white) if (part.Multicolor != Color.white)
@ -28,34 +29,45 @@ namespace Bread2Unity
if (part.ScreenColor != Color.black) if (part.ScreenColor != Color.black)
Debug.Log($"screen color not black at {name} sprite: {spriteIndex} part: {partIndex}"); Debug.Log($"screen color not black at {name} sprite: {spriteIndex} part: {partIndex}");
}*/
var v = sprite.parts.GroupBy(p => p.FlipX)
.Any(a => a.Select(part => part.RegionIndex.Index).Distinct().Count() < a.Count());
// if (sprite.parts.Select(part => part.Region).Distinct().Count() < sprite.parts.Count)
if(v)
// Debug.Log($"duplicate regions {name} sprite: {spriteIndex}");
problematicFiles.Add(name);
}
/*for (var animIndex = 0; animIndex < bccad.animations.Count; animIndex++)
{
var anim = bccad.animations[animIndex];
if (anim.Interpolated) Debug.Log($"interpolated {name} anim: {animIndex}");
for (var stepIndex = 0; stepIndex < anim.Steps.Count; stepIndex++)
{
var step = anim.Steps[stepIndex];
if(step.Color != Color.white)
Debug.Log($"step color not white at {name} anim: {animIndex} step: {stepIndex}");
if (step.Opacity != 255)
Debug.Log($"step opacity not 255 at {name} anim: {animIndex} step: {stepIndex}");
} }
}*/ }*/
for (var animIndex = 0; animIndex < bccad.animations.Count; animIndex++)
{
var anim = bccad.animations[animIndex];
// if (anim.Interpolated) Debug.Log($"interpolated {name} anim: {animIndex}");
if(anim.Steps.Select(step => step.TranslateX).Distinct().Count() > 1)
Debug.Log($"translation x changes at {name} anim: {animIndex}");
if(anim.Steps.Select(step => step.TranslateY).Distinct().Count() > 1)
Debug.Log($"translation y changes at {name} anim: {animIndex}");
/*for (var stepIndex = 0; stepIndex < anim.Steps.Count; stepIndex++)
{
var step = anim.Steps[stepIndex];
/*if(step.Color != Color.white)
Debug.Log($"step color not white at {name} anim: {animIndex} step: {stepIndex}");#1#
/*if (step.Opacity != 255)
Debug.Log($"step opacity not 255 at {name} anim: {animIndex} step: {stepIndex}");#1#
/*if (Math.Abs(step.StretchX - 1f) > 0.0000001)
{
Debug.Log($"stretch x at {name} anim: {animIndex} step: {stepIndex}");
}
if (Math.Abs(step.StretchY - 1f) > 0.0000001)
{
Debug.Log($"stretch y at {name} anim: {animIndex} step: {stepIndex}");
}#1#
/*if (step.Rotation > 0)
{
Debug.Log($"rotation at {name} anim: {animIndex} step: {stepIndex}");
}#1#
}*/
}
} }
foreach (var filename in problematicFiles) /*foreach (var filename in problematicFiles)
{ {
Debug.Log(filename); Debug.Log(filename);
} }*/
} }
} }
} }

View file

@ -24,12 +24,12 @@ namespace Bread2Unity
public float Depth; public float Depth;
public float StretchX; public float StretchX;//needs to add
public float StretchY; public float StretchY; //needs to add
public float Rotation; public float Rotation; //needs to add
public byte Opacity; public byte Opacity;//needs to add
public Color Color; public Color Color;//needs to add
} }
} }

View file

@ -5,12 +5,17 @@ Rhythm Heaven animation to Unity animation converter
### TODO ### TODO
- [X] add option for rotate texture - [X] add option for rotate texture
- [ ] remove npe (animationController) - [ ] remove npe (animationController)
- [x] change animations save location - [x] change animations save location
- [x] refactor files - [x] refactor files
- [ ] add color animations (use bccad test) - [ ] add color animations
- [ ] add rotation from steps
- [ ] add scale from steps
- [x] add translation from steps
- [ ] remove bccad test - [ ] remove bccad test