Working with Verify Watermark
Contents
[
Hide
]
Using the Aspose.3D for Java API, developers can easily verify the blind watermark of 3D files.
Watermarking requires a valid license — without it the operation is limited by the evaluation restrictions.
Create a 3D Scene
First you need to create a 3d scene from a 3d file.The following code snippet shows how to use this functionality:
Scene scene = Scene.fromFile("output.fbx");Decode Watermark
Aspose.3D uses the decodeWatermark method to confirm the watermark for the 3d file after filling in the password. The following code snippet shows how to use this functionality:
import java.io.IOException;
// Helper class that walks the node tree and reads the blind watermark of the first mesh that carries one
class WatermarkHelper {
String decodeWatermark(Node node) throws IOException {
Entity entity = node.getEntity();
if (entity instanceof Mesh) {
String text = Watermark.decodeWatermark((Mesh) entity, "1234");
if (text != null) {
return text;
}
}
for (Object childObj : node.getChildNodes()) {
String text = decodeWatermark((Node) childObj);
if (text != null) {
return text;
}
}
return null;
}
}
String text = new WatermarkHelper().decodeWatermark(scene.getRootNode());
System.out.println("Watermark: " + text);Document Confirmation
For the returned result, if the returned result is null, it means that there is no watermark added to the 3d document. If it returns text information, it is the watermark of the 3d file. If the password is entered incorrectly, a java.io.IOException is thrown.