diff --git a/common/src/main/java/org/ayamemc/ayame/model/resource/IModelResource.java b/common/src/main/java/org/ayamemc/ayame/model/resource/IModelResource.java index a00b338..6bc9338 100644 --- a/common/src/main/java/org/ayamemc/ayame/model/resource/IModelResource.java +++ b/common/src/main/java/org/ayamemc/ayame/model/resource/IModelResource.java @@ -20,17 +20,25 @@ package org.ayamemc.ayame.model.resource; +import org.ayamemc.ayame.model.AyameModelType; import org.ayamemc.ayame.model.IndexData; import org.ayamemc.ayame.util.TODO; import java.io.File; import java.nio.file.Path; +import java.util.List; public interface IModelResource { // TODO 完成 IndexData.ModelMetaData getMetaData(); - public static IModelResource fromFile(File file){ + List getModels(); + + default IndexData.ModelData getDefault() { + return getModels().getFirst(); + } + + static IModelResource fromFile(File file){ throw new TODO("create model from file"); } } diff --git a/common/src/main/java/org/ayamemc/ayame/model/resource/ModelResourceRegistry.java b/common/src/main/java/org/ayamemc/ayame/model/resource/ModelResourceRegistry.java index 5153d42..4090ae2 100644 --- a/common/src/main/java/org/ayamemc/ayame/model/resource/ModelResourceRegistry.java +++ b/common/src/main/java/org/ayamemc/ayame/model/resource/ModelResourceRegistry.java @@ -20,7 +20,7 @@ package org.ayamemc.ayame.model.resource; -import org.ayamemc.ayame.model.IndexData; +import org.ayamemc.ayame.util.JsonInterpreter; import org.ayamemc.ayame.util.TODO; import java.util.HashMap; @@ -58,7 +58,7 @@ public static IModelResource create(String format, ModelFile modelFile) { * @return 模型实例 */ public static IModelResource create(ModelFile modelFile){ - return create(modelFile.getIndexData().metaData().format(), modelFile); + return create(modelFile.getFormat(), modelFile); } /** @@ -76,7 +76,7 @@ public static boolean contains(String name){ * @return 是否支持被读取 */ public static boolean contains(ModelFile modelFile){ - return contains(modelFile.getIndexData().metaData().format()); + return contains(modelFile.getFormat()); } @FunctionalInterface @@ -87,8 +87,12 @@ public interface ResourceFactory { public static class ModelFile{ // TODO 这里起暂时的占位符作用,后面请修改它 - public IndexData getIndexData(){ + public JsonInterpreter getIndexJson(){ throw new TODO("Model File"); } + + public String getFormat(){ + return getIndexJson().getString("format"); + } } } diff --git a/examples/test/index.json b/examples/test/index.json index 4ce3b5c..f8b1ce0 100644 --- a/examples/test/index.json +++ b/examples/test/index.json @@ -15,17 +15,17 @@ "vanilla-like" ] }, - "default": { - "name": "默认", - "model": "models/def_model.json", - "animation": "animations/def_anim.json", - "texture": "textures/def_tex.json", - "arm": "animations/arm.json", - "controllers": [ - "ayame:default" - ] - }, - "presets": [ + "models": [ + { + "name": "默认", + "model": "models/def_model.json", + "animation": "animations/def_anim.json", + "texture": "textures/def_tex.json", + "arm": "animations/arm.json", + "controllers": [ + "ayame:default" + ] + }, { "name": "预设1", "model": "models/def_model.json", @@ -36,29 +36,5 @@ "ayame:default" ] } - ], - "注释(别管这么多啦,这是咱开发时用的)": { - "presets": [ - { - "name": "预设1", - "model": "models/preset1_model.json", - "animation": "animations/preset1_anim.json", - "texture": "textures/preset1_tex.json", - "arm": "animations/arm.json", - "controllers": [ - "ayame:default" - ] - }, - { - "name": "预设2", - "model": "models/preset2_model.json", - "animation": "animations/preset2_anim.json", - "texture": "textures/preset2_tex.json", - "arm": "animations/arm.json", - "controllers": [ - "ayame:default" - ] - } - ] - } + ] } \ No newline at end of file