dae models support

This commit is contained in:
Yoshman29
2022-12-19 17:06:44 +01:00
parent cd0edc8378
commit ea24d91efa
4 changed files with 28 additions and 7 deletions
+8 -2
View File
@@ -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;
+3 -1
View File
@@ -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());
+1 -4
View File
@@ -159,10 +159,7 @@ class CoolUtil
"BPM" => null
]);
var parsedBPM:Null<Float> = Std.parseFloat(musicInfo["BPM"]);
if (parsedBPM == null)
Conductor.changeBPM(DefaultBPM);
else
Conductor.changeBPM(parsedBPM);
Conductor.changeBPM(parsedBPM == null ? DefaultBPM : parsedBPM);
} else
Conductor.changeBPM(DefaultBPM);
}
+16
View File
@@ -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));