hacked shadows

This commit is contained in:
Michael Stumpf 2021-07-26 12:57:13 +02:00
parent 6e98a76e03
commit 5e5a19dd06
1 changed files with 22 additions and 2 deletions

24
visu.py
View File

@ -1,7 +1,27 @@
def add_domain_bounds(plotter,bounds,color='black',line_width=2.):
import pyvista
domain = pyvista.Box(bounds=bounds)
plotter.add_mesh(domain,color=color,style='wireframe',line_width=line_width)
plotter.add_mesh(domain,color=color,style='wireframe',line_width=line_width,opacity=0.999,lighting=False)
return
def enable_shadows_hacked():
# Reimplements pyvistas "enable_shadows()" method to also render translucent
# objects (without shadows). Can be used to add objects which do not throw
# shadows (but may look weird) by setting their opacity to a value close to 1,
# e.g. 0.999. This is useful when drawing a bounding box using "add_domain_bounds()".
import vtk
shadows = vtk.vtkShadowMapPass()
transl = vtk.vtkTranslucentPass()
seq = vtk.vtkSequencePass()
passes = vtk.vtkRenderPassCollection()
passes.AddItem(shadows.GetShadowMapBakerPass())
passes.AddItem(shadows)
passes.AddItem(transl)
seq.SetPasses(passes)
# Tell the renderer to use our render pass pipeline
cameraP = vtk.vtkCameraPass()
cameraP.SetDelegatePass(seq)
pl.renderer.SetPass(cameraP)
return
def setup_camera(pl,bounds,viewvec,dist=None,parallel_projection=False,
@ -107,4 +127,4 @@ def translate_circular(pd,translation,bounds,axis=0):
pd_lo.translate(shift_forw)
pd_hi.translate(shift_back)
# return the merged PolyData
return pd_lo+pd_hi
return pd_lo+pd_hi