Disclaimer: The code in this post is written on version 9.0.7700 of Simplygon. If you encounter this post at a later stage, some of the API calls might have changed. However, the core concepts should still remain valid.
Using the aggregation pipeline you can enable volumetric geometry culling. This will remove all internal geometry, creating a hollow shell where the exterior is unaffected. It can be really helpful to clean up your object collections in kit bashing scenarios.
Let's take this rockpile, built up from a bunch of separate rocks, as an example.
Since the individual parts of this asset are intersecting with each other, there is geometry that isn't visible from the outside. We want to get rid of that.
Processing through the UI
We can process this using the UI in one of the integrations. Create a basic aggregation pipeline and turn on EnableGeometryCulling, if you want the culling to be more aggressive you can boost the precision at the cost of longer processing time. Here are the settings you want to run with.
This is the resulting object if we run the process. It looks like the same object, but we have removed almost 9k of the 22k+ polys that were not visible from the outside. The object looks the same as the original, but if you zoom in so that you see the insides you will notice that a lot of the internal geometry has been removed.
Processing through script
If you want you can also run the process through Python,C# or C++ code. Here is a Python snippet that sets up the aggregation pipeline in the same way.
def create_hollow_shell(sg, scene): aggregation_pipeline = sg.CreateAggregationPipeline() aggregator_settings = aggregation_pipeline.GetAggregationSettings() # Setting geometry culling will remove internal geometry aggregator_settings.SetEnableGeometryCulling(True) # The higher precision the longer the process will take, # but more internal geometry will be removed. aggregator_settings.SetGeometryCullingPrecision(0.5) # We want the resulting geometry to merged into one mesh aggregator_settings.SetMergeGeometries(True) # Now we can run the processing. aggregation_pipeline.RunScene(scene, Simplygon.EPipelineRunMode_RunInThisProcess)
When to use this method?
This method works well for geometry where you have a complete outer hull, and there is a lot of internal geometry that you want to get rid off. Typically this what would happen when you are using kit bashing workflows, combining smaller objects to create a larger object. It would also work for complex models, for example a complete car with all the bits and pieces, when you only want an exterior view of the object. The method is more precise than visibility based culling, but does rely on the objects exterior being watertight.
For a more detailed description on how to create a hollow shell script you can read this post.