| texture map on cylindrical section [message #43307] |
Tue, 05 April 2005 12:50 |
Rob Dimeo
Messages: 17 Registered: November 1999
|
Junior Member |
|
|
Hi,
I'm trying to texture map an image onto a cylindrical section (created
with an IDLgrPolygon object) but I'm having trouble determining the
proper texture mapping coordinates to display it properly. Can I use
the vertices or connectivity arrays that were calculated from MESH_OBJ
somehow for this?
The code below creates and displays the cylindrical shell section
properly but the part that I really want...the texture mapping...is
left off. Any help is greatly appreciated!
Thanks,
Rob
*******************
pro cylindrical_sector
; This procedure attempts to create a section of a cylindrical
; shell.
; Use extrusion to create the cylindrical section
; First create an arc in the x-y plane
radius = 1.0 & height = 1.0
th_lo = 25.0 & th_hi = 180.-th_lo
n = 50 & dth = (th_hi-th_lo)/(n - 1.0)
th = th_lo+dth*findgen(n)
x = radius * cos(!dtor * th)
y = radius * sin(!dtor * th)
z = replicate(-0.5*height,n)
type = 5 ; extrusion
; Create the array based on x and y
array = fltarr(3,n)
for i = 0,n-1 do array[0:2,i] = [x[i],y[i],z[i]]
; Use MESH_OBJ to create the extruded section
mesh_obj, type, verts, polys, array
; tcoords = ???????
; Create a model into which we'll stuff the POLYGON object
omodel = obj_new('IDLgrModel')
; Create the image data to be texture-mapped onto the
; POLYGON object.
image_data = bytscl(hanning(32,32))
oimage = obj_new('IDLgrImage',image_data)
; Create the POLYGON object
osection = obj_new('IDLgrPolygon',verts,style = 2,polygons = polys, $
color = [255,0,0]);,texture_map = oimage,texture_coord = tcoords)
omodel->add,osection
omodel->rotate,[1,0,0],-90.0
xobjview,omodel
end
|
|
|
|