Skip to content

Instantly share code, notes, and snippets.

@kwahoo2
Last active October 28, 2024 17:15
Show Gist options
  • Save kwahoo2/92fde23a56e9787a0cf820429fbddee7 to your computer and use it in GitHub Desktop.
Save kwahoo2/92fde23a56e9787a0cf820429fbddee7 to your computer and use it in GitHub Desktop.
SoEnvironment usage in FreeCAD scene
# SoEnvironment usage in FreeCAD scene
# https://www.coin3d.org/coin/classSoEnvironment.html
# https://forum.freecad.org/viewtopic.php?p=785643#p785643
from pivy.coin import SoEnvironment
se = SoEnvironment() # create a new node
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
sg.insertChild(se, 1) # add the node at the beginning of our scene
se.ambientIntensity.getValue() # read value for current ambient light eg.: 0.2
se.ambientIntensity.setValue(0.8) # set a new value for ambient light, can be higher than 1 too, since it is multiplied by AmbientColor property of a material
# add fog
se.fogType = SoEnvironment.HAZE
# different type of fog
se.fogType = SoEnvironment.SMOKE
# make the fog red
from pivy.coin import SbColor
se.fogColor = SbColor(1, 0, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment