Hi all, After some careful consideration and inspection of the sphere primative's vertex list, I've come to the conclusion that the built-in sphere primative is an open mesh. It has an open seam on its back running from pole to pole.
Personally, I like to think of spheres as closed entities and I wondered why Macromedia created their sphere primative as an open mesh. After spending some time to produce a function to return a closed mesh sphere, I think I have an answer... An open mesh sphere is a lot easier to produce as you can ignore the wraparound special cases that happen at the poles and along the rear seam. Still, it was quite fun to write the following function and I hope it is of some use to the list. Becareful of line splits, I think I added the continuation character to correct for this, but... The segments is approximately equal to to the sphere primative's resolution property divided by 4. Any comments would be welcome. Take care, and may your normals always point in the right direction, Kevan Dettelbach Lunny Communications on newClosedSphereResource(MemberRef,name,radius,segments) -- creates and returns a closed mesh sphere, segments directly relates to --the number of slices in a single --quadrant of a cross section through the sphere -- the spehere is centred at the origin (0,0,0) segments = segments.integer --just in case radius = abs(radius) totalfaces = 8*((2*segments*segments) - segments)--((segments \ *(segments -1)) * 16) +(segments * 8) totalvertices = 2*((4*segments*segments) - (2*segments) +1) -- we'll let the normals be generated automatically and we won't worry about --colors or texture coords -- these may be added later as needed rsphere = MemberRef.newmesh(name,totalfaces,totalvertices) --create the vertices, don't worry about the first and last vertice for now segangle = 90.0 / segments vcount = 2 repeat with latcount = 1 to (2*segments) - 1 repeat with longcount = 1 to 4*segments --rather than worry about calculating the proper position ourselves, we'll --set up a transform and letdirector handle it trans = transform() trans.position = vector(0,radius,0) trans.rotate(vector(0,0,0),vector(1,0,0),segangle *latcount) trans.rotate(vector(0,0,0),vector(0,1,0),segangle*longcount) rsphere.vertexlist[vcount] = trans.position vcount = vcount + 1 end repeat end repeat rsphere.vertexlist[1] = vector(0,radius,0) --northpole rsphere.vertexlist[totalvertices] = vector(0,-radius,0) --southpole --create faces facecount = (segments * 4) +1 vcount = 2 repeat with latcount = 1 to (2*segments) - 2 repeat with longcount = 1 to (4*segments)-1 rsphere.face[facecount].vertices = [vcount,vcount + (segments *4),vcount + \ (segments *4)+1] facecount = facecount + 1 rsphere.face[facecount].vertices = [vcount,vcount + (segments *4)+1,vcount \ +1] facecount = facecount + 1 vcount = vcount + 1 end repeat --back seam rsphere.face[facecount].vertices = [vcount,vcount + (segments *4),vcount + \ 1] facecount = facecount + 1 rsphere.face[facecount].vertices = [vcount,vcount+1,vcount -((segments \ *4)-1)] facecount = facecount + 1 vcount = vcount + 1 end repeat --southpole repeat with longcount = 1 to (4*segments)-1 rsphere.face[facecount].vertices = [vcount,totalvertices,vcount + 1] facecount = facecount + 1 vcount = vcount + 1 end repeat --back seam rsphere.face[facecount].vertices = [vcount,totalvertices,vcount -((segments \ *4)-1)] --northpole vcount = 2 facecount = 1 repeat with longcount = 1 to (4*segments)-1 rsphere.face[facecount].vertices = [1,vcount,vcount+1] facecount = facecount + 1 vcount = vcount + 1 end repeat --back seam rsphere.face[facecount].vertices = [1,vcount,2] rsphere.generatenormals(#smooth) rsphere.build() return rsphere end [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
