Как исправить отображение текстур obj/g3dj в LibGDX Java
Нужно создать приложение отображающие объекты (их создаю в Blender). Далее есть возможность сохранить в формате obj или fbx. По гайдам понял, что есть два варианта: перевести в G3DB/G3DJ или пользоваться самим obj форматом. Однако G3DB/G3DJ просто не отображает объект. А obj выводит полностью белый объект без текстур. Прошу указать в чем ошибка в использовании G3DB/G3DJ или сказать как показать текстуры на obj.
Фрагмент кода mtl файла
"materials": [
{
"id": "Default OBJ",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.001547, 0.000055, 0.000055],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 1.000000,
"specular": [ 0.001547, 0.000055, 0.000055],
"shininess": 25.000000
},
{
"id": "Material",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.051959, 0.004757, 0.157481],
"emissive": [ 0.008614, 0.000655, 0.027222],
"opacity": 1.000000,
"specular": [ 0.051959, 0.004757, 0.157481],
"shininess": 15.999998
},
{
"id": "Material.002",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 1.000000,
"specular": [ 0.800000, 0.800000, 0.800000],
"shininess": 25.000000
},
{
"id": "Material.003",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 1.000000,
"specular": [ 0.800000, 0.800000, 0.800000],
"shininess": 25.000000
},
{
"id": "Material.006",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 1.000000,
"specular": [ 0.800000, 0.800000, 0.800000],
"shininess": 25.000000,
"textures": [
{
"id": "base_color_texture",
"filename": "thumb_l_2612.jpg",
"type": "DIFFUSE"
}
]
}
],
Основной класс
public class Main extends ApplicationAdapter {
public Environment environment;
public PerspectiveCamera cam;
public CameraInputController camController;
public ModelBatch modelBatch;
public Model model;
public ModelInstance instance;
public AssetManager assets ;
@Override
public void create() {
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
modelBatch = new ModelBatch();
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(5,5,5);
cam.lookAt(0, 10, 0);
cam.near = 1f;
cam.far = 300f;
cam.update();
assets = new AssetManager();
assets.load("fall_sleepy.obj", Model.class);
assets.finishLoading();
model = assets.get("fall_sleepy.obj", Model.class);
instance = new ModelInstance(model);
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
}
@Override
public void render() {
camController.update();
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(cam);
modelBatch.render(instance, environment);
modelBatch.end();
}
@Override
public void dispose() {
modelBatch.dispose();
assets.dispose() ;
}
}