diff --git a/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs b/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs index 7287b8b4c..aa48dd80d 100644 --- a/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs +++ b/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs @@ -49,7 +49,6 @@ namespace Bread2Unity AnimatorController.CreateAnimatorControllerAtPath( AssetDatabase.GenerateUniqueAssetPath( $"{animationsFolderPath}/{prefabData.Name}Controller.controller")); - var bccadSprites = bccad.sprites; //get all of the parts associated with the game object var steps = prefabData.Animations.SelectMany(animation => animation.Steps); @@ -120,9 +119,9 @@ namespace Bread2Unity var sprite = sprites[bccadSpritePart.RegionIndex.Index]; var width = bccadSpritePart.StretchX / bccadPrefab.WidthRatio; 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; - var y = -(bccadSpritePart.PosY - 512f) / SpriteCreator.PixelsPerUnit - + var y = -(bccadSpritePart.PosY + currentStep.TranslateY- 512f) / SpriteCreator.PixelsPerUnit - sprite.bounds.size.y * 0.5f * height; var z = -0.00001f * partIndex; @@ -176,7 +175,9 @@ namespace Bread2Unity if ((from part in partsOfGameObject select part.RegionIndex.Index).Distinct().Count() > 1) AnimationUtility.SetObjectReferenceCurve(animationClip, spriteBinding, spriteFrames.ToArray()); 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.y", yTransformCurve); diff --git a/Assets/Editor/bread2unity/BccadTest.cs b/Assets/Editor/bread2unity/BccadTest.cs index a43a37f52..e6f869af7 100644 --- a/Assets/Editor/bread2unity/BccadTest.cs +++ b/Assets/Editor/bread2unity/BccadTest.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using UnityEngine; @@ -12,15 +13,15 @@ namespace Bread2Unity const string folderPath = "C:\\Users\\Eliya\\games\\3DS\\PackEnglishV12\\PackEnglishV12\\PackHack\\ExtractedRomFS\\cellanim"; var allFiles = Directory.GetFiles(folderPath, "*.bccad", SearchOption.AllDirectories); - var problematicFiles = new HashSet(); + // var problematicFiles = new HashSet(); foreach (var file in allFiles) { var bccad = BCCAD.Read(File.ReadAllBytes(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]; - /*for (var partIndex = 0; partIndex < sprite.parts.Count; partIndex++) + for (var partIndex = 0; partIndex < sprite.parts.Count; partIndex++) { var part = sprite.parts[partIndex]; if (part.Multicolor != Color.white) @@ -28,34 +29,45 @@ namespace Bread2Unity if (part.ScreenColor != Color.black) 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); - } + }*/ } } } \ No newline at end of file diff --git a/Assets/Editor/bread2unity/Model/Animation.cs b/Assets/Editor/bread2unity/Model/Animation.cs index 3e8489ec2..415b903c9 100644 --- a/Assets/Editor/bread2unity/Model/Animation.cs +++ b/Assets/Editor/bread2unity/Model/Animation.cs @@ -24,12 +24,12 @@ namespace Bread2Unity public float Depth; - public float StretchX; - public float StretchY; + public float StretchX;//needs to add + public float StretchY; //needs to add - public float Rotation; + public float Rotation; //needs to add - public byte Opacity; - public Color Color; + public byte Opacity;//needs to add + public Color Color;//needs to add } } \ No newline at end of file diff --git a/Assets/Editor/bread2unity/README.md b/Assets/Editor/bread2unity/README.md index fb549066e..9a62110eb 100644 --- a/Assets/Editor/bread2unity/README.md +++ b/Assets/Editor/bread2unity/README.md @@ -5,12 +5,17 @@ Rhythm Heaven animation to Unity animation converter ### TODO - [X] add option for rotate texture + - [ ] remove npe (animationController) - [x] change animations save location + - [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