3D Formats Conversion Via Java

Convert 3D file formats without any 3D modeling and rendering software installation to build cross-platform Java applications.

 

For creating, editing, manipulating and saving three-dimensional graphics applications, Java 3D API provides high level of methods to do such features without installation of any 3D modeling and rendering software. Few are build the mesh of different three-dimensional geometric shapes, create a 3D scene file, set up normals or UV on the Cube, format elements, add animation property and more.

Convert 3D File to different formats

Conversion process is simple. Just load the source 3D file using Scene class . As scene is a top-level object having the nodes, geometries, textures, materials, animation, poses, sub-scenes etc. Create the relevant the Save options such as AmfSaveOptions, ColladaSaveOptions, Discreet3dsSaveOptions, DracoSaveOptions, FbxSaveOptions, GltfSaveOptions, RvmSaveOptions, StlSaveOptions, U3dSaveOptions etc and set the properties accordingly. Finally call the save method with output file and created target format save options object. Further more, Using the API programmers can even save 3D scene as HTML.

Java Code for AMF to 3DS Conversion
// load the AMF in an object of Scene
Scene amfto3ds = new Scene("template.amf");
// create an instance of 3dsSaveOptions
Discreet3dsSaveOptions options = new Discreet3dsSaveOptions();
// save AMF as a 3DS
amfto3ds.save("output.3ds", options);
Convert 3D Scene to HTML via Java
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Java
// Initialize a scene
Scene scene = new Scene();
// Initialize a node
Node node = scene.getRootNode().createChildNode(new Cylinder());
// Set child node properites
LambertMaterial mat = new LambertMaterial();
mat.setDiffuseColor(new Vector3(0.34,0.59, 0.41));
node.setMaterial(mat);
Light light = new Light();
light.setLightType(LightType.POINT);
scene.getRootNode().createChildNode(light).getTransform().setTranslation(10, 0, 10);
// Initialize HTML5SaveOptions
HTML5SaveOptions opt = new HTML5SaveOptions();
// Turn off the grid
opt.setShowGrid(false);
//Turn off the user interface
opt.setShowUI(false);
scene.save(RunExamples.getDataDir() + "html5SaveOption.html", FileFormat.HTML5);