Jeffrey M. Augenbaum (augenbau@erols.com) writes:
> I'm new to IDL and would like to plot two surface volumes with different
> colors. For example, I want to visualize some 3D aspects of fluid flow
> about an object.
> ie. I want to plot an ellipsoid volume in one color and then a tube with
> a different color. I'd appreeciate any help with this.
Why is it that people who are new to IDL always want to do
the hardest things? How come new people don't just want to
draw line plots? Sigh... Oh, well, at least he doesn't
want to call this code from a C program, too. ;-)
Presumably Jeffrey already knows that he is going to have
to use Shade_Volume and PolyShade to render his 3D objects.
(I presume he is using direct graphics or he wouldn't need
to ask this question. Object graphics would easily allow
him to specify his colors directly.)
The trick is to use the SET_SHADING command with the VALUES
keyword to restrict his output to just a portion of the
color table, which he has loaded with the colors he wants
to use.
Here is an example program I hacked together from some
examples in the IDL documentation. It shows a blue tube
(cylinder) going through a red sphere.
************************************************************ *
PRO Example
; Load colors in different portions of the color table.
LoadCT, 3, NColors=100 ; Red colors
LoadCT, 1, NColors=100, Bottom=100 ; Blue colors
; Create a sphere.
SPHERE = FLTARR(20, 20, 20)
FOR X=0,19 DO FOR Y=0,19 DO FOR Z=0,19 DO $
SPHERE(X, Y, Z) = SQRT((X-10)^2 + (Y-10)^2 + (Z-10)^2)
SHADE_VOLUME, SPHERE, 8, V1, P1
; Create a cylinder.
MESH_OBJ, 3, V2, P2, Replicate(1, 48, 40), P4=40
; Render in the Z-graphics buffer
thisDevice = !D.Name
Set_Plot, 'Z'
Device, Set_Resolution=[400,400]
Erase
; Set !P.T Transformation matrix.
Scale3, XRANGE=[0,20], YRANGE=[0,20], ZRANGE=[0,20]
; Render sphere in red colors.
Set_Shading, Values=[0,99]
image = POLYSHADE(V1, P1, /T3D)
; Render cylinder in blue colors.
Set_Shading, Values=[100,199]
T3D, Translate=[0.25,0.20,0]
v2 = Vert_T3D(v2)
image = POLYSHADE(V2, P2, /T3D)
; Take a snapshot of the Z-buffer.
snap = TVRD()
; Display the snapshot on the display.
Set_Plot, thisDevice
Window, XSize=400, YSize=400
TV, snap
END
**********************************************************
> Please email me directly, as I don't read this group regularly.
Only faithful readers who read the group regularly usually
get their questions answered in this much detail. :-)
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|