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

Home » Public Forums » archive » Is it possible a transparent image in space ???
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
Is it possible a transparent image in space ??? [message #38804] Sun, 28 March 2004 22:38 Go to next message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Hi,

i know it is possible to put two images in the same "plane" and make one
of two semi-transparent to allow see the second image.
My question is: Is it possible to create an image as a texture of
poligon and make it be transparent in the 3D space? (transparent for
other planes).

I have a program similar to "d_vectrack.pro" and i'd like my slides to
be semi-transparent.

Thanks.
Re: Is it possible a transparent image in space ??? [message #38847 is a reply to message #38804] Wed, 31 March 2004 10:52 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Hi Antonio,

Often it is helpful to break the problem down. Below I create two texture
mapped polygon objects. The "near" polygon is colored orange and is located
at z=0 and is textured with a 4 pixel image whose alpha values range from
255..50. The "far" polygon lt. blue in color and is located at z=-0.5 and
is textured with a 4 pixel image whose alpha values are 255, 255, 255, and
0.

oContainer = OBJ_NEW('IDL_Container')

; Create the near poly texture map
idata[*,0,0]=[255,150,5,255]
idata[*,0,1]=[255,150,5,225]
idata[*,1,1]=[255,150,5,125]
idata[*,1,0]=[255,150,5,50]
oTexOne = OBJ_NEW('IDLgrImage', idata)
oContainer -> Add, oTexOne

; Create the near polygon
verts = [[-1,-1,0], $
[1,-1,0], $
[1,1,0], $
[-1,1,0]]
polys = [4,0,1,2,3]
texcoords = [[0,0],[1,0],[1,1],[0,1]]
oNearPoly = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=polys, $
COLOR=[255,255,255], TEXTURE_COORD=texcoords, $
TEXTURE_MAP=oTexOne)



; Create the far poly texture map
idata[*,0,0]=[0,205,170,0]
idata[*,0,1]=[0,205,170,255]
idata[*,1,1]=[0,205,170,255]
idata[*,1,0]=[0,205,170,255]
oTexTwo = OBJ_NEW('IDLgrImage', idata)
oContainer -> Add, oTexTwo

; Create the far polygon
verts = [[-1,-1,-0.5], $
[1,-1,-0.5], $
[1,1,-0.5], $
[-1,1,-0.5]]
polys = [4,0,1,2,3]
texcoords = [[0,0],[1,0],[1,1],[0,1]]
oFarPoly = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=polys, $
COLOR=[255,255,255], TEXTURE_COORD=texcoords, $
TEXTURE_MAP=oTexTwo)


; Add the polygon objects to a model - *note the order*
oModel = OBJ_NEW('IDLgrModel')
oModel -> Add, [oNearPoly, oFarPoly]
oContainer -> Add, oModel

stop

end


Copy the above code and run it. When execution halts, an IDLgrModel object,
oModel, will exist and contain our polygons. Use XOBJVIEW to view the
model. At the IDL command prompt type:

XOBJVIEW, oModel

Before you manipulate anything, is this what we expected? Sort-of... The
orange polygon does show varying levels of transparency but we see the white
background instead of the light blue polygon behind it.

If you rotate the model you will see the blue polygon. And if you rotate
the model 180 degrees, now viewing it from the back, things will render as
we would expect. Peering thru the one transparent quadrant of the blue
polygon we see the orange polygon and thru the orange polygon we see the
white background.

Back at the IDL command prompt flip the order of the two polygons in our
model. Whereas before the near polygon was first and the far polygon was
last (based on the order we added them to the model), flipping them will
move the far polygon to the first position and the near polygon to the last:

oModel -> Move, 0,1

Now go back to the XOBJVIEW window and rotate the model another 180 degrees
so you are viewing it head on again. Look different?

When using transparency in IDL you must draw your objects in order from the
most -Z to the most +Z. In this case, we needed to draw the far polygon
first, then the near polygon. Depending on your application is can be
anywhere from moderatly annoying to a real headache. The reasons for this
have been covered in depth in this group before so if you relish the details
you can search google.

I would suggest playing around with this code, adding your own textures,
until you can produce the desired results. Then go back and take a look at
your existing code.

-Rick


P.S. Don't forget to clean up:

OBJ_DESTROY, oContainer





