Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

JAVA3D Loader Help

  1. Jul 6, 2010 #1
    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 [Broken]

    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 cant help me- or ...i dunno, maybe im 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: May 4, 2017
  2. jcsd
  3. Jul 6, 2010 #2

    Filip Larsen

    User Avatar
    Gold Member

    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?
  4. Jul 15, 2010 #3
    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 (Text):
    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.*;
    10. public class ObjLoad extends Applet {
    12. private String filename = null;
    14. public BranchGroup createSceneGraph() {
    15. // Create the root of the branch graph
    16. BranchGroup objRoot = new BranchGroup();
    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. }
    36. objRoot.addChild(s.getSceneGroup());
    37. }
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - JAVA3D Loader Help Date
C/++/# Help with MATLAB code? Feb 9, 2018
Java3D graphics Nov 23, 2012
Java3D graphics: solid line looks dashed Aug 19, 2012
JAVA3d help Jul 9, 2010
Macromedia flash Professional 8 loaders and scroll panes help Apr 18, 2009