Hi there!
I've been struggling my mind trying to fix an error Ive been reported. When I try to load a 3ds model everything is all right but the texture is not found. I put it in the same directory with the 3ds file, and I created a new ResourceLocator setting up that directory, but nothing changed.Find below the code I use:
public void buildPlayer(){
this.keyboard = KeyBindingManager.getKeyBindingManager();
this.character = new Node ("Character");
try{
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(MainCharacter.class.getClassLoader().getResource("data/model/table/"))); }catch (URISyntaxException e1){
logger.log(Level.WARNING,"unable to setup texture directory.",e1);
}
MaxToJme converter = new MaxToJme();
URL MSFile = MainCharacter.class.getClassLoader().getResource("data/model/table/table.3ds");
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try {
converter.convert(MSFile.openStream(), BO);
}catch (IOException e){
logger.info("IO problem writting the file");
logger.info(e.getMessage());
System.exit(0);
}
try{
this.character = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
}catch (IOException e){
logger.info("darn exceptions:"+e.getMessage());
}
this.character.setLocalTranslation(new Vector3f (100,0,100));
this.character.setLocalScale(7f);
this.character.setModelBound(new BoundingBox());
this.character.updateModelBound();
jc = ((JointController) this.character.getController(0));
jc.setTimes(0,0);
jc.setRepeatType(Controller.RT_WRAP);
jc.setActive(false);
keyboard.set("walk", KeyInput.KEY_W);
keyboard.set("walk2", KeyInput.KEY_S);
keyboard.set("jump", KeyInput.KEY_X);
}
Any help much appreciated, this trouble is coming up again and again with all the 3ds models I try!
Thank you!
do a
converter.setProperties(texdir, yourTextureDirectoryURL);
Thank u! I will try it later on and I'll post whether it works or not.