[Fluxus] another perspective on perspective

Kassen signal.automatique at gmail.com
Thu Feb 25 11:31:43 PST 2010


Dear list.

The code below is my latest study in non-euclidean architecture. Here I'm
building a tower with a roof. The walls of the tower rise up perpendicular
to the surface it's on. This isn't at all unusual, of course. You'll say
that the walls of your own house do the same. However, were your house build
on a sphere that would mean that the floor of your attic would have a larger
surface than the floor on ground level. Good thing we don't actually live on
a sphere in reality; it would get very confusing very quickly.

The main trick here is that when we have a spot on a sphere we can move
straight "up" by simply multiplying the location vector of that spot. That
does mean we need to build from a perspective (the centre of the world)
that's quite far away from the model, hence the jumping up and down states
and doing some operations based on matrices instead of from the state and
regular transforms. By getting the location from a matrix I get rid of the
rotation element of the local state.

Enjoy (zoom out for a bit as the camera starts out at the origin which is
inside of the sphere)

Yours,
Kas.


(clear-colour (vector 0 0 1))
(clear)

(define diam 10)

(with-state
    (colour (vector 0 1 0))
    (scale diam)
    (build-sphere 20 20))

(define (loc-from-mat m)
    (vector
        (vector-ref m 12)
        (vector-ref m 13)
        (vector-ref m 14)))

(define (above spot height)
    (let ((loc (loc-from-mat spot)))
        (vadd loc (vmul (vnormalise loc) height))))

(define (build-block  x y z)
    (with-state
        (let ((origin (get-transform)))
            (let((ground_corners (list
                    (mmul origin (mtranslate (vector (/ x -2) (/ y -2) 0 )))
                    (mmul origin (mtranslate (vector (/ x  2) (/ y -2) 0 )))
                    (mmul origin (mtranslate (vector (/ x  2) (/ y  2) 0 )))
                    (mmul origin (mtranslate (vector (/ x -2) (/ y  2) 0
))))))
                (identity)
                (with-primitive (build-polygons 16 'quad-list)
                    (for ((x (in-range 0 4)))
                        (pdata-set! "p" (* x 4)        (loc-from-mat
(list-ref ground_corners x)))
                        (pdata-set! "p" ( + (* x 4) 1) (loc-from-mat
(list-ref ground_corners (modulo (+ x 1) 4))))
                        (pdata-set! "p" ( + (* x 4) 3) (above (list-ref
ground_corners x) z))
                        (pdata-set! "p" ( + (* x 4) 2) (above (list-ref
ground_corners (modulo (+ x 1) 4))z)))
                        (recalc-normals 0.5))))))

(define (build-roof-duo x y z build-height roof-col)
    (with-state
        (let ((origin (get-transform)))
            (let((ground_corners (list
                    (mmul origin (mtranslate (vector (/ x -2) (/ y -2) 0 )))
                    (mmul origin (mtranslate (vector (/ x  2) (/ y -2) 0 )))
                    (mmul origin (mtranslate (vector (/ x  2) (/ y  2) 0 )))
                    (mmul origin (mtranslate (vector (/ x -2) (/ y  2) 0 )))

                    (mmul origin (mtranslate (vector 0        (/ y -2) 0 )))
                    (mmul origin (mtranslate (vector 0        (/ y  2) 0
))))))
            (identity)
        (with-primitive (build-polygons 8 'quad-list)
            (pdata-set! "p" 0 (above (list-ref ground_corners 0)
build-height))
            (pdata-set! "p" 1 (above (list-ref ground_corners 4) (+
build-height z)))
            (pdata-set! "p" 2 (above (list-ref ground_corners 5) (+
build-height z)))
            (pdata-set! "p" 3 (above (list-ref ground_corners 3)
build-height))

            (pdata-set! "p" 4 (above (list-ref ground_corners 4) (+
build-height z)))
            (pdata-set! "p" 5 (above (list-ref ground_corners 1)
build-height ))
            (pdata-set! "p" 6 (above (list-ref ground_corners 2)
build-height ))
            (pdata-set! "p" 7 (above (list-ref ground_corners 5) (+
build-height z)))

            (colour roof-col)
            (recalc-normals .5)
            )

        (with-primitive (build-polygons 6 'triangle-list)
            (pdata-set! "p" 0 (above (list-ref ground_corners 0)
build-height))
            (pdata-set! "p" 1 (above (list-ref ground_corners 1)
build-height))
            (pdata-set! "p" 2 (above (list-ref ground_corners 4) (+
build-height z)))
            (pdata-set! "p" 3 (above (list-ref ground_corners 2)
build-height))
            (pdata-set! "p" 4 (above (list-ref ground_corners 3)
build-height))
            (pdata-set! "p" 5 (above (list-ref ground_corners 5) (+
build-height z)))
            (recalc-normals .5)
            )))))

(rotate (vector 45 45 0))
(translate (vector 0 0 (- diam .1)))
(build-block  1 1 3)

(build-roof-duo 1 1 .5 3 (vector 1 0 0))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pawfal.org/pipermail/fluxus-pawfal.org/attachments/20100225/6ac38e54/attachment-0002.htm>


More information about the Fluxus mailing list