[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Polygons and polylines
- Subject: Re: Polygons and polylines
- From: Rick Towler <rtowler(at)u.washington.edu>
- Date: Wed, 26 Apr 2000 17:15:56 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: The University of Washington
- References: <Pine.GSO.4.05.10004251656570.9002-100000@grad> <email@example.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19417
Struan Gray wrote:
> Steven Chetelat, firstname.lastname@example.org 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
;add the alpha channel - a 4th "color" channel
;create the new larger image array
;copy the original image data to it
;set alpha to the value of my opacity slider (values from 0..255)
WIDGET_CONTROL, state.wOpacityS, GET_VALUE=alpha
state.oPhoto = OBJ_NEW('IDLgrImage', idata2, INTERLEAVE=2, $
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),
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, $
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
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)
Hope this helps.
> 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.