[vtkusers] I can't change opacity using vtkVolumeRayCastIsosurfaceFunction
Lisa Avila
lisa.avila at kitware.com
Thu May 9 16:41:25 EDT 2002
Hello Shwuping Vong,
Nothing is wrong with your code - the vtkVolumeRayCastIsosurfaceFunction
does not support transparent isosurfaces.
Lisa
At 02:05 PM 5/8/2002, Shwu Ping Vong wrote:
>Hi vtkusers,
>
>Please help me with the following scenario:
>
>I am doing volume rendering using the vtkVolumeRayCastIsosurfaceFunction
>as the ray caster function. Below is the code I have. The problem I am
>facing now is no matter what value I give to
>opacityTransferFunction->AddPoint(), the opacity of the object rendered
>stays the same. If I use vtkVolumeRayCastCompositeFunction instead,
>then I can change the opacity of the object. Can anyone tell me why
>that is so? What is wrong with this piece of code?
>
>Thanks in advance,
>Shwuping Vong
>
>=====================================================================
>
>#include "vtkStructuredPointsReader.h"
>#include "vtkPiecewiseFunction.h"
>#include "vtkColorTransferFunction.h"
>#include "vtkVolumeProperty.h"
>#include "vtkVolumeRayCastIsosurfaceFunction.h"
>#include "vtkVolumeRayCastMapper.h"
>#include "vtkVolume.h"
>#include "vtkRenderer.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkActor.h"
>
>int main()
>{
>
>vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
> reader-> SetFileName
>("/home/svong/vtk40Data/VTKData/Data/ironProt.vtk");
>
>vtkPiecewiseFunction *opacityTransferFunction =
>vtkPiecewiseFunction::New();
> opacityTransferFunction-> AddPoint (0 , 0);
> opacityTransferFunction-> AddPoint ( 255, 0.3);
>
>vtkColorTransferFunction *colorTransferFunction =
>vtkColorTransferFunction::New();
> colorTransferFunction-> AddRGBPoint ( 0, 1.0, 1.0, 1.0);
> colorTransferFunction-> AddRGBPoint (255, 1.0, 1.0, 1.0);
>
>vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> volumeProperty-> SetColor( colorTransferFunction);
> volumeProperty-> SetScalarOpacity (opacityTransferFunction);
> volumeProperty-> ShadeOn();
> volumeProperty-> SetInterpolationTypeToLinear();
>
>vtkVolumeRayCastIsosurfaceFunction *isoFunction =
>vtkVolumeRayCastIsosurfaceFunction::New();
> isoFunction-> SetIsoValue (128.0);
>
>vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
> volumeMapper-> SetInput (reader-> GetOutput());
> volumeMapper-> SetVolumeRayCastFunction (isoFunction);
>
>vtkVolume *volume = vtkVolume::New();
> volume-> SetMapper (volumeMapper);
> volume-> SetProperty( volumeProperty);
>
>vtkRenderer *ren1 = vtkRenderer::New();
>vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin-> AddRenderer( ren1);
> renWin-> SetSize (200, 200);
>vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren-> SetRenderWindow (renWin);
>
>ren1-> AddVolume (volume);
>ren1-> SetBackground (0.1, 0.2, 0.4);
>renWin-> Render();
>iren-> Initialize();
>iren->Start();
>
>return 0;
>}
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list