From a6a4ed2c445e7daf188c47ccf67c5926e28affdf Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 11 Sep 2021 09:37:04 -0400 Subject: [PATCH] new wacky matrix stuff lil messy teehee --- source/animate/FlxAnimate.hx | 58 +++++++++++++++++++----- source/animate/FlxSymbol.hx | 17 +++---- source/animate/ParseAnimate.hx | 82 ++++++++++++++++++++++++++++++---- 3 files changed, 128 insertions(+), 29 deletions(-) diff --git a/source/animate/FlxAnimate.hx b/source/animate/FlxAnimate.hx index 08a561db3..60408697a 100644 --- a/source/animate/FlxAnimate.hx +++ b/source/animate/FlxAnimate.hx @@ -18,6 +18,7 @@ import flixel.system.FlxAssets.FlxGraphicAsset; import haxe.format.JsonParser; import openfl.Assets; import openfl.display.BitmapData; +import openfl.geom.Matrix; import openfl.geom.Rectangle; class FlxAnimate extends FlxSymbol @@ -34,7 +35,9 @@ class FlxAnimate extends FlxSymbol sprGrp = new FlxTypedGroup(); - var folder:String = "tightBarsLol"; + var tests:Array = ['tightBarsLol', 'tightestBars']; + + var folder:String = tests[1]; frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + "/spritemap1.png"), Paths.file('images/$folder/spritemap1.json')); @@ -75,10 +78,7 @@ class FlxAnimate extends FlxSymbol **/ function generateSpriteShit() { - sprGrp.kill(); // kills group, maybe dont need to do this one so broadly? - - // just used for sum default shit? - var normalSpr:FlxSymbol = new FlxSymbol(0, 0); + sprGrp.kill(); // kills group, maybe dont need to do this one so broadly? ehh whatev for (frameSorted in ParseAnimate.frameList) { @@ -88,6 +88,7 @@ class FlxAnimate extends FlxSymbol var spr:FlxSymbol = sprGrp.recycle(FlxSymbol); // redo this to recycle from a list later spr.frames = frames; spr.frame = spr.frames.getByName(i.frameName); // this one is fine + spr.updateHitbox(); // move this? wont work here! if (FlxG.keys.justPressed.I) @@ -98,20 +99,53 @@ class FlxAnimate extends FlxSymbol } // cuz its in group, gets a lil fuckie when animated, need to go thru and properly reset each thing for shit like matrix! - spr.transformMatrix.copyFrom(normalSpr.transformMatrix); + // merely resets the matrix to normal ass one! + spr.transformMatrix.identity(); + spr.setPosition(); - for (swagMatrix in i.matrixArray) + /* for (swagMatrix in i.matrixArray) + { + var alsoSwag:FlxMatrix = new FlxMatrix(swagMatrix[0], swagMatrix[1], swagMatrix[4], swagMatrix[5], swagMatrix[12], swagMatrix[13]); + spr.matrixExposed = true; + spr.transformMatrix.concat(alsoSwag); + }*/ + + // i.fullMatrix.concat + + spr.matrixExposed = true; + + // trace(i.fullMatrix); + + if (i.fullMatrix.a < 0) { - var alsoSwag:FlxMatrix = new FlxMatrix(swagMatrix[0], swagMatrix[1], swagMatrix[4], swagMatrix[5], swagMatrix[12], swagMatrix[13]); - spr.matrixExposed = true; - spr.transformMatrix.concat(alsoSwag); + trace('negative?'); + trace(i.fullMatrix); } - // spr.alpha = 0.3; + spr.transformMatrix.concat(i.fullMatrix); + + if (i.fullMatrix.a < 0) + { + trace('negative?'); + trace(i.fullMatrix); + trace(spr.transformMatrix); + } + + // trace(spr.transformMatrix); + spr.origin.set(); + + /* for (trpShit in i.trpArray) + { + spr.origin.x -= trpShit[0]; + spr.origin.y -= trpShit[1]; + } + */ + // spr.alpha = 0.3; + spr.antialiasing = true; sprGrp.add(spr); - // spr.alpha = 0.5; + spr.alpha = 0.5; /* if (i == "0225") { diff --git a/source/animate/FlxSymbol.hx b/source/animate/FlxSymbol.hx index b3a131d97..097ce5914 100644 --- a/source/animate/FlxSymbol.hx +++ b/source/animate/FlxSymbol.hx @@ -154,6 +154,7 @@ class FlxSymbol extends FlxSprite dumbassMatrix.concat(_matrix); spr.matrixExposed = true; + spr.transformMatrix.concat(dumbassMatrix); // spr._matrix.concat(spr.transformMatrix); @@ -248,18 +249,18 @@ class FlxSymbol extends FlxSprite } else { - if (bakedRotationAngle <= 0) - { - updateTrig(); - - if (angle != 0) - _matrix.rotateWithTrig(_cosAngle, _sinAngle); - } - updateSkewMatrix(); _matrix.concat(_skewMatrix); } + if (bakedRotationAngle <= 0) + { + updateTrig(); + + if (angle != 0) + _matrix.rotateWithTrig(_cosAngle, _sinAngle); + } + _point.addPoint(origin); _matrix.translate(_point.x, _point.y); diff --git a/source/animate/ParseAnimate.hx b/source/animate/ParseAnimate.hx index 4fb51eb59..0e663c9e2 100644 --- a/source/animate/ParseAnimate.hx +++ b/source/animate/ParseAnimate.hx @@ -2,6 +2,8 @@ package animate; import haxe.format.JsonParser; import openfl.Assets; +import openfl.geom.Matrix3D; +import openfl.geom.Matrix; import sys.io.File; /** @@ -109,20 +111,30 @@ class ParseAnimate */ public static var matrixHelp:Array>> = []; - public static var trpHelpIDK:Array> = []; + public static var trpHelpIDK:Array>> = []; public static var loopedFrameShit:Int = 0; + public static var funnyMatrix:Matrix = new Matrix(); + public static var matrixFlipper:Array = []; + // clean up all the crazy ass arrays public static function resetFrameList() { + // funnyMatrix.identity(); + frameList = []; frameList.push([]); matrixHelp = []; matrixHelp.push([]); + + trpHelpIDK = []; + trpHelpIDK.push([]); } + public static var isFlipped:Bool = false; + public static function parseTimeline(TL:Timeline, tabbed:Int = 0, ?frameInput:Int) { var strTab:String = ""; @@ -185,27 +197,76 @@ class ParseAnimate { matrixHelp[matrixHelp.length - 1].push(element.ASI.M3D); + var m3D = element.ASI.M3D; + var lilMatrix:Matrix = new Matrix(m3D[0], m3D[1], m3D[4], m3D[5], m3D[12], m3D[13]); + matrixFlipper.push(lilMatrix); + + // matrixFlipper.reverse(); + + // funnyMatrix.identity(); + + // for (m in matrixFlipper) + // funnyMatrix.concat(m); + + if (isFlipped) + { + trace("MORE FLIPPED SHIT"); + trace("MORE FLIPPED SHIT"); + trace("MORE FLIPPED SHIT"); + trace(funnyMatrix); + trace(matrixFlipper); + } + + // trace(funnyMatrix); + + funnyMatrix.concat(lilMatrix); + // trace(funnyMatrix); + frameList[frameList.length - 1].push({ frameName: element.ASI.N, - M3D: element.ASI.M3D, depthString: depthTypeBeat, matrixArray: matrixHelp[matrixHelp.length - 1], - trpArray: trpHelpIDK + trpArray: trpHelpIDK[trpHelpIDK.length - 1], + fullMatrix: funnyMatrix.clone() }); // flips the matrix once?? I cant remember exactly why it needs to be flipped // matrixHelp[matrixHelp.length - 1].reverse(); - trpHelpIDK = []; + // trpHelpIDK = []; + + // push the matrix array after each symbol? + + funnyMatrix.identity(); + matrixFlipper = []; depthTypeBeat = ""; curLoopType = ""; loopedFrameShit = 0; + + isFlipped = false; } else { + var m3D = element.SI.M3D; + var lilMatrix:Matrix = new Matrix(m3D[0], m3D[1], m3D[4], m3D[5], m3D[12], m3D[13]); + + if (lilMatrix.a == -1) + { + isFlipped = true; + + trace('IS THE NEGATIVE ONE'); + } + + if (isFlipped) + trace(lilMatrix); + + funnyMatrix.concat(lilMatrix); + matrixFlipper.push(lilMatrix); + // trace(funnyMatrix); + matrixHelp[matrixHelp.length - 1].push(element.SI.M3D); - trpHelpIDK.push([element.SI.TRP.x, element.SI.TRP.y]); + trpHelpIDK[trpHelpIDK.length - 1].push([element.SI.TRP.x, element.SI.TRP.y]); // trpHelpIDK.push(); depthTypeBeat += "->" + element.SI.SN; curLoopType = element.SI.LP; @@ -222,6 +283,11 @@ class ParseAnimate parseTimeline(symbolMap.get(element.SI.SN).TL, tabbed + 1, inputFrame); } + + // idk if this should go per layer or per element / object? + + matrixHelp.push([]); + trpHelpIDK.push([]); } if (tabbed == 0) @@ -229,8 +295,6 @@ class ParseAnimate frameList[frameList.length - 1].reverse(); frameList.push([]); // new layer essentially } - - matrixHelp.push([]); } frameList.reverse(); @@ -240,10 +304,10 @@ class ParseAnimate typedef VALIDFRAME = { frameName:String, - M3D:Array, depthString:String, matrixArray:Array>, - trpArray:Array> + trpArray:Array>, + fullMatrix:Matrix } typedef AnimJson =