Reputation: 43
I'm using libGdx 1.9.6 and I've got an issue. I've searched multiple forums, read various tutorials but nothing fits. I've created a simple cube in blender, textured it and export it to FBX (using fbx-conv). I've also downloaded the BDX-Blender-Exporter. I've tested Blender 2.69 and 2.76b without any changes to the result.
The model is loaded and shown :
If I change the background color to (0,0,0,0) or (0,0,0,1) then only a black screen appears.
Here's the code (libGDX 1.9.6, Android-Studio 2.3.3)
public class modelloader implements ApplicationListener {
private PerspectiveCamera camera;
private ModelBatch modelBatch;
private Model model;
private ModelInstance modelInstance;
private Environment environment;
private CameraInputController camController;
private AssetManager as;
@Override
public void create() {
camera = new PerspectiveCamera(
75,
Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
camera.position.set(0f,0f,7f);
camera.lookAt(0f,0f,0f);
camera.near = 0.1f;
camera.far = 300.0f;
modelBatch = new ModelBatch();
as = new AssetManager();
as.load("moon.g3db",Model.class);
as.finishLoading();
model = as.get("moon.g3db",Model.class);
model.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(1, 0, 0, 0);
modelInstance.transform.translate(0, 0, -2);
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.8f, 0.8f, 0.8f, 1.0f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.8f, 0.3f, 1f));
camController = new CameraInputController(camera);
camController.forwardTarget = true;
Gdx.input.setInputProcessor(camController);
}
@Override
public void dispose() {
modelBatch.dispose();
model.dispose();
}
@Override
public void render() {
camController.update();
Gdx.gl20.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl20.glClearColor(1,1,1,0);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
camera.update(true);
modelBatch.begin(camera);
modelBatch.render(modelInstance, environment);
modelBatch.end();
}
The model is also only shown when the line
model.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
exists.
Here's the blender file :
Where could be the problem?
Upvotes: 1
Views: 601
Reputation: 43
Holy mackerel, it was the texture file... it was 1024x1024 png... but somehow corruptet... once opened and resaved and all works.... countless hours and this is the only thing I've not checked... Thanks for the help guys! –
Upvotes: 1