"Antonio Santiago" wrote ...
> Hi Rick,
>
> sorry to bother you another time but i just seeing some examples found
> in google about texture maps transparencies and i think i am doing the
same.
>
> My code is a little big (is part of a more big program) so i put some
> important lines.
> (I have one IDLgrModel and put a polygon with a texture_map and a simple
> IDLgrImage.)
>
>
> -First i create two IDLgrImage ('oXImage' and 'ximage'. 'oXImage' will
> be a texture map and 'ximage' will be a simple image put on a
IDLgrModel):
>
> Note: The first data i put into image DATA is not an alpha image. I
> create later this.
>
> ;Imagen corte X
> img_x_data = data_vol[0,*,*]
> img_x_data = REFORM(img_x_data, sizes[1], sizes[2])
> oXImage = OBJ_NEW('IDLgrImage', img_x_data, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
> sEstado.oXSlideImage = oXImage
> sEstado.oHolderTemp->Add, oXImage
>
> ximage = OBJ_NEW('IDLgrImage', img_x_data, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
> sEstado.oTopModelVol->Add, ximage
> sEstado.ximage=ximage
>
>
> -Then i create one IDLgrPolygon and assing oXImage as a texture_map:
>
> oXSlide = OBJ_NEW('IDLgrPolygon', COLOR=[255,255,255], $
> [[0,0,0],[0,y,0],[0,y,z],[0,0,z],[0,0,0]], $
> THICK=2, STYLE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> TEXTURE_MAP=oXImage, TEXTURE_COORD=[[0,0], [1,0], [1,1],[0,1], [0,0]])
> sEstado.oVolumeModelVol->Add, oXSlide
> sEstado.oXSlide = oXSlide
>
> -Final when i move the polygon i caught some data, convert to alpha
> image and assign to both texture_map image and simple image:
>
> ...
> c[*,*,0] = red(img_x_data[*,*])
> c[*,*,1] = green(img_x_data[*,*])
> c[*,*,2] = blue(img_x_data[*,*])
> c[*,*,3] = 100
>
> sEstado.ximage->SetProperty, DATA=c, INTERLEAVE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
> sEstado.oXSlideImage->SetProperty, DATA=c, INTERLEAVE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
>
>
> The result is: the simple image put on the IDLgrModel is transparent but
> the texture map not.
>
> I think it is the same as all examples.
>
>
> Well, if you arrive here a lot of thanks for your patient and time :)
>
> --------
> Antonio.
>
Re: Is it possible a transparent image in space ??? [message #38851 is a reply to message #38804] Wed, 31 March 2004 08:59 Go to previous message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
I guess the only suggestion I have is to simplify your application until you
see the cause. For example, don't add your ximage to the TopModelVol and
then see if your texture-mapped planes look transparent.

"Antonio Santiago" <d6522117@est.fib.upc.es> wrote in message
news:406AF51F.40408@est.fib.upc.es...
> This seems a crazy dialog :) with myself.
>
> For some strange reason (i supose reason are me) my polygons (slices X,
> Y, Z) with a semi-transparent texture map image arn't trsnaparent among
> them, but when i a draw an IDLgrVolume in the space, the slices are
> transparent with respect the volume.
>
> Well, i supose the order i am drawing the slices and the rest of objects
> isn't right :(. I'm a fuker newbie :)
>
> Thanks for all.
> Antonio
>
>
>
> Antonio Santiago wrote:
>> Hi Rick,
>>
>> sorry to bother you another time but i just seeing some examples found
>> in google about texture maps transparencies and i think i am doing the
>> same.
>>
>> My code is a little big (is part of a more big program) so i put some
>> important lines.
>> (I have one IDLgrModel and put a polygon with a texture_map and a simple
>> IDLgrImage.)
>>
>>
>> -First i create two IDLgrImage ('oXImage' and 'ximage'. 'oXImage' will
>> be a texture map and 'ximage' will be a simple image put on a
IDLgrModel):
>>
>> Note: The first data i put into image DATA is not an alpha image. I
>> create later this.
>>
>> ;Imagen corte X
>> img_x_data = data_vol[0,*,*]
>> img_x_data = REFORM(img_x_data, sizes[1], sizes[2])
>> oXImage = OBJ_NEW('IDLgrImage', img_x_data, $
>> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
>> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
>> sEstado.oXSlideImage = oXImage
>> sEstado.oHolderTemp->Add, oXImage
>>
>> ximage = OBJ_NEW('IDLgrImage', img_x_data, $
>> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
>> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
>> sEstado.oTopModelVol->Add, ximage
>> sEstado.ximage=ximage
>>
>>
>> -Then i create one IDLgrPolygon and assing oXImage as a texture_map:
>>
>> oXSlide = OBJ_NEW('IDLgrPolygon', COLOR=[255,255,255], $
>> [[0,0,0],[0,y,0],[0,y,z],[0,0,z],[0,0,0]], $
>> THICK=2, STYLE=2, $
>> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
>> TEXTURE_MAP=oXImage, TEXTURE_COORD=[[0,0], [1,0], [1,1],[0,1],
>> [0,0]])
>> sEstado.oVolumeModelVol->Add, oXSlide
>> sEstado.oXSlide = oXSlide
>>
>> -Final when i move the polygon i caught some data, convert to alpha
>> image and assign to both texture_map image and simple image:
>>
>> ...
>> c[*,*,0] = red(img_x_data[*,*])
>> c[*,*,1] = green(img_x_data[*,*])
>> c[*,*,2] = blue(img_x_data[*,*])
>> c[*,*,3] = 100
>>
>> sEstado.ximage->SetProperty, DATA=c, INTERLEAVE=2, $
>> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
>> sEstado.oXSlideImage->SetProperty, DATA=c, INTERLEAVE=2, $
>> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
>>
>>
>> The result is: the simple image put on the IDLgrModel is transparent but
>> the texture map not.
>>
>> I think it is the same as all examples.
>>
>>
>> Well, if you arrive here a lot of thanks for your patient and time :)
>>
>> --------
>> Antonio.
>>
>
Re: Is it possible a transparent image in space ??? [message #38852 is a reply to message #38804] Wed, 31 March 2004 08:43 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
This seems a crazy dialog :) with myself.

For some strange reason (i supose reason are me) my polygons (slices X,
Y, Z) with a semi-transparent texture map image arn't trsnaparent among
them, but when i a draw an IDLgrVolume in the space, the slices are
transparent with respect the volume.

Well, i supose the order i am drawing the slices and the rest of objects
isn't right :(. I'm a fuker newbie :)

