Rendering GeometryΒΆ
There are many reasons to render geometry beyond the VTK based pyg4omety viewer. Potential targets are 3D asset packages (e.g. blender, houdini), games engines (unreal engine, unity). A common format is Universal Scene Description (USD). USD can be loaded in many packages and so a dedicated UDS converter/viewer is available in pyg4ometry. For example to load and convert a file to USD
1r = pyg4ometry.gdml.Reader("lht.gdml")
2l = r.getRegistry().getWorldVolume()
3v = pyg4ometry.visualisation.UsdViewer("lht.usd")
4v.traverseHierarchy(l)
5v.save()
This will write a file called lht.gdml which can be viewed in a USD viewer like usdview. USD has a preview shader. The settings can set via the VisualisationOptions stored in logical volumes (visOption), so for example
1r = pyg4ometry.gdml.Reader("lht.gdml")
2reg = r.getRegistry()
3reg.logicalVolumeDict["vCalorimeter"].visOptions.color = [1, 0, 0]
4v = pyg4ometry.visualisation.UsdViewer("lht.usd")
5v.traverseHierarchy(reg.getWorldVolume())
6v.save()
visOptions.colour and visOptions.alpha are passed though to the USD shader. There are many more options for shading in USD which can be accessed via visOptions.usdOptions
Here is an example of opening the usd file in usdview
USD can be imported to blender without any other conversion