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

Can someone look at this Java code for me?

  1. Jul 10, 2010 #1
    im starting a project from an Ebook that seems to be missing a line or two or something. Can someone suggest what should be here? I added the ending parsing since it was one of the more obvious missing things.


    import com.sun.j3d.loaders.*;
    import com.glyphein.j3d.loaders.milkshape.MS3DLoader;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.universe.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import javax.media.j3d.BranchGroup;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.ParsingErrorException;
    import com.sun.j3d.loaders.IncorrectFormatException;
    import com.sun.j3d.loaders.Scene;
    import java.applet.Applet;
    import java.io.*;

    class bob extends Applet {
    // Loader loader = new MS3DLoader(MS3DLoader.LOAD_ALL);

    private String filename = null;

    public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    Loader raptor = new MS3DLoader(MS3DLoader.LOAD_ALL);
    Scene s = null;
    try {
    s = raptor.load("Ships/raptor.MS3D");
    }
    catch (FileNotFoundException e) {
    System.err.println(e);
    System.exit(1);
    }
    catch (ParsingErrorException e) {
    System.err.println(e);
    System.exit(1);
    }
    catch (IncorrectFormatException e) {
    System.err.println(e);
    System.exit(1);
    }

    objRoot.addChild(s.getSceneGroup());
    }

    }
     
  2. jcsd
  3. Jul 10, 2010 #2
    OK, I looked at it...

    Without actually formatting it so I can grok the braces, it looks like it oughta compile.

    What's it 'sposed to do, and what isn't it doing? Also not sure what the "ending parsing" you added is or why?
     
  4. Jul 10, 2010 #3
    It's supposed to load a milkshape3d model. I know i didnt put in a universe or anything standard like that yet (trying to keep posted code simple), but for some reason, I can't get the all clear from my editor for the code.

    There was origionally one parsing at the end, but I added another to close it off.
     
  5. Jul 10, 2010 #4

    Mark44

    Staff: Mentor

    I don't get the "ending parsing" bit, either. What "parsing" bit are you talking about?

    To expand on schip666!'s questions, what problems are you having? Are you getting compiler errors or run-time errors or what?
     
  6. Jul 10, 2010 #5

    Sorry. Forget the Parsing thing.

    I'm trying to get a model to import and run in JAVA3D. a model from milkshape3d
     
  7. Jul 10, 2010 #6

    Mark44

    Staff: Mentor

    Again, what problems are you having? Are you getting compiler errors or run-time errors or what? If you don't give us some idea of where you're stuck it's very difficult to provide any help.
     
  8. Jul 11, 2010 #7
    This is a good example of a curious phenomenon in these sorts of "help" forums....
    There is obviously some kind of problem, but the poster doesn't seem to have enough experience -- yet -- to know what to specify, or how to capture the output, in order to get help.

    Phrases like "added ending parsing" and "getting the all-clear from my editor" make wonderful sense -- to the poster -- but only open further cans'o'worms for the rest of us riff-raff. Providing the missing context and actual errors is what we need here, e.g.,
    by "all-clear from my editor" I'm suspecting that "editor" means the development system
    and that there's a compile time error of some sort. But without having exactly the same, unspecified, system, we are somewhat en-darkened....
     
  9. Jul 12, 2010 #8
    By "ending parsing" the original poster means the closing curly bracket "}".

    Not sure what's wrong with the code. Maybe the lack of main()?
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook