Hi, I'm new to jME so I've just been playing with the tutorials a little.
I made a small landscape in 3ds Max and am trying to import it into the HelloSimpleGame project however i keep getting a "MalformedURLException: no protocol" error.
I'm using Netbeans 5.5 and the problem is that I'm not sure which directory I should be placing the model into. When I set an absolute dir such as "C:/landscape.3ds" it still throws the same exception.
Can anyone tell me where I should be placing my models? In the following example I just have URL("landscape.3ds"), which dir is this relating to?
I'm sure I have my code correct, however just in case, here it is:
public Node buildTerrain() {
Node r = null;
try {
MaxToJme C1=new MaxToJme();
ByteArrayOutputStream BO=new ByteArrayOutputStream();
URL maxFile=new URL("landscape.3ds");
C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
JmeBinaryReader jbr=new JmeBinaryReader();
jbr.setProperty("bound","box");
r = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
r.setLocalScale(.1f);
} catch (IOException e) {
System.out.println("Damn exceptions:"+e);
e.printStackTrace();
}
return r;
}
Gentleman Hal said:
You're getting that error because your URL is malformed :P
URL's need to include a protocol such as http or file to be valid.
Try new File("landscape.3ds").toURL() instead.
Thanks for actually answering his question, GH. :)
Take a look at the way the examples load models and such, it will give you a good basic understanding how to loading resources into your game.
You’re getting that error because your URL is malformed
URL’s need to include a protocol such as http or file to be valid.
Try new File(“landscape.3ds”).toURL() instead.
Actually toURL is deprecated in 1.6. It is preferrable to use File().toURI().toURL() instead.
Woo thanks
Had to read up on packages a lot too, (I'm a c++ programmer by heart).
But it works now so cheers guys