hello, i have a problem with an obj Model.
I’ve created a model in Blender with a texture. It is a field for a game.
When i load this in java, no problems appear. But instead showing the texture, the model have a brown color.
Here two screens for it.
Texture:
scene with model:
And this is the relevant method:
protected void initGame() {
scene = new Node("scene");
pitch.fromAngleAxis(FastMath.PI / 2, new Vector3f(1,0,0));
ObjToJme converter = new ObjToJme();
try {
URL objFile = Test.class.getClassLoader().getResource(
"data/Feld6.obj");
converter.setProperty("mtllib", objFile);
converter.setProperty("texdir",objFile);
try {
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(Test.class.getClassLoader().getResource("data/")));
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ByteArrayOutputStream BO = new ByteArrayOutputStream();
System.out.println("Starting to convert .obj to .jme");
converter.convert(objFile.openStream(), BO);
//load as a TriMesh if single object
TriMesh model = (TriMesh) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray()));
model.setModelBound(new BoundingSphere());
model.updateModelBound();
model.setLocalRotation(pitch);
model.setLocalScale(5f);
model.updateRenderState();
scene.attachChild(model);
} catch (IOException e) {
e.printStackTrace();
}
scene.updateRenderState();
scene.updateGeometricState( 0, true );
scene.updateWorldBound();