Aspose.3D for Java是獨立的Gameware和計算機輔助設計(CAD)API,用於處理3D文件。同時支持大多數流行的3D文件格式,應用程序能夠輕鬆建立,讀取,轉換和修改3D文件。此外,API還能夠幫助開發人員在遊戲中建模和建立大量世界,爲設計可視化建立出色的場景,參與虛擬現實體驗,將動畫屬性添加到3D場景文件,使用3D變換格式化元素等等。安全
在最新版的Aspose.3D for Java v19.8(點擊下載)中,新增在Wavefront OBJ中添加點雲支持,加強Aspose.3D的安全性審查,修復DRC到STL轉換失敗等多項問題,下面咱們用示例來演示該功能的使用和工做原理。動畫
/** * Gets the flag whether the exporter should export the scene as point cloud(without topological structure), default value is false */ public boolean getPointCloud(); /** * Sets the flag whether the exporter should export the scene as point cloud(without topological structure), default value is false * @param value New value */ public void setPointCloud(boolean value);
示例代碼生成一個obj格式的球面點雲。this
Scene scene = new Scene(new Sphere()); ObjSaveOptions opt = new ObjSaveOptions(); opt.setPointCloud(true); scene.save("sphere.obj", opt);
/** * Create a polygon with 4 vertices(quad) * @param v1 Index of the first vertex * @param v2 Index of the second vertex * @param v3 Index of the third vertex * @param v4 Index of the fourth vertex */ public void createPolygon(int v1, int v2, int v3, int v4); /** * Create a polygon with 3 vertices(triangle) * @param v1 Index of the first vertex * @param v2 Index of the second vertex * @param v3 Index of the third vertex */ public void createPolygon(int v1, int v2, int v3);
示例代碼:spa
Mesh mesh = new Mesh(); mesh.createPolygon(new int[] { 0, 1, 2 }); //The old CreatePolygon needs to create a temporary array for holding the face indices mesh.createPolygon(0, 1, 2); //The new overloads doesn't need extra allocation, and it's optimized internally.
/** * The JSON content of GLTF file is indented for human reading, default value is false */ public boolean getPrettyPrint(); /** * The JSON content of GLTF file is indented for human reading, default value is false * @param value New value */ public void setPrettyPrint(boolean value);
舊的prettyPrint是一個公共領域,它已被財產取代以保持一致。示例代碼:設計
Scene scene = new Scene(new Sphere()); GLTFSaveOptions opt = new GLTFSaveOptions(FileFormat.GLTF2); //opt.prettyPrint = true; //Old code opt.setPrettyPrint(true); //Use setter to change this configuration. scene.save("sphere.gltf", opt);