Thanks for all.
Antonio



Antonio Santiago wrote:
> Hi Rick,
>
> sorry to bother you another time but i just seeing some examples found
> in google about texture maps transparencies and i think i am doing the
> same.
>
> My code is a little big (is part of a more big program) so i put some
> important lines.
> (I have one IDLgrModel and put a polygon with a texture_map and a simple
> IDLgrImage.)
>
>
> -First i create two IDLgrImage ('oXImage' and 'ximage'. 'oXImage' will
> be a texture map and 'ximage' will be a simple image put on a IDLgrModel):
>
> Note: The first data i put into image DATA is not an alpha image. I
> create later this.
>
> ;Imagen corte X
> img_x_data = data_vol[0,*,*]
> img_x_data = REFORM(img_x_data, sizes[1], sizes[2])
> oXImage = OBJ_NEW('IDLgrImage', img_x_data, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
> sEstado.oXSlideImage = oXImage
> sEstado.oHolderTemp->Add, oXImage
>
> ximage = OBJ_NEW('IDLgrImage', img_x_data, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> PALETTE=sEstado.oPalPolygon, BLEND_FUNCTION=[3,4])
> sEstado.oTopModelVol->Add, ximage
> sEstado.ximage=ximage
>
>
> -Then i create one IDLgrPolygon and assing oXImage as a texture_map:
>
> oXSlide = OBJ_NEW('IDLgrPolygon', COLOR=[255,255,255], $
> [[0,0,0],[0,y,0],[0,y,z],[0,0,z],[0,0,0]], $
> THICK=2, STYLE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv, $
> TEXTURE_MAP=oXImage, TEXTURE_COORD=[[0,0], [1,0], [1,1],[0,1],
> [0,0]])
> sEstado.oVolumeModelVol->Add, oXSlide
> sEstado.oXSlide = oXSlide
>
> -Final when i move the polygon i caught some data, convert to alpha
> image and assign to both texture_map image and simple image:
>
> ...
> c[*,*,0] = red(img_x_data[*,*])
> c[*,*,1] = green(img_x_data[*,*])
> c[*,*,2] = blue(img_x_data[*,*])
> c[*,*,3] = 100
>
> sEstado.ximage->SetProperty, DATA=c, INTERLEAVE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
> sEstado.oXSlideImage->SetProperty, DATA=c, INTERLEAVE=2, $
> XCOORD_CONV=xconv, YCOORD_CONV=yconv, ZCOORD_CONV=zconv
>
>
> The result is: the simple image put on the IDLgrModel is transparent but
> the texture map not.
>
> I think it is the same as all examples.
>
>
> Well, if you arrive here a lot of thanks for your patient and time :)
>
> --------
> Antonio.
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Finding the closest value in an array...
Next Topic: Student Edition Splash Screen

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

Current Time: Thu Oct 09 23:11:55 PDT 2025

Total time taken to generate the page: 1.27831 seconds