Working with Watermark

Contents
[ ]

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("template.3ds");

Encode Watermark

Aspose.3D adds watermark text information and watermark password to 3d files through the encodeWatermark method. The following code snippet shows how to use this functionality:

import java.io.IOException;

// Helper class that walks the node tree and encodes the blind watermark of every mesh
class WatermarkHelper {
    void encodeWatermark(Node node) throws IOException {
        Entity entity = node.getEntity();
        if (entity instanceof Mesh) {
            Mesh watermarked = Watermark.encodeWatermark((Mesh) entity, "HelloWorld", "1234");
            if (watermarked != null) {
                node.setEntity(watermarked);
            }
        }
        for (Object childObj : node.getChildNodes()) {
            encodeWatermark((Node) childObj);
        }
    }
}

// Encode a blind watermark into every mesh of the scene
new WatermarkHelper().encodeWatermark(scene.getRootNode());

Save Document

You can save to any 3d file format you want.The following code snippet shows how to use this functionality:

scene.save("output.fbx", FileFormat.FBX7400ASCII);