I'm not sure how to use this. I have a model cube.obj. But I'm not sure where to put it. My project looks like this:
bin/
src/
org/
me/
LoadCube.java
I'd like my model to sit in
data/
model/
cube.obj
But when I set:
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL,
new SimpleResourceLocator(LoadCube.class
.getClassLoader().getResource(
"data/model/")));
I get on:
URL objFile = LoadCube.class.getClassLoader().getResource(
"cube.obj");
jme java.lang.NullPointerException
Where should I be putting the data? All the examples I find are using jmetest/data/. But I want to use a path relative to my project's path.
You should use the ResourceLocator to locate your Resource
URL objFile = LoadCube.class.getClassLoader().getResource(“cube.obj”);
ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL,“cube.obj”),
Then either put the data folder below the src folder:
src
data
model
cube.obj
org
me
Loadcube.java
Or if you want to keep src and data on the same level, define the data folder also as source folder in your IDE.
In Eclipse its Project properties -> Java build Path -> Source -> Add Folder.
src
org
me
data
model
How should it done after deployment? And how does it work with webstart? I'd hate to have all my images and models inside the jar file - but how should they be attached otherwise?
What about when you're loading a .jme file? I've noticed that when I export a model and save it into the binary format, and then when I load it up it tries to load the texture files from the absolute path of where the texture was when I saved it. Is there a way to save it in such a way that when you load the file, the textures are loaded from a relative texture folder (either done when saving to the binary format, or when loading it)?
May be a newb question, but I haven't had much luck finding a clear answer via search and at this point I think I'm confusing myself
if u r using resourceloator tool, the loaded binary file will automatically go to the directory u specified for the texture files.
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(textureDirectoryURL)));
Hi,
I am running in eclipse and my project runs fine.
The problem comes when I try and run standalone from a JNLP
The resourcelocator tool crashes out with a BaseDir cannot be Null error.
the code I have for setting up the Resource Locator is as follows
try {
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(CubeMobile.class.getResource("/data/textures)));
}catch (URISyntaxException e) {
e.printStackTrace();
}
This works totally fine in eclipse. If I remove this piece of code it works fine as a JNLP except it doesn't load any textures onto my models (it does load the models fine though) I am running my JNLP locally using the "Allow offline" setting in the eclipse webstart plug in. The data/textures/ directory is in the Runnable Jar that is part of the JNLP launch and the JNLP version is pulling models from the data/models/ directory just fine. Why doesn't the ResourceLocator work outside of eclipse???
Thanks in advance for a solution to this !
CH