[vtkusers] vtkSphereSource and vtkGlyph3D ignores alpha values
Henrik Westerberg
henrik.westerberg at crg.es
Thu Apr 29 08:26:23 EDT 2010
Hi Folks,
I am having a problem with making individual spheres transparent using a sphereSource -> glyph3D pipeline.
The alpha values work just fine with a cubeSource but not with sphereSource. I have included some code modified
from the example in the wiki on how to color glyphs.
Is there any way to make spheres transparent on a per glyph basis? as I prefer spheres to cubes for a visualisation
I'm working on.
thanks,
Henrik
pts = vtkPoints()
pts.InsertNextPoint(0,0,0)
pts.InsertNextPoint(5,0,0)
pts.InsertNextPoint(10,0,0)
pts2 = vtkPoints()
pts2.InsertNextPoint(0,10,0)
pts2.InsertNextPoint(5,10,0)
pts2.InsertNextPoint(10,10,0)
colors = vtkUnsignedCharArray()
colors.SetName("colors")
colors.SetNumberOfComponents(4)
r = [255,0,0]
g = [0,255,0]
b = [0,0,255]
colors.InsertTuple4(0,r[0],r[1],r[1],255)
colors.InsertTuple4(1,g[0],g[1],g[2],125)
colors.InsertTuple4(2,b[0],b[1],b[2],10)
pd = vtkPolyData()
pd.SetPoints(pts)
pd.GetPointData().SetScalars(colors)
pd2 = vtkPolyData()
pd2.SetPoints(pts2)
pd2.GetPointData().SetScalars(colors)
cubeSource = vtkCubeSource()
sphereSource = vtkSphereSource()
glyph3D = vtkGlyph3D()
glyph3D.SetColorModeToColorByScalar()
glyph3D.SetSource(cubeSource.GetOutput())
glyph3D.SetInput(pd)
glyph3D.ScalingOff()
glyph3D.Update()
glyph3D2 = vtkGlyph3D()
glyph3D2.SetColorModeToColorByScalar()
glyph3D2.SetSource(sphereSource.GetOutput())
glyph3D2.SetInput(pd2)
glyph3D2.ScalingOff()
glyph3D2.Update()
m = vtkPolyDataMapper()
m.SetInput(glyph3D.GetOutput())
a = vtkActor()
a.SetMapper(m)
m2 = vtkPolyDataMapper()
m2.SetInput(glyph3D2.GetOutput())
a2 = vtkActor()
a2.SetMapper(m2)
More information about the vtkusers
mailing list