I working on converting 'obj' file formats to 3d pdf. I've been able to convert obj files to 3d pdf but when I open the file, it just loads. Although I can see the embedded 3d components, it takes a long time to load(in minutes ranging on different computers).
This is the code that I am using:
Code: Select all
//the absolute path of the obj files are passed as command line arguments.
// TODO add your handling code here:
String destFileName= dest; //destination file
Readers.registerReader("OBJ", ReaderOBJ.class);
Readers.registerFileEndings("OBJ", "obj");
SceneGraphComponent content = new SceneGraphComponent();
SceneGraphComponent[] childContent = new SceneGraphComponent[top];
try {
for (int i = 0; i < childContent.length; i++) {
childContent[i] = new SceneGraphComponent();
childContent[i] = Readers.read(new File(src[i]));
BufferedReader bufReader = new BufferedReader(new FileReader(src[i]));
String line = bufReader.readLine();
String[] words = line.split("\\s");
childContent[i].setName(words[1]);
bufReader.close();
}
content.setName("Surfaces");
content.addChildren(childContent);
RemoveDuplicateInfo.simplifySceneTree(content);
// Embedding U3D into pdf file format
// and creating 3d pdf
WriterPDF pdfObject = new WriterPDF();
pdfObject.setGridMode(WriterPDF.PDF3DGridMode.GRID_MODE_OFF);
pdfObject.setLighting(WriterPDF.PDF3DLightingScene.WHITE);
pdfObject.setRenderMode(WriterPDF.PDF3DRenderMode.SOLID);
pdfObject.setShowInventory(true);
pdfObject.setTool(WriterPDF.PDF3DTool.ROTATE);
JrScene scene = new JrScene(content);
OutputStream pdfOutput = new FileOutputStream(destFileName);
pdfObject.writeScene(scene, pdfOutput);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Denzilgri