Can someone look at this Java code for me?

  • Java
  • Thread starter the other guy
  • Start date
  • Tags
    Code Java
In summary: I'm guessing that's the problem and that the code is just supposed to be a snippet of a larger program.
  • #1
the other guy
19
0
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());
}

}
 
Technology news on Phys.org
  • #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?
 
  • #3
schip666! said:
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?

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.
 
  • #4
schip666! said:
What's it 'sposed to do, and what isn't it doing? Also not sure what the "ending parsing" you added is or why?

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?
 
  • #5
Mark44 said:
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?


Sorry. Forget the Parsing thing.

I'm trying to get a model to import and run in JAVA3D. a model from milkshape3d
 
  • #6
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.
 
  • #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...
 
  • #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()?
 

Related to Can someone look at this Java code for me?

1. What is the process for having someone look at my Java code?

The process for having someone look at your Java code may vary depending on the individual or platform you are seeking help from. Generally, you can share your code through a code-sharing website, via email, or through a version control system like GitHub. Be sure to clearly communicate what specific areas of your code you need help with and provide any necessary context or instructions.

2. How can I ensure that my code is easy for someone else to read and understand?

To make your code easier for someone else to read and understand, it is important to follow good coding practices such as using descriptive variable names, properly indenting your code, and adding comments to explain complex sections. Additionally, breaking your code into smaller, modular functions can also make it easier to understand and troubleshoot.

3. What should I do if someone points out errors or suggests improvements in my code?

If someone points out errors or suggests improvements in your code, it is important to thank them for their feedback and carefully consider their suggestions. Remember to stay open-minded and be willing to make changes to your code if necessary. Don't be afraid to ask for clarification or further explanation if needed.

4. Is it okay to ask for help with my code?

Yes, it is absolutely okay to ask for help with your code. In fact, seeking feedback and collaborating with others is a valuable part of the coding process. Just make sure to give credit and acknowledge the help you receive from others.

5. How can I improve my coding skills through having someone look at my code?

Having someone look at your code can be a great learning opportunity. Pay attention to the suggestions and feedback you receive, and try to incorporate them into your future coding practices. You can also ask the person looking at your code to explain their thought process and reasoning behind their suggestions, which can help you gain a better understanding of coding principles and techniques.

Back
Top