阅读 3D 文档
Contents
[
Hide
]
3D 支持的格式列表 (导入)
Aspose.3D for Java API 支持阅读各种类型的 3D 文档。Scene
类的可用构造函数有助于这样做,它们接受有效的文件路径字符串。支持的可读文件格式如下:
- FBX 7.5 (ASCII,二进制)
- FBX 7.4 (ASCII,二进制)
- FBX 7.3 (ASCII,二进制)
- FBX 7.2 (ASCII,二进制)
- STL (ASCII,二进制)
- WavefrontOBJ
- Discreet3DS
- Universal3D
- Collada
- glTF
- DXF
- PLY (ASCII,二进制)
- X (ASCII,二进制)
- Draco
- 3MF
- RVM (文本,二进制)
- ASE
Scene类的构造函数在内部检测 3D 文档格式。
导入 3D 文档
Aspose.3D for Java API 支持导入各种类型的 3D 文档,用于修改、添加和处理。
读取 3D 场景: 编程示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the path to the documents directory. | |
String MyDir = RunExamples.getDataDir(); | |
// Initialize a Scene class object | |
Scene scene = new Scene(); | |
// Load an existing 3D document | |
scene.open(MyDir + "document.fbx"); |
使用 3D 属性
Aspose.3D API 允许您使用场景的子节点读取 3D 场景属性。下面的代码示例演示了此功能的用法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Java | |
String dataDir = RunExamples.getDataDir(); | |
Scene scene = new Scene(dataDir+ "EmbeddedTexture.fbx"); | |
Material material = scene.getRootNode().getChildNodes().get(0).getMaterial(); | |
PropertyCollection props = material.getProperties(); | |
//List all properties using for loop | |
for (Property prop:props) | |
{ | |
System.out.println("Name" + prop.getName() + " Value = " + prop.getValue()); | |
} | |
//or using ordinal for loop | |
for (int i = 0; i < props.size(); i++) | |
{ | |
Property prop = props.get(i); | |
System.out.println("Name" + prop.getName() + " Value = " + prop.getValue()); | |
} | |
//Get property value by name | |
Object diffuse = (Vector3)props.get("Diffuse"); | |
System.out.println(diffuse); | |
//modify property value by name | |
props.set("Diffuse", new Vector3(1, 0, 1)); | |
//Get property instance by name | |
Property pdiffuse = props.findProperty("Diffuse"); | |
System.out.println(pdiffuse); | |
//Since Property is also inherited from A3DObject | |
//It's possible to get the property of the property | |
System.out.println("Property flags = " + pdiffuse.getProperty("flags")); | |
//and some properties that only defined in FBX file: | |
System.out.println("Label = " + pdiffuse.getProperty("label")); | |
System.out.println("Type Name = " + pdiffuse.getProperty("typeName")); | |
//so traversal on property's property is possible | |
for (Property pp: pdiffuse.getProperties()) | |
{ | |
System.out.println("Diffuse. " + pp.getName() + " = " + pp.getValue()); | |
} |