Hi.I tried to loa a .obj File with the following Code.The Shapes are visible after running the programm ,but the material textures are not.The Shape should look like lips because in the obj File i write:
usemtl lips
But the Shapes are just white.Here is the Code:
import com.jme.app.AbstractGame.ConfigShowMode;
import com.jme.app.SimpleGame;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.LightState;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.ObjToJme;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class HelloModelLoading extends SimpleGame {
private static final Logger logger = Logger
.getLogger(HelloModelLoading.class.getName());
public static void main(String[] args) {
HelloModelLoading app = new HelloModelLoading();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
// Turn the logger off so we can see the XML later on
app.start();
}
protected void simpleInitGame() {
Node node = loadGumsinNode();
//createLight(node);
rootNode.attachChild(node);
}
private Node loadGumsinNode() {
Node node = StringtoNode("uppergums.obj");
return node;
}
private Node loadTeethinNode(){
Node node = StringtoNode("11.obj");
return node;
}
private Node StringtoNode(String string){
URL model = HelloModelLoading.class.getClassLoader().getResource(
string);
FormatConverter converter = new ObjToJme();
converter.setProperty("mtllib", model);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
Node node = new Node();
try {
converter.convert(model.openStream(), BO);
node.attachChild( (Spatial) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray())));
} catch (IOException ex) {
Logger.getLogger(HelloModelLoading.class.getName()).log(Level.SEVERE, null, ex);
}
return node;
}
private void createLight(Node node){
// Create a point light
PointLight l = new PointLight();
// Give it a location
l.setLocation(new Vector3f(0, 10, 5));
// Make it a red light
l.setDiffuse(ColorRGBA.red.clone());
// Enable it
l.setEnabled(true);
// Create a LightState to put my light in
LightState ls = display.getRenderer().createLightState();
// Attach the light
ls.attach(l);
node.setRenderState(ls);
}
}