[Fluxus] avoiding glitches and sphere normals
gabor papp
gabor.lists at mndl.hu
Sat Feb 13 10:02:06 PST 2010
> parts. I suspect it's due to the sphere being a single primitive. I also had
> that issue on the flat plane and there it was solved by chopping up the
> plane into separate planes. Clearly for a sphere doing that would be a lot
> harder to do. One of the things I fear there is lighting. A single sphere
it's not that difficult. you just copy the points and normals and build
your triangles from the data. something like this:
(clear)
(define s (build-sphere 10 10))
; rebuild the sphere from triangles
(with-primitive s
(poly-for-each-triangle
(lambda (indices)
(let ([tri (build-polygons 3 'triangle-list)]
[points (for/list ([i '(2 1 0)])
(pdata-ref "p" (list-ref indices i)))]
[normals (for/list ([i '(2 1 0)])
(pdata-ref "n" (list-ref indices i)))])
(with-primitive tri
(pdata-index-map!
(lambda (i p)
(list-ref points i))
"p")
(pdata-index-map!
(lambda (i n)
(list-ref normals i))
"n"))))))
; destroy original
(destroy s)
and congrats for your village project. it evolved very nicely in the
last months.
best,
gabor
More information about the Fluxus
mailing list