Before starting off, big thanks to jReality team. I have been using WriterPDF class for converting obj files to 3d pdf. The conversion takes place quite smoothly, but when I open it, the pdf file fails to load quickly, unlike normal files. It several minutes for it load. And even after completely loading, it slow. This is the case when I am trying to convert any obj file above 1000 Kb.
This is the code that I've used:
Code: Select all
public static void main(String[] args) {
// TODO code application logic here
// register the reader class for the OBJ-format
Readers.registerReader("OBJ", ReaderOBJ.class);
Readers.registerFileEndings("OBJ", "obj");
Scanner scan = new Scanner(System.in);// Enter the source file name
System.out.println("Source file path: ");
SceneGraphComponent content1 = null;
SceneGraphComponent content2 = null;
SceneGraphComponent content3 = null;
try {
content1 = Readers.read(new File("E:\\file0" + ".obj"));
content2 = Readers.read(new File("E:\\file1" + ".obj"));
content3 = Readers.read(new File("E:\\file2" + ".obj"));
SceneGraphComponent content = new SceneGraphComponent();
content.setName("Surface");
content1.setName("s_100_Geyer_Nordost");
content2.setName("s_101_Geyer_West");
content3.setName("s_33_Wiesenbad");
content.addChild(content1);
content.addChild(content2);
content.addChild(content3);
//U3D write
System.out.println("Enter the target path: ");
String destFileName = scan.nextLine() ;
WriterU3D wrt = new WriterU3D();
JrScene jrscene = new JrScene(content);
OutputStream out;
out = new FileOutputStream("E:\\" + destFileName + ".u3d");
wrt.writeScene(jrscene, out);
out.close();
// 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.setShowGrid(true);
pdfObject.setShowInventory(true);
pdfObject.setTool(WriterPDF.PDF3DTool.ROTATE);
//pdfObject.setSize(null);
OutputStream pdfOutput = new FileOutputStream("E:\\" + destFileName + ".pdf");
pdfObject.writeScene(new JrScene(content), pdfOutput);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Denzilgri