这是一个巨大的 WIP(开发中),但我最终会完成它。文档和维基也尚未发布。
描述
StargazerLib 是一个库,能够在 Minecraft 实体上直接渲染并动画化 glTF / GLB 模型,包括其骨架、动画和纹理。
简而言之:它就像 GeckoLib,但使用的是真实网格而非方块。
它的诞生源于一个简单的挫败感:GeckoLib 只能渲染方块。当你的艺术家在 Blender 中工作并交给你低多边形模型时,你的选择会很糟糕。
- 为什么要将干净的低多边形模型体素化,这使得它比原始模型 更丑 且 更重?
- 为什么要手动在 Blockbench 中重建整个模型,而它已经以
.glb 格式存在?
- 为什么在这个过程中会丢失你的骨架、动画和纹理?
StargazerLib 采取了另一条路线:它以原样加载 .glb 文件,并通过 Minecraft 自身的管道渲染实际网格,因此光照和光影仍然有效。蒙皮、动画片段(支持片段间的交叉淡入淡出)、纹理和自动缩放都由你处理。
它的用途类似于 GeckoLib,供其他模组使用,但你可以保留你的艺术家已经使用的 Blender 工作流程。
对于开发者
将你的模型放入 assets/<modid>/models/entity/<name>.glb,然后让你的实体声明它:
public class Dragon extends Entity implements GltfAnimatable {
public ResourceLocation getGltfModel() {
return new ResourceLocation("mymod", "dragon");
}
public float getGltfSize() {
return 2.0f; // 最大维度约 2 个方块
}
public void registerControllers(ControllerRegistrar registrar) {
registrar.add(new AnimationController<>("main",
state -> state.isMoving() ? "fly" : "idle"));
}
}
然后注册提供的通用渲染器:
event.registerEntityRenderer(DRAGON_TYPE, GltfEntityRenderer::new);
就这样,Blender 模型就会出现在你的实体上,带有动画和纹理。包含两个演示实体(stargazerlib:gltf_test 和 stargazerlib:gltf_dragon),以便你在游戏中查看效果。
It is a HUGE WIP, but i'll get there eventually. The docs and wiki are yet to be published too.
Description
StargazerLib is a library that renders and animates glTF / GLB models directly on Minecraft entities, with their skeleton, animations and textures.
In short: it's like GeckoLib, but for real meshes instead of cubes.
It was born out of a simple frustration: GeckoLib only renders cubes. When your artists work in Blender and hand you low-poly models, your options are bad ones.
- Why voxelize a clean low-poly model, when that makes it both uglier and heavier than the original ?
- Why rebuild an entire model by hand in Blockbench, when it already exists as a
.glb ?
- Why lose your skeleton, your animations and your textures on the way in ?
StargazerLib takes the other route: it loads the .glb as-is and renders the actual mesh through Minecraft's own pipeline, so lighting and shaders keep working. Skinning, animation clips (with cross-fading between them), textures and auto-scaling are all handled for you.
It is meant to be used by other mods much like GeckoLib, but you keep the Blender workflow your artists already use.
For developers
Drop your model in assets/<modid>/models/entity/<name>.glb, then have your entity declare it:
public class Dragon extends Entity implements GltfAnimatable {
public ResourceLocation getGltfModel() {
return new ResourceLocation("mymod", "dragon");
}
public float getGltfSize() {
return 2.0f; // ~2 blocks on the largest dimension
}
public void registerControllers(ControllerRegistrar registrar) {
registrar.add(new AnimationController<>("main",
state -> state.isMoving() ? "fly" : "idle"));
}
}
Then register the provided generic renderer:
event.registerEntityRenderer(DRAGON_TYPE, GltfEntityRenderer::new);
That's it, the Blender model shows up on your entity, animated and textured. Two demo entities (stargazerlib:gltf_test and stargazerlib:gltf_dragon) are included so you can see it in-game.
评论 0
登录后参与评分
还没有评论,来抢沙发吧