[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering and Code like Points2polys

Hi Larry,

This can answer you need as it continue my thread about "spherical gridding"
Here I got finally something - it seem we try to do about the same; building a "tin" surface over a sphere.
Special thanks to Ben who point me to some good cues in private email about the "orb" object and the CV_COORD procedure. I ran also almost by accident on the "mesh_obj.pro" in the lib directory which use triangulate procedure in conjunction whith cv_coord to build spherical surface among other types.

Now in the proccess of building my own "sphere_surf.pro" which I just have tested the basic inner working.
I will be more or less based on mesh_obj interface:
sphere_surf, type, vertex_list,[ /full], [/degrees], [renderStyle=value], [shading=value], [color=value], [etc... ]
in which: type 0= spherically triangulated irregular network, 1= spherically gridded mesh
vertex_list is the input xyz vertices for type =1 and a 2 dim array for type 1
/full is to build the mesh or tin over a full sphere
/degrees is to input the x, y as degrees
for render_style, shading, color, etc, these are the parameters of the inner IDLgrPolygon used to construct the result - and here I'm not sure if I should implement as a procedure, a function or derivate a new object - suggestion welcome.

Anyhow, for the moment I badly only need just the tin over the incomplete sphere so I'll keep the rest for later.
To complete the sphere (there is still a gap in this form as I expected), I suppose it will be a matter of using the "B" optionnal variable in triangulate which return a list of the indices of the boundary point in ccw order and to triangulate those again and add the resulting connectivity to the preceeding before feeding IDLgrPolygon.
I also tested in double precision; it is OK. (although, trying to view in xobjview generate zclipping plane error which I dont mind at all as long the object is ok).

So here the sample code which build the tin:
; Create array to hold vertices
vertexlist = dblarr(3, 200)
; Create some random longitude points:
vertexlist[0, *] = RANDOMU(seed, 200) * 360. - 180.
; Create some random latitude points:
vertexlist[1, *] = RANDOMU(seed, 200) * 180. - 90.
; Set z to uniform value
vertexlist[2, *] = 500

; Triangulate a spherical surface
Triangulate, vertexlist[0, *], vertexlist[1, *], tri, /degrees
polylist = [Replicate(3L, 1L, (N_Elements(tri) / 3L)), Temporary(tri)]
polylist = polylist[*]

vertex = CV_COORD(From_Sphere=vertexlist, /To_Rect, /degrees)

; Create model.
oGroup = OBJ_NEW('IDLgrModel')

; Create the surface.
oTin = OBJ_NEW('IDLgrPolygon', vertex, polygon=PolyList, STYLE=2, $
                  SHADING=1, COLOR=[0,20,70])
oGroup->Add, oTin

oLightGroup = OBJ_NEW('IDLgrModel')
; Create some lights.
oLight = OBJ_NEW('IDLgrLight', LOCATION=[2,2,2], TYPE=1)
oLightGroup->Add, oLight
oLight = OBJ_NEW('IDLgrLight', TYPE=0, INTENSITY=0.5)
oLightGroup->Add, oLight

xobjview, oGroup, stationary=oLightGroup

Just run as is. If you have other ideas about how the final object should work, I'll be glad to hear about it.
My purpose is to have a way to construct and project and merge all kind of dem from lat/long gridded to xyz irregular surveyed points onto the WGS84 geoid at any kind of resolution from crude to exact. Plus the ability to map satellite imagery over the resulting tile or "patch" and calculating exact texture coordinate on each part. Later, I'll like also to implement "constrained" delanoy triangulation to include VMAP and higher resolution vectors to constrain the tin along rivers, roads, etc

Hope it help

Sylvain Carette
VRML designer-composer

Larry Busse wrote:


I've been given a list of xyz points on the surface of an object and I'd
like to be able to use the IDLgrPolygon object to view them.  This
requires trigulation....generating lists of vertices (the original
points) and a list of faces (list of indices that define each polygon,
or triangle, on the surfaces.)  I found a WindowsNT program by Parasoft
called Points2Polys that will do this but it would certainly be more
convenient if I could do it directly within IDL.

Has anyone written such code thqat they would be willing to share? or
could provide pointers??

David Fanning's article "Gridding XYZ Triples to form a Surface Plot" is
a step in the right direction but I was thinking the polygon approach
would be better for closed surfaces and for datasets with a large number
of points.

Any thoughts on the topic would be appreciated.