从服务器加载GLTF文件时,对象不是取原点,而是从底部算起位置(0,0,0), 但是当我们在同一文件中检入Blender时,所有对象的顺序都正确。
我们是否必须手动将GLTF中所有网格的顶点位置设置为原点,因为Sceneform不遵守它们的相对变换。
我尝试使用setRecenterMode(),但是没有用。
下面是我的代码
hair_render = ModelRenderable.builder()
.setSource(this, RenderableSource.builder().setSource(
this,
Uri.parse(hair_gltf),
RenderableSource.SourceType.GLTF2)
.setRecenterMode(RenderableSource.RecenterMode.NONE)
.build())
.setRegistryId(hair_gltf)
.build();
body_render = ModelRenderable.builder()
.setSource(this, RenderableSource.builder().setSource(
this,
Uri.parse(body_gltf),
RenderableSource.SourceType.GLTF2)
.setRecenterMode(RenderableSource.RecenterMode.NONE)
.build())
.setRegistryId(body_gltf)
.build();
top_render = ModelRenderable.builder()
.setSource(this, RenderableSource.builder().setSource(
this,
Uri.parse(top_gltf),
RenderableSource.SourceType.GLTF2)
.setRecenterMode(RenderableSource.RecenterMode.NONE)
.build())
.setRegistryId(top_gltf)
.build();
CompletableFuture.allOf(
body_render,
top_render,
hair_render)
.handle((notUsed, throwable) -> {
if (throwable != null) {
DemoUtils.displayError(this, "Unable to load renderable", throwable);
return null;
}
try {
body = body_render.get();
top = top_render.get();
hair = hair_render.get();
// Everything finished loading successfully.
hasFinishedLoading = true;
} catch (InterruptedException | ExecutionException ex) {
DemoUtils.displayError(this, "Unable to load renderable", ex);
}
return null;
});