Simplygon 9 Documentation Simplygon 9 Documentation
Overview
Simplygon API
Maya
Max
UE4
Unity
Download
Overview
Simplygon API
Maya
Max
UE4
Unity
Download
  • Simplygon API
  • Getting started

  • API Concepts

  • Examples

    • Getting started
    • Aggregation

    • Aggregation pipeline

    • Material Casting

    • Batching

    • Events

      • Error Event
      • Progress Event
    • Scene

    • Reduction

    • Reduction pipeline

    • Remeshing

    • Remeshing pipeline

    • Shading networks

  • API Reference

    // Copyright (c) Microsoft Corporation. 
    // Licensed under the MIT license. 
    
    #include <string>
    #include <stdlib.h>
    #include <filesystem>
    #include <future>
    #include "SimplygonLoader.h"
    
    class CustomObserver : public Simplygon::Observer
    {
    	public:
    	bool OnProgress(Simplygon::spObject subject, Simplygon::real progressPercent) override
    	{
    		printf("Progress: %f\n", progressPercent);
    		// return false to abort the processing
    		return true;
    	}
    } customObserver;
    
    
    void RunReduction(Simplygon::ISimplygon* sg)
    {
    	// Create the reduction pipeline. 
    	Simplygon::spReductionPipeline sgReductionPipeline = sg->CreateReductionPipeline();
    
    	// Add the custom observer to the reduction pipeline. 
    	sgReductionPipeline->AddObserver(&customObserver);
    
    	// Start the reduction pipeline. 
    	sgReductionPipeline->RunSceneFromFile("../Assets/RiggedSimplygonMan/RiggedSimplygonMan.fbx", "output.fbx", Simplygon::EPipelineRunMode::RunInNewProcess);
    
    }
    
    void main()
    {
    	Simplygon::ISimplygon* sg = NULL;
    	Simplygon::EErrorCodes initval = Simplygon::Initialize( &sg );
    	if( initval != Simplygon::EErrorCodes::NoError )
    	{
    		return;
    	}
    
    	RunReduction(sg);
    
    	Simplygon::Deinitialize(sg);
    }
    
    
    
    // Copyright (c) Microsoft Corporation. 
    // Licensed under the MIT license. 
    
    using System;
    using System.IO;
    using System.Threading.Tasks;
    
    public class CustomObserver : Simplygon.Observer
    {
        public override bool OnProgress(Simplygon.spObject subject, float progressPercent)
        {
            Console.WriteLine($"Progress: {progressPercent}");
            // return false to abort the processing
            return true;
        }
    }
    
    public class Program
    {
        static private CustomObserver customObserver;
    
        static void RunReduction(Simplygon.ISimplygon sg)
        {
            // Create the reduction pipeline. 
            using (Simplygon.spReductionPipeline sgReductionPipeline = sg.CreateReductionPipeline())
            {
                // Add the custom observer to the reduction pipeline. 
                sgReductionPipeline.AddObserver(customObserver);
    
                // Start the reduction pipeline. 
                sgReductionPipeline.RunSceneFromFile("../Assets/RiggedSimplygonMan/RiggedSimplygonMan.fbx", "output.fbx", Simplygon.EPipelineRunMode.RunInNewProcess);
    
            }
        }
        static void Main(string[] args)
        {
            using (var sg = Simplygon.Loader.InitSimplygon(out var errorCode, out var errorMessage))
            {
                if (errorCode != Simplygon.EErrorCodes.NoError)
                    return;
                customObserver = new CustomObserver();
                RunReduction(sg);
            }
        }
    }
    
    
    # Copyright (c) Microsoft Corporation. 
    # Licensed under the MIT license. 
    
    import math
    import os
    import sys
    import glob
    import gc
    import threading
    
    from pathlib import Path
    from simplygon import simplygon_loader
    from simplygon import Simplygon
    
    class CustomObserver(Simplygon.Observer):
        def OnProgress(self, subject: Simplygon.spObject, progressPercent: float):
            print("Progress: %f" %(progressPercent))
            # return False to abort the processing
            return True
    
    customObserver = CustomObserver()
    
    def RunReduction(sg: Simplygon.ISimplygon):
        # Create the reduction pipeline. 
        sgReductionPipeline = sg.CreateReductionPipeline()
    
        # Add the custom observer to the reduction pipeline. 
        sgReductionPipeline.AddObserver(customObserver)
    
        # Start the reduction pipeline. 
        sgReductionPipeline.RunSceneFromFile("../Assets/RiggedSimplygonMan/RiggedSimplygonMan.fbx", "output.fbx", Simplygon.EPipelineRunMode_RunInNewProcess)
    
    
    if __name__ == '__main__':
        sg = simplygon_loader.init_simplygon()
    
        RunReduction(sg)
    
        sg = None
        gc.collect()
    
    
    

    ← Error Event FBX import and export →