浏览我们的产品
Aspose.3D for Java 22.4发行说明
此页包含Aspose.3D for Java 22.4的发行说明信息。
改进和变更
钥匙 | 摘要 | 类别 |
---|---|---|
THREEDNET-1116 | 节点的euleangle混淆导致模型旋转后的错误位置 | 错误修复 |
THREEDNET-1137 | 从FBX导入的LayeredTexture可能会生成无效的GLTF文件 | 错误修复 |
THREEDNET-1119 | 支持GLTF自定义顶点属性 | 新功能 |
THREEDNET-1129 | GLB到U3D转换导致方向错误 | 新功能 |
THREEDNET-1121 | 点云出口支持在USD/USDZ | 新功能 |
THREEDNET-1122 | 点云导入支持在USD/USDZ | 新功能 |
THREEDNET-1113 | 加载OBJ模型丢失纹理坐标vt | 错误修复 |
THREEDNET-1107 | 当应用程序构建为单个可执行文件时,无法加载许可证。 | 错误修复 |
API更改
需要此版本中的所有API更改才能通过TriMesh
导出glTF中的用户数据,下一个版本将支持Mesh
和VertexElementUserData
中的用户数据。
在类com.aspose.threed.VertexDeclaration
中添加了方法AddField:
/**
* Add a new vertex field
* @param dataType The data type of the vertex field
* @param semantic How will this field used for
* @param index The index for same field semantic, -1 for auto-generation
* @param alias The alias name of the field
*/
public VertexField addField(int dataType, VertexFieldSemantic semantic, int index, String alias);
新的AddField增加了一个新的参数别名要指定字段的别名,它的工作原理与SemanticAttribute的新添加构造函数完全相同。
添加成员到类com.aspose.threed.VertexField
:
/**
* Field's alias
*/
public String getAlias();
将自定义数据导出到glTF的代码段
private static void writeVertex(DataOutputStream writer,
float px, float py, float pz,
float nx, float ny, float nz,
float u, float v,
float batchId)
throws IOException
{
writer.writeFloat(px);
writer.writeFloat(py);
writer.writeFloat(pz);
writer.writeFloat(nx);
writer.writeFloat(ny);
writer.writeFloat(nz);
writer.writeFloat(u);
writer.writeFloat(v);
writer.writeFloat(batchId);
}
private static void exportCustomFieldToGLTF()
throws Exception
{
byte[] verticesInBytes;
try(var os = new ByteArrayOutputStream())
{
try(var writer = new DataOutputStream(os)) {
writeVertex(writer, 1, 0, 0, 0, 1, 0, 0, 0, 1);
writeVertex(writer, 1, 1, 0, 0, 1, 0, 0, 1, 2);
writeVertex(writer, 0, 1, 0, 0, 1, 0, 1, 0, 3);
writeVertex(writer, 0, 1, 1, 0, 1, 0, 1, 1, 4);
}
verticesInBytes = os.toByteArray();
}
var indices = new int[]
{
0, 1, 2,
1, 2, 3
};
//create a vertex declaration
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
vd.addField(VertexFieldDataType.FLOAT, VertexFieldSemantic.USER_DATA, -1, "_BATCH_ID");
//construct a TriMesh from raw bytes of vertices and indices
var mesh = TriMesh.fromRawData(vd, verticesInBytes, indices, false);
//create a scene with the mesh
var scene = new Scene(mesh);
//export the scene to a binary glTF file
scene.save("test.glb", FileFormat.GLTF2_BINARY);
// The GLTF primitive generated in the test.glb will be:
// {"attributes" : {"POSITION" : 1, "NORMAL" : 3, "TEXCOORD_0" : 2, "_BATCH_ID" : 4}, "mode" : 4}
}