null72
May 12, 2009, 10:26pm
1
So I have a object model that I'm importing into jME and it's simply not looking good at all.
http://i40.tinypic.com/ezmlqx.jpg
that's what it looks like, nothing what it looks like in blender. Everything in blender is much smoother and cleaner looking whereas that model is well, triangle - ee. Here's my source code for building the model…
private void buildPlayer() {
URL folder= DarkRune.class.getClassLoader().getResource("simplegame/");
URL model = DarkRune.class.getClassLoader().getResource("simplegame/java_girl_body1.obj");
FormatConverter converter=new ObjToJme();
converter.setProperty("mtllib", folder);
converter.setProperty("texdir", folder);
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
converter.convert(model.openStream(), BO);
fem=(Spatial) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
fem.setLocalScale(1f);
fem.setModelBound(new BoundingBox());
fem.updateModelBound();
} catch (Exception e) {
System.out.println("Damn exceptions! O_o n" + e);
e.printStackTrace();
System.exit(0);
}
player = new Node("Player Node");
player.setLocalTranslation(new Vector3f(100,0, 100));
scene.attachChild(player);
player.attachChild(fem);
player.updateWorldBound();
}
Did you export smoothgroups? You might need to check a button to do so.
you have to set a ShadeState as Renderstate onto you model, with "smooth" option.
It might be that this only works if you have "setSmooth" to the model in blender.
And the "ShadeState" was available in jme1 … i think it's still in jme2, too.
just give it a try.
null72
May 12, 2009, 11:10pm
4
Tried using shadestate but with no luck. I used set smooth in blender as well.
private void buildPlayer() {
URL folder= DarkRune.class.getClassLoader().getResource("simplegame/");
URL model = DarkRune.class.getClassLoader().getResource("simplegame/female.obj");
FormatConverter converter=new ObjToJme();
converter.setProperty("mtllib", folder);
converter.setProperty("texdir", folder);
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
converter.convert(model.openStream(), BO);
fem=(Spatial) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
fem.setLocalScale(1f);
fem.setModelBound(new BoundingBox());
fem.updateModelBound();
} catch (Exception e) {
System.out.println("Damn exceptions! O_o n" + e);
e.printStackTrace();
System.exit(0);
}
final ShadeState smoothShadeState = display.getRenderer().createShadeState();
smoothShadeState.setShadeMode( ShadeState.ShadeMode.Smooth );
fem.setRenderState( smoothShadeState );
player = new Node("Player Node");
player.setLocalTranslation(new Vector3f(100,0, 100));
scene.attachChild(player);
player.attachChild(fem);
player.updateWorldBound();
}
nymon
May 12, 2009, 11:33pm
5
Also make sure you export with "high quality normals" selected. Don't know what difference this will make, but I always use it and the normals come out correct.
null72
May 13, 2009, 12:08am
6
nymon said:
Also make sure you export with "high quality normals" selected. Don't know what difference this will make, but I always use it and the normals come out correct.
Excellent. This fixed the problem. Thank you!! :)
nymon
May 13, 2009, 4:17pm
7
null72 said:
Excellent. This fixed the problem. Thank you!! :)
Haha wow! I really didn't expect it to.