Thanks, Alark.<br><br>I tried your methods and found a better one as below.<br><br> tfun AddSegment 0 0.0 0.01 0.0<br> tfun AddSegment 0.2 1.0 255 1.0<br><br>This time, I got a gray sphere. I don't know why there are no colors as shown on the other one. Anyone knows why?
<br><br>Jian Wu<br><br><div><span class="gmail_quote">On 8/23/06, <b class="gmail_sendername">Alark Joshi</b> <<a href="mailto:alark_j@hotmail.com">alark_j@hotmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div>The transfer function in your case is set to 1 for all values of density in the volume. That is most probably causing the 'dark cube'. <br>
<br>
Try something like <br>
<br>
tfun AddSegment 0 0.0 55 0.2<br> tfun AddSegment 55 0.2 255 1.0<br><br>
or even <br>
tfun AddSegment 0 0.0 255 1.0<br><br>
Hope that helps.<br>
<br>
Alark<br>
<br><br><br> <br>
<blockquote style="border-left: 2px solid rgb(0, 128, 128); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<hr>
Date: Wed, 23 Aug 2006 13:43:19 -0400<br>From: <a href="mailto:eewujian@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">eewujian@gmail.com</a><br>To: <a href="mailto:vtkusers@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
vtkusers@vtk.org</a><br>Subject: [vtkusers] seeking for help on volume rendering<br><br>Hi, everyone,<br>I'm a new VTK user. I was failed to produced the similar results for a sample code I came upon with in the book "The VTK User's Guide (
VTK4.4)". Page 122. Here is the code that I used. I made a few modification 'cause it is incomplete and has a few obvious errors for the original one. It is supposed to display two similar spheres. But I found the one given by ray-casting was incorrect. It displayed as a dark cube. Is there anyone know the reason? Thanks!
<br><br>Jian Wu<br><br>######################################################################<br>package require vtk<br>package require vtkinteraction<br><br># Create the standard renderer, render window<br># and interactor
<br>vtkRenderer ren1<br>vtkRenderWindow renWin<br> renWin AddRenderer ren1<br>vtkRenderWindowInteractor iren<br> iren SetRenderWindow renWin<br><br># Create a geometric sphere<br>vtkSphereSource sphere<br> sphere SetRadius 20
<br> sphere SetCenter 70 25 25<br> sphere SetThetaResolution 50<br> sphere SetPhiResolution 50<br><br>vtkPolyDataMapper mapper<br> mapper SetInput [sphere GetOutput]<br><br>vtkActor actor<br> actor SetMapper mapper
<br> [actor GetProperty] SetColor 1 1 1<br> [actor GetProperty] SetAmbient 0.01<br> [actor GetProperty] SetDiffuse 0.7<br> [actor GetProperty] SetSpecular 0.5<br> [actor GetProperty] SetSpecularPower 70.0<br>
<br># Read in a volumetric sphere<br>vtkSLCReader reader<br> reader SetFileName "$VTK_DATA_ROOT/Data/sphere.slc"<br><br># Use this tfun for both opacity and color<br>vtkPiecewiseFunction tfun<br> tfun AddSegment 0
1.0 255 1.0<br><br># Make the volume property match the geometric one<br>vtkVolumeProperty volumeProperty<br> volumeProperty SetColor tfun<br> volumeProperty SetScalarOpacity tfun<br> volumeProperty ShadeOn<br> volumeProperty SetInterpolationTypeToLinear
<br> volumeProperty SetDiffuse 0.7<br> volumeProperty SetAmbient 0.01<br> volumeProperty SetSpecular 0.5<br> volumeProperty SetSpecularPower 70.0<br><br>vtkVolumeRayCastCompositeFunction compositeFunction<br>
vtkVolumeRayCastMapper volumeMapper<br> volumeMapper SetInputConnection [reader GetOutputPort]<br> volumeMapper SetVolumeRayCastFunction compositeFunction<br><br>vtkVolume volume<br> volume SetMapper volumeMapper
<br> volume SetProperty volumeProperty<br><br># Add both the geometric and volumetric spheres to the renderer<br>ren1 AddViewProp volume<br>ren1 AddViewProp actor<br><br># Create a red, green, and blue light<br>vtkLight redlight
<br> redlight SetColor 1 0 0<br> redlight SetPosition 1000 25 25<br> redlight SetFocalPoint 25 25 25<br> redlight SetIntensity 0.5<br><br>vtkLight greenlight<br> greenlight SetColor 0 1 0<br> greenlight SetPosition 25 1000 25
<br> greenlight SetFocalPoint 25 25 25<br> greenlight SetIntensity 0.5<br><br>vtkLight bluelight<br> bluelight SetColor 0 0 1<br> bluelight SetPosition 25 25 1000<br> bluelight SetFocalPoint 25 25 25<br> bluelight SetIntensity
0.5<br><br># Add the light to the renderer<br>ren1 AddLight redlight<br>ren1 AddLight greenlight<br>ren1 AddLight bluelight<br>ren1 SetBackground 0.1 0.1 0.2<br><br># Render it!<br>renWin Render<br><br>proc TkCheckAbort {} {
<br> set foo [renWin GetEventPending]<br> if {$foo != 0} {renWin SetAbortRender 1}<br>}<br>renWin AddObserver AbortCheckEvent {TkCheckAbort}<br><br>iren AddObserver UserEvent {wm deiconify .vtkInteract}<br>iren Initialize
<br><br>wm withdraw .<br><br>######################################################################<br></blockquote></div>
</div></blockquote></div><br>