Hi all,<br><br>If I could please return to the subject of colouring faces for a moment? I've had some time to let more of Scheme sink in and browse the manual some more and made this edit of Gabor's example. What I wanted to do was to give each face a random colour. This led to a big series of experiments with tie-died cubes as colouring the vertices led to interpolated colours on faces. I got around this while also gaining a deeper understanding of Gabor's example. Here is as my experiment stands right now;<br>
<br>(clear)<br>(hint-unlit)<br><br>(define obj1 (build-cube))<br><br>(define (divby? x y)<br>    (if (=  (/ x y)  (floor (/ x y)))  #t #f))<br><br><br>(with-primitive obj1<br>    (let ((facecol .3) (corners 3))<br>        (hint-vertcols)<br>
        (display (poly-type)) (newline)<br>        (if (equal? (poly-type) 'quad-list) (set! corners 4) (set! corners 3))<br>        (pdata-index-map!<br>            (lambda (i c)<br>                (if (divby? i corners) (set! facecol (flxrnd)) (set! facecol facecol))<br>
                (hsv->rgb (vector facecol 1 .9)))<br>            "c")))<br><br><br>One of the things I'm trying to do here is get of the "4" (corners per face) and "6" (faces per object) magic numbers in Gabor's code and generalise the function for more kinds of shapes. I think I've got this down here; I can figure out the number of vertices per face from the poly-type and figure out the amount of faces by dividing the total length of the pdata array by that. This should go fine... except for this "polygon" type; in that case all bets are off, as far as I can see. <br>
<br>Is there any way of reliably and generally taking a vertex and figuring out what face it belongs to in order to do something to that face?<br><br>Yours,<br>Kas.<br>