From ea24d91efaac060cfc6f3ae47600cef0e19637b9 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:06:44 +0100 Subject: [PATCH] dae models support --- source/flx3d/Flx3DView.hx | 10 ++++++++-- source/funkin/menus/FreeplayState.hx | 4 +++- source/funkin/system/CoolUtil.hx | 5 +---- source/funkin/system/Paths.hx | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/flx3d/Flx3DView.hx b/source/flx3d/Flx3DView.hx index ee21e252..ab1c4cd4 100644 --- a/source/flx3d/Flx3DView.hx +++ b/source/flx3d/Flx3DView.hx @@ -3,7 +3,7 @@ package flx3d; import away3d.loaders.misc.AssetLoaderToken; import away3d.library.assets.Asset3DType; import away3d.events.Asset3DEvent; -import away3d.loaders.parsers.OBJParser; +import away3d.loaders.parsers.*; import away3d.utils.Cast; import away3d.materials.TextureMaterial; import haxe.io.Path; @@ -69,7 +69,13 @@ class Flx3DView extends FlxView3D { if (texturePath != null) material = new TextureMaterial(Cast.bitmapTexture(texturePath), smoothTexture); - var token = _loader.loadData(model, context, null, new OBJParser()); + var token = _loader.loadData(model, context, null, switch(Path.extension(assetPath).toLowerCase()) { + case "dae": new DAEParser(); + case "md2": new MD2Parser(); + case "md5": new MD5MeshParser(); + case "awd": new AWDParser(); + default: new OBJParser(); + }); meshCallback = function(mesh) { if (material != null) mesh.material = material; diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 34f62b60..5b360608 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -155,12 +155,14 @@ class FreeplayState extends MusicBeatState // putting it before so that its actually smooth updateOptionsAlpha(); + var dontPlaySongThisFrame = false; #if PRELOAD_ALL autoplayElapsed += elapsed; if (!songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].songName, songs[curSelected].difficulties[curDifficulty]))) FlxG.sound.playMusic(curPlayingInst, 0); songInstPlaying = true; + dontPlaySongThisFrame = true; } #end @@ -171,7 +173,7 @@ class FreeplayState extends MusicBeatState FlxG.switchState(new MainMenuState()); } - if (controls.ACCEPT) + if (controls.ACCEPT && !dontPlaySongThisFrame) { CoolUtil.loadSong(songs[curSelected].songName, songs[curSelected].difficulties[curDifficulty]); FlxG.switchState(new PlayState()); diff --git a/source/funkin/system/CoolUtil.hx b/source/funkin/system/CoolUtil.hx index e4edaef9..d27bdf98 100644 --- a/source/funkin/system/CoolUtil.hx +++ b/source/funkin/system/CoolUtil.hx @@ -159,10 +159,7 @@ class CoolUtil "BPM" => null ]); var parsedBPM:Null = Std.parseFloat(musicInfo["BPM"]); - if (parsedBPM == null) - Conductor.changeBPM(DefaultBPM); - else - Conductor.changeBPM(parsedBPM); + Conductor.changeBPM(parsedBPM == null ? DefaultBPM : parsedBPM); } else Conductor.changeBPM(DefaultBPM); } diff --git a/source/funkin/system/Paths.hx b/source/funkin/system/Paths.hx index d91d78ff..9e186787 100644 --- a/source/funkin/system/Paths.hx +++ b/source/funkin/system/Paths.hx @@ -176,6 +176,22 @@ class Paths return getPath('models/$key.obj', BINARY, null); } + inline static public function dae(key:String) { + return getPath('models/$key.dae', BINARY, null); + } + + inline static public function md2(key:String) { + return getPath('models/$key.md2', BINARY, null); + } + + inline static public function md5(key:String) { + return getPath('models/$key.md5', BINARY, null); + } + + inline static public function awd(key:String) { + return getPath('models/$key.awd', BINARY, null); + } + inline static public function getSparrowAtlas(key:String, ?library:String) { return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));