I have been spending hours trying to figure this out, but no tutorials that I’ve found have explained why this might be happening. I just started 3D modeling in Blender, and I’m finally starting to understand how to created models. I even managed to map a texture to my model in the program. The problem is importing the model into LibGDX. Whenever I do, the texture just doesn’t load. Here’s a picture of what happens when I try to load my models:
http://s30.postimg.org/3ngboq3j5/mylivinghell.png
Of course, a face texture should show up when there is a big rectangular blob. This is what the model looks like in Blender:
http://s12.postimg.org/3q8u8hspo/whycan_titlooklikethis.jpg
Here is a copy of my blender file, and a couple of exported versions if anyone is interested in sifting through my files:
Last, but not least, here is a copy of my rendering code:
package display;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g3d.Environment;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
import com.badlogic.gdx.math.Matrix4;
import util.ResourceManager;
/**
* Main screen used by project
* @author William Andrew Cahill
*
*/
public class DisplayScreen implements Screen
{
// 3D environment variables
private DisplayGame game; // Reference to game
private Environment environment; // Environment of models
private ModelBatch mBatch; // Batch used for rendering models
private PerspectiveCamera cam; // Camera used
private CameraInputController controller; // Camera controller
private AssetManager manager; // Asset manager
// Etc
private List<Model> models; // List of models loaded
private List<ModelInstance> instances; // List of model instances loaded
// Loading flag
private boolean loading;
/**
* Constructs a DisplayScreen
* @param game Game creating this Screen
*/
public DisplayScreen(DisplayGame game)
{
// Keeps reference of game
this.game = game;
// Constructs fields
mBatch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, .5f));
environment.add(new DirectionalLight().set(0.4f, 0.4f, 0.4f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0f, 5f, 10f);
//cam.lookAt(0,0,0);
cam.near = 1f;
cam.far = 300f;
cam.update();
controller = new CameraInputController(cam);
Gdx.input.setInputProcessor(controller);
// Loads main model
manager = new AssetManager();
manager.load("models/wigglesModel.g3db", Model.class);
loading = true;
// Constructs empty lists of models and their instances
models = new ArrayList<Model>();
instances = new ArrayList<ModelInstance>();
}
/**
* Finishes loading
*/
private void doneLoading()
{
// Loads models
models.add(manager.get("models/wigglesModel.g3db", Model.class));
// Particular instance
ModelInstance instance;
// Adds instances
instance = new ModelInstance(models.get(0));
instances.add(instance);
instance = new ModelInstance(models.get(0));
instance.transform.translate(5, 0, 0);
instances.add(instance);
loading = false;
}
@Override
public void render(float delta)
{
// Brings in data to render whenever ready
if(loading && manager.update())
doneLoading();
// Updates controller
controller.update();
// Camera clear data
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
// Begins rendering
mBatch.begin(cam);
mBatch.render(instances, environment);
for(int i=0; i<instances.size(); i++)
instances.get(i).transform.rotate(0, 1, 0, 1);
mBatch.end();
}
@Override
public void resize(int width, int height)
{
}
@Override
public void show()
{
}
@Override
public void hide()
{
}
@Override
public void pause()
{
}
@Override
public void resume()
{
}
@Override
public void dispose()
{
mBatch.dispose();
instances.clear();
manager.dispose();
}
}
Halp?