comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Polygons and polylines
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Polygons and polylines [message #19794] Tue, 25 April 2000 00:00 Go to next message
Steven Chetelat (CS) is currently offline  Steven Chetelat (CS)
Messages: 11
Registered: February 2000
Junior Member
OK, this should be my last problem with object graphics for a while.
Right now I have a ploygon object which I rotate to various angles for
display. I use user input to generate a polyline (except it's just one
line), which is inside/behind the polygon. Does the polygon object allow
for transparency? I can't find such a property in the Objects & Object
Graphics book. If not, what are my other options? Should I use a surface
or volume object?
In direct graphics, I was using a volume, I just made two different
isosurface images and added them together. I suppose I could do something
similar in object graphics, but I'm convinced there has to be a much
better way...

K-Bye,
STEVE! (chetelat@csee.usf.edu)(steve@moffitt.usf.edu)
Re: Polygons and polylines [message #19925 is a reply to message #19794] Wed, 26 April 2000 00:00 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Struan Gray wrote:
>
> Steven Chetelat, chetelat@csee.usf.edu writes:
>
>> Does the polygon object allow
>> for transparency?
>
> Investigate the use of a 'texture map': an image object which
> gives colour to the polygon faces and overrides (well, interacts with)
> the colours given to the polygon vertices. If the image has a fourth,
> 'alpha', channel the values in that channel determine the degree of
> transparency. I think David F. has an example of how to do this on
> his website (www.dfanning.com).


I have struck out with a couple of my replies so take this as a
suggestion only. I am trying.....

Struan is on the right path. I just had to figure this one out and here
are some hints. I make no claims that they are the *best* hints but
they'll get you somewhere:

create an image object with an alpha channel. Note that your image data
can be created manually too.

;you can read one from an existing file
READ_JPEG,file ,idata, TRUE=3
imsize=SIZE(idata, /DIMENSIONS)
;add the alpha channel - a 4th "color" channel
;create the new larger image array
idata2=FLTARR(imsize(0),imsize(1),imsize(2)+1)
;copy the original image data to it
idata2(*,*,0:2)=idata
;set alpha to the value of my opacity slider (values from 0..255)
WIDGET_CONTROL, state.wOpacityS, GET_VALUE=alpha
idata2(*,*,3)=alpha

state.oPhoto = OBJ_NEW('IDLgrImage', idata2, INTERLEAVE=2, $
BLEND_FUNCTION=[3,4], /INTERPOLATE)


Or create it manually. Here is a 50x50 pixel pure white solid (alpha
channel set to 255) image object:

state.oImage = OBJ_NEW('IDLgrImage', REPLICATE(255,50,50,4),
INTERLEAVE=2, $
BLEND_FUNCTION=[3,4], /INTERPOLATE)


Notice the BLEND_FUNCTION. Values of 3,4 do what your looking for but
take a better look at the documentation on this. I personally didn't
get the whole picture from the manual and I stopped trying when I got
things to work the way I wanted them to.


Now create a polygon with the texture mapped image object.

state.oFBSurface = OBJ_NEW("IDLgrPolygon", x,y,z, $
SHADING=1, COLOR=body_color, POLY=fb_mesh, $
TEXTURE_MAP=state.oImage, STYLE=2, $ /TEXTURE_INTERP, $
TEXTURE_COORD=TRANSPOSE([[ynorm],[znorm]]), $
REJECT=0, ZERO_OPACITY_SKIP=0)


You can see that I set TEXTURE_MAP to the image object I create above.
You only need to set TEXTURE_INTERP if your going to be using detailed
images and want the better image quality. TEXTURE_COORD is required and
is set to an array of normailzed vertex values and is used to map the
image object to the polygon object.


Lastly, order your objects from back to front so they are displayed
properly.
something like:

oModelTop -> ADD, myPolyline
oModelTop -> ADD, mySurface


To change opacity of your polygon just change the alpha channel values
of your image object. I have a slider widget and can pick up the new
value of my alpha channel from that (as ev.value)

state.oImage->getProperty, Data=image
image(*,*,3)=ev.value
state.oImage->setProperty, Data=image


Hope this helps.

-Rick Towler



>
> You also need to pay attention to the order in which objects are
> drawn, with the frontmost, transparent object drawn last. You control
> the drawing order by changing the ordering of the objects in their
> enclosing model or view. I don't know if this works with two
> intersecting transparent surfaces, but I suspect that only one will be
> drawn properly.
>
> Struan
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Polygons and polylines
Next Topic: Polar to spherical coordinates

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:10:03 PDT 2025

Total time taken to generate the page: 0.00562 seconds