This discussion is archived
0 Replies Latest reply: Sep 14, 2012 3:48 AM by 962165 RSS

Java 3D Application With a Loaded Maya Scene

962165 Newbie
Currently Being Moderated
How Loaded Maya Scene in to Java 3D Application ?
when I run the application, I get "com.sun.j3d.loaders.ParsingErrorException: Unrecognized token, line 1" .
Please help me.

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.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.io.*;
public class A extends Applet{
public A() {
     setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);

BranchGroup scene = createSceneGraph();
scene.compile();

// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

// This moves the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
} // end of ObjLoad (constructor)

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

String filename = "D:/Maya/13.mb";

ObjectFile f = new ObjectFile();
Scene s = null;
try {
s = f.load(filename);
}
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());
return objRoot;
} // end of createSceneGraph method
//-----------------------------------------------------------------
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Frame frame = new MainFrame(new A(), 500, 500);
}
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points