R
R
ratatyq2017-03-11 21:19:36
libgdx
ratatyq, 2017-03-11 21:19:36

Why are textures not drawn on 3d models in libGdx?

Hello, I'm trying to display a cube with textures in an android application using the libGdx library. At first, a white cube was simply drawn, then a DirectionLight light was added and now the color of the cube is drawn (which is by default during modeling), and I can't figure out how to display the texture, because the tutorials just need to add an object to the scene with light and everything will be ok....
Here is my code:

// Создаю assetMananger =>
 assetMananger = new AssetManager();
 assetMananger.load("models/box/box.obj", Model.class);
// загружаю куб в методе create =>
         Model model = game.assetMananger.get("models/box/box.obj", Model.class);
        modelInstance = new ModelInstance(model);
        modelInstance.transform.setTranslation(0f, 0f, 0f);
// Создаю свет =>
 environment = new Environment();
 environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
 environment.add(new DirectionalLight().set(com.badlogic.gdx.graphics.Color.BLUE, 1,650,1));
// Создаю камеру =>
 camera = new PerspectiveCamera(45,Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
 camera.position.set(0,625,0);
 camera.lookAt(0f,0f,0f);
 camera.far = 6000;
 camera.near = 0.01f;
 camera.update();
// В методе render рендерю модели =>
 Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
 camera.update();
 modelBatch.begin(camera);
 modelBatch.render(modelInstance, environment);
 modelBatch.end();

The model itself consists of a .tga texture, an .obj object itself, and an .mta file

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question