From 9d382807bf22b2b888f29556ad9e28df87263274 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Thu, 8 Jun 2023 00:21:54 +0530 Subject: [PATCH] make this work --- src/DtsObject.hx | 59 ++++++++++++++++++++++++++---------- src/Marble.hx | 72 +++++++++++++++++++++----------------------- src/MarbleWorld.hx | 6 +--- src/MissionList.hx | 37 ++++++++++++----------- src/gui/PlayGui.hx | 2 +- src/mis/MisParser.hx | 5 +++ src/shapes/Gem.hx | 2 +- src/shapes/Glass.hx | 19 +++++++----- 8 files changed, 118 insertions(+), 84 deletions(-) diff --git a/src/DtsObject.hx b/src/DtsObject.hx index c73c1edc..a402824a 100644 --- a/src/DtsObject.hx +++ b/src/DtsObject.hx @@ -815,26 +815,53 @@ class DtsObject extends GameObject { if (scale > 0) { scales = []; - for (i in 0...this.dts.nodes.length) { - var affected = ((1 << i) & scale) != 0; + if (sequence.flags & 1 > 0) { // Uniform scales + for (i in 0...this.dts.nodes.length) { + var affected = ((1 << i) & scale) != 0; - if (affected) { - var scale1 = this.dts.nodeAlignedScales[sequence.numKeyFrames * affectedCount + keyframeLow]; - var scale2 = this.dts.nodeAlignedScales[sequence.numKeyFrames * affectedCount + keyframeHigh]; + if (affected) { + var scale1 = this.dts.nodeUniformScales[sequence.numKeyFrames * affectedCount + keyframeLow]; + var scale2 = this.dts.nodeUniformScales[sequence.numKeyFrames * affectedCount + keyframeHigh]; - var v1 = new Vector(scale1.x, scale1.y, scale1.z); - var v2 = new Vector(scale2.x, scale2.y, scale2.z); + var v1 = new Vector(scale1, scale1, scale1); + var v2 = new Vector(scale2, scale2, scale2); - var scaleVec = Util.lerpThreeVectors(v1, v2, t); - this.graphNodes[i].scaleX = scaleVec.x; - this.graphNodes[i].scaleY = scaleVec.y; - this.graphNodes[i].scaleZ = scaleVec.z; + var scaleVec = Util.lerpThreeVectors(v1, v2, t); + this.graphNodes[i].scaleX = scaleVec.x; + this.graphNodes[i].scaleY = scaleVec.y; + this.graphNodes[i].scaleZ = scaleVec.z; - this.dirtyTransforms[i] = true; - } else { - this.graphNodes[i].scaleX = 1; - this.graphNodes[i].scaleY = 1; - this.graphNodes[i].scaleZ = 1; + this.dirtyTransforms[i] = true; + } else { + this.graphNodes[i].scaleX = 1; + this.graphNodes[i].scaleY = 1; + this.graphNodes[i].scaleZ = 1; + } + } + } + + if (sequence.flags & 2 > 0) { // `Aligned` scales + for (i in 0...this.dts.nodes.length) { + var affected = ((1 << i) & scale) != 0; + + if (affected) { + var scale1 = this.dts.nodeAlignedScales[sequence.numKeyFrames * affectedCount + keyframeLow]; + var scale2 = this.dts.nodeAlignedScales[sequence.numKeyFrames * affectedCount + keyframeHigh]; + + var v1 = new Vector(scale1.x, scale1.y, scale1.z); + var v2 = new Vector(scale2.x, scale2.y, scale2.z); + + var scaleVec = Util.lerpThreeVectors(v1, v2, t); + this.graphNodes[i].scaleX = scaleVec.x; + this.graphNodes[i].scaleY = scaleVec.y; + this.graphNodes[i].scaleZ = scaleVec.z; + + this.dirtyTransforms[i] = true; + } else { + this.graphNodes[i].scaleX = 1; + this.graphNodes[i].scaleY = 1; + this.graphNodes[i].scaleZ = 1; + } } } } diff --git a/src/Marble.hx b/src/Marble.hx index 7b728ded..790e413c 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -564,11 +564,11 @@ class Marble extends GameObject { var currentXVelocity = rollVelocity.dot(sideDir); var mv = m.d; - // mv = mv.multiply(1.538461565971375); - // var mvlen = mv.length(); - // if (mvlen > 1) { - // mv = mv.multiply(1 / mvlen); - // } + mv = mv.multiply(1.538461565971375); + var mvlen = mv.length(); + if (mvlen > 1) { + mv = mv.multiply(1 / mvlen); + } var desiredYVelocity = this._maxRollVelocity * mv.y; var desiredXVelocity = this._maxRollVelocity * mv.x; @@ -696,38 +696,38 @@ class Marble extends GameObject { interior.setStopped(); } } - } while (!done && itersIn < 1e4); // Maximum limit pls - // if (this.velocity.lengthSq() < 625) { - var gotOne = false; - var dir = new Vector(0, 0, 0); - for (j in 0...contacts.length) { - var dir2 = dir.add(contacts[j].normal); - if (dir2.lengthSq() < 0.01) { - dir2 = dir2.add(contacts[j].normal); - } - dir = dir2; - dir.normalize(); - gotOne = true; - } - if (gotOne) { - dir.normalize(); - var soFar = 0.0; - for (k in 0...contacts.length) { - var dist = this._radius - contacts[k].contactDistance; - var timeToSeparate = 0.1; - var vel = this.velocity.sub(contacts[k].velocity); - var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal); - if (dist > timeToSeparate * outVel) { - soFar += (dist - outVel * timeToSeparate) / timeToSeparate / contacts[k].normal.dot(dir); + } while (!done && itersIn < 20); // Maximum limit pls + if (this.velocity.lengthSq() < 625) { + var gotOne = false; + var dir = new Vector(0, 0, 0); + for (j in 0...contacts.length) { + var dir2 = dir.add(contacts[j].normal); + if (dir2.lengthSq() < 0.01) { + dir2 = dir2.add(contacts[j].normal); } + dir = dir2; + dir.normalize(); + gotOne = true; + } + if (gotOne) { + dir.normalize(); + var soFar = 0.0; + for (k in 0...contacts.length) { + var dist = this._radius - contacts[k].contactDistance; + var timeToSeparate = 0.1; + var vel = this.velocity.sub(contacts[k].velocity); + var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal); + if (dist > timeToSeparate * outVel) { + soFar += (dist - outVel * timeToSeparate) / timeToSeparate / contacts[k].normal.dot(dir); + } + } + if (soFar < -25) + soFar = -25; + if (soFar > 25) + soFar = 25; + this.velocity = this.velocity.add(dir.multiply(soFar)); } - // if (soFar < -25) - // soFar = -25; - // if (soFar > 25) - // soFar = 25; - this.velocity = this.velocity.add(dir.multiply(soFar)); } - // } return stoppedPaths; } @@ -1587,9 +1587,7 @@ class Marble extends GameObject { this.velocity.set(this.velocity.x + A.x * timeStep, this.velocity.y + A.y * timeStep, this.velocity.z + A.z * timeStep); this.omega.set(this.omega.x + a.x * timeStep, this.omega.y + a.y * timeStep, this.omega.z + a.z * timeStep); if (this.mode == Start) { - // Bruh... - this.velocity.y = 0; - this.velocity.x = 0; + this.velocity.set(0, 0, 0); } stoppedPaths = this.velocityCancel(timeState.currentAttemptTime, timeStep, isCentered, true, stoppedPaths, pathedInteriors); this._totalTime += timeStep; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index eb0eee7b..1559e569 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -393,11 +393,7 @@ class MarbleWorld extends Scheduler { "shapes/images/glow_bounce.dts", "shapes/images/glow_bounce.png", "shapes/images/helicopter.dts", - "shapes/images/helicopter.jpg", - "shapes/pads/white.jpg", // These irk us a lot because ifl shit - "shapes/pads/red.jpg", - "shapes/pads/blue.jpg", - "shapes/pads/green.jpg", + "shapes/images/helicopter.jpg", // These irk us a lot because ifl shit "shapes/items/gem.dts", // Ew ew "shapes/items/gemshine.png", "shapes/items/enviro1.jpg", diff --git a/src/MissionList.hx b/src/MissionList.hx index ffc591e4..c81ccde5 100644 --- a/src/MissionList.hx +++ b/src/MissionList.hx @@ -31,24 +31,27 @@ class MissionList { #end var difficultyMissions = []; for (file in difficultyFiles) { - if (file.extension == "mis") { - var misParser = new MisParser(file.getText()); - var mInfo = misParser.parseMissionInfo(); - var mission = Mission.fromMissionInfo(file.path, mInfo); - if (game != "custom") - mission.game = game; - else if (mInfo.game != null && mInfo.game != "") - mission.game = mInfo.game.toLowerCase(); - else - mission.game = game; // Last case scenario - if (game == "custom") - mission.isCustom = true; - // do egg thing - if (StringTools.contains(file.getText().toLowerCase(), 'datablock = "easteregg"')) { // Ew - mission.hasEgg = true; + var subfiles = ResourceLoader.fileSystem.dir(file.path); + for (file in subfiles) { + if (file.extension == "mis") { + var misParser = new MisParser(file.getText()); + var mInfo = misParser.parseMissionInfo(); + var mission = Mission.fromMissionInfo(file.path, mInfo); + if (game != "custom") + mission.game = game; + else if (mInfo.game != null && mInfo.game != "") + mission.game = mInfo.game.toLowerCase(); + else + mission.game = game; // Last case scenario + if (game == "custom") + mission.isCustom = true; + // do egg thing + if (StringTools.contains(file.getText().toLowerCase(), 'datablock = "easteregg"')) { // Ew + mission.hasEgg = true; + } + missions.set(file.path, mission); + difficultyMissions.push(mission); } - missions.set(file.path, mission); - difficultyMissions.push(mission); } } difficultyMissions.sort((a, b) -> Std.parseInt(a.missionInfo.level) - Std.parseInt(b.missionInfo.level)); diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 60523c2f..ae8bf87e 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -313,7 +313,7 @@ class PlayGui { // gemImageSceneTargetBitmap.blendMode = None; // gemImageSceneTargetBitmap.addShader(new ColorKey()); - var GEM_COLORS = ["blue", "red", "yellow", "purple", "green", "turquoise", "orange", "black"]; + var GEM_COLORS = ["red"]; var gemColor = GEM_COLORS[Math.floor(Math.random() * GEM_COLORS.length)]; gemImageObject = new DtsObject(); diff --git a/src/mis/MisParser.hx b/src/mis/MisParser.hx index c1c09c87..ed30404e 100644 --- a/src/mis/MisParser.hx +++ b/src/mis/MisParser.hx @@ -24,6 +24,7 @@ import src.Util; import h3d.Vector; import h3d.Quat; import src.Console; +import src.ResourceLoader; final elementHeadRegEx = ~/new\s+(\w+)\((.*?)\)\s*{/g; final blockCommentRegEx = ~/\/\*(.|\n)*?\*\//g; @@ -151,6 +152,10 @@ class MisParser { } public function parseMissionInfo() { + this.variables = ["$usermods" => '""']; // Just make $usermods point to nothing + for (key => value in localizations) { + this.variables.set(key, '"' + value + '"'); + } var missionInfoIndex = this.text.indexOf("new ScriptObject(MissionInfo)"); this.index = missionInfoIndex; var mInfo:MissionElementScriptObject = cast readElement(); diff --git a/src/shapes/Gem.hx b/src/shapes/Gem.hx index 302e1027..15460065 100644 --- a/src/shapes/Gem.hx +++ b/src/shapes/Gem.hx @@ -23,7 +23,7 @@ class Gem extends DtsObject { useInstancing = true; showSequences = false; // Gems actually have an animation for the little shiny thing, but the actual game ignores that. I get it, it was annoying as hell. - var GEM_COLORS = ["blue", "red", "yellow", "purple", "green", "turquoise", "orange", "black"]; + var GEM_COLORS = ["red"]; var color = element.datablock.substring("GemItem".length); if (color.length == 0) color = GEM_COLORS[Math.floor(Math.random() * GEM_COLORS.length)]; diff --git a/src/shapes/Glass.hx b/src/shapes/Glass.hx index ee70d721..16274e20 100644 --- a/src/shapes/Glass.hx +++ b/src/shapes/Glass.hx @@ -1,7 +1,12 @@ package shapes; +import h3d.scene.RenderContext; +import h3d.mat.Material; +import h3d.Vector; +import mis.MisParser; import mis.MissionElement.MissionElementStaticShape; import src.DtsObject; +import src.ResourceLoader; class Glass extends DtsObject { public function new(element:MissionElementStaticShape) { @@ -10,21 +15,21 @@ class Glass extends DtsObject { var datablockLowercase = element.datablock.toLowerCase(); switch (datablockLowercase) { case "glass_3shape": - this.dtsPath = "data/shapes/glass/3x3.dts"; + this.dtsPath = "data/shapes/structures/glass_3.dts"; case "glass_6shape": - this.dtsPath = "data/shapes/glass/6x3.dts"; + this.dtsPath = "data/shapes/structures/glass_6.dts"; case "glass_9shape": - this.dtsPath = "data/shapes/glass/9x3.dts"; + this.dtsPath = "data/shapes/structures/glass_9.dts"; case "glass_12shape": - this.dtsPath = "data/shapes/glass/12x3.dts"; + this.dtsPath = "data/shapes/structures/glass_12.dts"; case "glass_15shape": - this.dtsPath = "data/shapes/glass/15x3.dts"; + this.dtsPath = "data/shapes/structures/glass_15.dts"; case "glass_18shape": - this.dtsPath = "data/shapes/glass/18x3.dts"; + this.dtsPath = "data/shapes/structures/glass_18.dts"; } this.isCollideable = true; - this.useInstancing = true; + this.useInstancing = false; this.identifier = datablockLowercase; }