*** Solved already. Solution added below.
So far I’m able to load up my objects that I’ve made in blender (2.5) and do animations, but now I want to have 1 object that can use different textures. So I UV mapped the model in blender and exported to a mesh.xml file. So I load it up as follows and it seems that the UV map didn’t export. I’m not really certain how to proceed with doing what I want to do here. Anyone familiar with doing this?
[java] Spatial CubeGuy = assetManager.loadModel(“Models/CubeGuy.mesh.xml”);
Material mat_default = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat_default.setTexture(“NormalMap”, assetManager.loadTexture(“Textures/TexturemapRev2.png”));
mat_default.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/TexturemapRev2.png”));
CubeGuy.setMaterial(mat_default);
CubeGuy.scale(1.05f, 1.05f, 1.05f);
CubeGuy.rotate(0.0f, -3.0f, 0.0f);
CubeGuy.setLocalTranslation(0.0f, -5.0f, -2.0f);
rootNode.attachChild(CubeGuy);
// You must add a light to make the model visible
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
rootNode.addLight(sun);[/java]
Update:
So, in other posts people talked about not flipping their texture and there was no clear answer as to what they did code-wise to fix it. Apparently my UV map was preserved in the mesh I made. I just needed to change
[java]Texture tex = assetManager.loadTexture(“Textures/TexturemapRev2.png”);[/java]
to
[java]Texture tex = assetManager.loadTexture(new TextureKey(“Textures/TexturemapRev2.png”, false));[/java]
1 Like