Hi all!! i try to apply texture to a model (.3ds) but no work at all so i try to modify the example that came with jME
jmetest.renderer.loader.TestMaxJmeWrite
but didn't work at all the texture never applied to the model, can you help me with that? what its wrong in the code that i modified
protected void simpleInitGame() {
// code added for me to apply texture to a 3ds model
URL tex=TestMaxJmeWrite.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg");
TextureState ts1=display.getRenderer().createTextureState();
ts1.setTexture(TextureManager.loadTexture(tex,Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear));
ts1.setEnabled(true);
if (modelToLoad == null) {
modelToLoad = TestMaxJmeWrite.class.getClassLoader().getResource(
"jmetest/data/model/char.3ds");
}
try {
MaxToJme C1 = new MaxToJme();
ByteArrayOutputStream BO = new ByteArrayOutputStream();
C1.convert(new BufferedInputStream(modelToLoad.openStream()), BO);
Node r1 = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
//Node r = new Node("parent stuff");
//r.attachChild(C1.get(new BufferedInputStream(modelToLoad.openStream()), BO));
//r.setLocalScale(.1f);
r1.setLocalScale(.1f);
if (r1.getChild(0).getControllers().size() != 0)
r1.getChild(0).getController(0).setSpeed(20);
Quaternion temp = new Quaternion();
temp.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
rootNode.setLocalRotation(temp);
r1.setLocalTranslation(new Vector3f(10,0,0));
r1.setRenderState(ts1); // just apply the texture
//rootNode.attachChild(r);
rootNode.attachChild(r1);
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to load Max file", e);
}
}