Ok, I’m thinking this is just something really dumb on my part so here it is:
I’ve working on HelloModelLoading trying to get the code working for my own models. First off, the buildtest.xml fails on my system so I could not test the pure HelloModelLoading to see that it works. The error I get when running
“C:Documents and SettingsDavidMy DocumentsDevjme>ant -f buildtest.xml”
[javac] Compiling 136 source files to C:Documents and SettingsDavidMy DocumentsDevjmetestbuild
[javac] C:Documents and SettingsDavidMy DocumentsDevjmesrcjmetestTutorialGuideHelloAnimation.java:4: package com.jme.scene.shape does not exist
[javac] import com.jme.scene.shape.Box;
[javac] ^
This is using the CVS tree I checked out 1.5 hours ago. I blew away my old copy and grabbed it fresh just to be sure.
The whole reason I was trying to run the test was in my own version of HelloModelLoading I am getting a java.lang.NullPointerException when I try "converter.convert". I tracked the problem down to the URL object being a null pointer.
URL model = Main.class.getClassLoader().getResource("maggie.obj");
FormatConverter converter = new ObjToJme();
converter.setProperty("mtllib", model);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
JmeBinaryReader jbr = new JmeBinaryReader();
try
{
System.out.println((model==null));
converter.convert(model.openStream(), BO);
Node baby = new Node("Maggie");
baby.setLocalScale(.1f);
baby = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
rootNode.attachChild(baby);
}
I have an ant build file that jar's all that up and then I put the maggie model and material file in the same directory. The
System.out.println((model==null));
is always true no matter how I switch my paths around in my run command (also part of my ant buildfile). I guess I don't really get where the "root" of the path is when using a relative path. I would think it would be where the jar being executed is or perhaps where I'm running the ant file from. Sorry if this is a dumb problem but I've been messing with this for 4 hours now and it's terribly frustrating. 8-O
I should have mentioned that I can do "ant dist" and that works fine, I get the jme.jar no problem.
hmmm
when you do an ant dist, do you still have the class files? or is just the jar there?
Under the build/com/jme directory I have all of the various directories that appear in src/com/jme. All of them seem to have the appropriate .class files based on what is in the /src/com/jme directories.
I’m also getting plenty of errors using the buildtest.xml file. Looking into it.
Ok, I just did:
ant
ant dist
ant -f buildtest.xml
and it worked. shrug
see if that helps.
Ok, thank you very much that worked for me too. I finally realized my errors and I will write out my solution so anyone else unfamiliar with the Java path system can avoid my many wasted hours.
First off I did not realize that there is no common "base" directory from which your app is running. I thought that you could make a relative path /assets/models/maggie.obj whithout also including the parent folder of /assets in the classpath. This seems to have been my biggest problem. For anyone having a similar issue, here was my directory structure.
/palabra
/lib
/assets/models <-- I copied the file from here to /publish in the previous post to resolve the path issues
/src/com/hcs/palabra
/bin/com/hcs/palabra
/publish
/assets/models <-- these are copied from /lib and /assets/models
/lib
Ok, so now I was using an ant build as I could not figure out how to get even the command line working :// This is the command line that I should have been using.
java -Djava.library.path=./lib -cp ./lib/lwjgl.jar;./lib/jme.jar;./publish -jar publish/palabra.jar
or in non-jar form
java -Djava.library.path=./lib -cp ./lib/lwjgl.jar;./lib/jme.jar;./publish;./bin com.hcs.palabra.Main
For the non-jar version the "./bin" must be added to the path as well.
Because I was not including the "./publish" nor was I including "./" the "/assets/models/maggie.obj" path had no root to start from and couldn't be found. Alternatively I could have referenced "./" instead of "./publish" in the classpath because there is an "/assets" in the root folder.
Phew. Thank you mojo for your help in getting me down the right path. Would it be of any use to newbies if I posted my build.xml file so others could see how I set up my project? If so just let me know where you want it.