Hi
i tried the whole night to get it to work, i don't get it and do not know how to continue.
I know this problem have been posted several times, i tried these examples, but damm, my nice satellite in outer space does miss his textures.
first:
jme 1
StandardGame
Blender export to obj
// in a GameState extending GameState
ObjToJme converter = new ObjToJme();
try {
URL objFile = TestObjJmeWrite.class.getClassLoader().getResource(
"objects/mainMenu/satellite.obj");
// converter.setProperty("mtllib", objFile);
// converter.setProperty("texdir",objFile);
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()));
// Node model=(Node)BinaryImporter.getInstance().load(
// new ByteArrayInputStream(BO.toByteArray()));
//load as a node if multiple objects
model.setModelBound(new BoundingSphere());
model.updateModelBound();
rootNode.attachChild(model);
} catch (IOException e) {
e.printStackTrace();
}
rootNode.updateRenderState();
i tried it with
converter.setProperty("mtllib", objFile); converter.setProperty("texdir",objFile);
The .obj, .mtl and textures are all in the same dir, textures are png.
In Blender it looks fine, by exporting i select:
Context
Selection Only
Extra Data
Edges
Normals
High Quality No
Uv's
Materials
Triangulate
Grouping
Objects
Object Prefs.
Apply modifiers
Rotate X90
With this i got two different results.
When i try it with
converter.setProperty("mtllib", objFile);
converter.setProperty("texdir",objFile);
In my GameState i have also implemented
try {
ResourceLocatorTool.addResourceLocator(
ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(getClass().getResource(
"/objects/mainMenu/")));
} catch (Exception e) {
System.out.println("Unable to access texture directory.");
e.printStackTrace();
}
Last, sorry for my spelling, it's a some time ago i posted in english.
mfg
Drake