mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
make this work
This commit is contained in:
parent
a9917d1ea1
commit
9d382807bf
8 changed files with 118 additions and 84 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue