[vtkusers] Influence of vtkProperties on Opacity/Color from Lookuptable
Rolf Mueller
rolf.mueller at uni-tuebingen.de
Sun Jan 5 16:31:04 EST 2003
Dear vtkusers,
I would like to render a sphere which intersects a second sphere. The
second sphere (while invisible itself) should determine the opacity of
the surface of the first, e.g., portions of the first which are are
inside the second should have an opacity of 0.3 and portions outside
an opacity of 1.0.
I have managed to assign different colors to the in- and out-portions
or get different opacity and gray-scale surfaces, but not colored
surfaces (same or different) and different opacity. The vtkProperty
passed to the actor seems to play a role here, but I don't understand
what the mechanisms are and how to tweak it so that I could get the
desired result. It seems that whether I set Ambient>=Diffuse
determines if I see the uniform color or the gray of varying
opacity.
My script is included below. I would be very thankful for any insight
into this.
Best regards,
Rolf
---
vtkSphereSource sphere1
sphere1 SetRadius 1.0
sphere1 SetPhiResolution 10
sphere1 SetThetaResolution 10
vtkSphere sphere
sphere SetCenter .5 0 0
sphere SetRadius 1
vtkSampleFunction spheresmpl
spheresmpl SetImplicitFunction sphere
spheresmpl SetModelBounds -3 3 -3 3 -3 3
spheresmpl SetSampleDimensions 50 50 50
vtkProbeFilter probe
probe SetInput [sphere1 GetOutput]
probe SetSource [spheresmpl GetOutput]
probe Update
vtkProperty sprop1
sprop1 SetRepresentationToSurface
sprop1 EdgeVisibilityOff
sprop1 SetAmbient 0.5
sprop1 SetDiffuse 0.5
vtkLookupTable lut
lut SetNumberOfTableValues 2
lut SetTableRange -1 1
lut SetTableValue 0 1.0 0.0 0.0 0.3
lut SetTableValue 1 1.0 0.0 0.0 1.0
lut SetScaleToLinear
vtkCamera camera
vtkDepthSortPolyData depthSort
depthSort SetInput [probe GetOutput]
depthSort SetDirectionToBackToFront
depthSort SetCamera camera
depthSort SortScalarsOn
depthSort Update
vtkPolyDataMapper sphere1mapper
sphere1mapper SetLookupTable lut
sphere1mapper SetInput [depthSort GetOutput]
sphere1mapper SetUseLookupTableScalarRange 1
vtkActor sphere1actor
sphere1actor SetMapper sphere1mapper
sphere1actor SetProperty sprop1
vtkRenderer ren
ren AddActor sphere1actor
ren SetActiveCamera camera
ren ResetCamera
ren SetBackground 1 1 1
vtkLight lght
lght SetLightTypeToCameraLight
lght SetColor 1 1 1
lght SetIntensity 1
eval lght SetPosition [camera GetPosition]
eval lght SetFocalPoint [camera GetFocalPoint]
ren AddLight lght
vtkRenderWindow renwin
renwin AddRenderer ren
renwin SetSize 300 300
vtkRenderWindowInteractor iren
iren SetRenderWindow renwin
iren Initialize
wm withdraw .
More information about the vtkusers
mailing list