Java3D Loader Help: Getting Started

  • Context: Java 
  • Thread starter Thread starter the other guy
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
the other guy
Messages
19
Reaction score
0
May I begin with the fact that this entire situation is suffering from a serious "where's the 'readme' file" complex

Ok, so I'm a seasoned 3d modeler trying to learn Java3d. I have java3d, the complimentary JDK, and this loader
http://www.duling.us/kevin/Java3D/Milkshape/index.html

Problem is, I don't know what to do with the loader. Everywhere I look on the internet just says to type in the appropriate code, and I do, but the thing is I can't find where I'm supposed to put the Loader.

I'm missing a step, and I can't find it via online search. The step between downloading the Loader, and inserting the appropriate code. Here is the sample code. It doesn't do anything, but it should work as far as the use of the Loader. What do I do wiht this MS3DLoader?

sorry for asking, but I totally seem to have either described my problem so poorly the internet can't help me- or ...i dunno, maybe I am depressed. the days are longer, ...i dunno.

import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
import com.sun.j3d.loaders.*;
import com.glyphein.j3d.loaders.milkshape.MS3DLoader;
public class core {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}

}
 
Last edited by a moderator:
Physics news on Phys.org
Maybe I misunderstand what your problem is, but on the page you refer to there is a link to a file Viewer.java containing a main method that takes the model filename as parameter and then seems to initialize the modeler. Have you tried that?
 
I'm also learning Java3D; however I haven't learned enough to implement a loader quite yet either. I assume you have looked at Sun's tutorials online but if not, I hope this helps: http://java.sun.com/developer/onlineTraining/java3d/j3d_tutorial_ch3.pdf. I believe your answer may be on p. 3-3 within example code line 21.

Code:
1. import com.sun.j3d.loaders.objectfile.ObjectFile; 
2. import com.sun.j3d.loaders.ParsingErrorException; 
3. import com.sun.j3d.loaders.IncorrectFormatException; 
4. import com.sun.j3d.loaders.Scene; 
5. import java.applet.Applet;
6. import javax.media.j3d.*;
7. import javax.vecmath.*;
8. import java.io.*; 
9.
10. public class ObjLoad extends Applet {
11.
12. private String filename = null;
13.
14. public BranchGroup createSceneGraph() {
15. // Create the root of the branch graph
16. BranchGroup objRoot = new BranchGroup();
17.
18. ObjectFile f = new ObjectFile();
19.  Scene s = null;
20.  try {
21. s = f.load(filename);
22. }
23. catch (FileNotFoundException e) {
24. System.err.println(e);
25. System.exit(1);
26. }
27. catch (ParsingErrorException e) {
28. System.err.println(e);
29. System.exit(1);
30. }
31. catch (IncorrectFormatException e) {
32. System.err.println(e);
33. System.exit(1);
34. }
35.
36. objRoot.addChild(s.getSceneGroup());
37. }