[Fluxus] object placement (syntax question)

Kassen signal.automatique at gmail.com
Mon Jan 18 16:28:02 PST 2010


Dear list,

I tried to get through this myself but now I seem stuck. my issue is that I
have a "world" (a green square) and I'd like to place objects in it (here
represented by cubes). I don't want objects to land on each other and
simple collision detection won't do because I want them to be clearly
free-standing. My solution so far is to keep a list of all objects in my
world with data like their type and position as well as the radius of free
space they need around them, then check potential spots for nearby objects
on this list. This, I realise, won't scale very well but it's the best I
could come up with and for small worlds it should still be ok, especially as
we will likely only need to run the whole thing once. This is what I have so
far, it places one cube, adds it to the "myworld" list, then picks a spot
and after that it *should* place a second cube, provided that spot isn't on
top of the first one. Sadly it doesn't place anything ever and I can't see
why. I don't get any more parser errors on this afer adding the lambda and
it's not a simple matter of having inverted some logic, I think. I
tried twiddling those bits.

(clear)


(with-state
    (colour (vector 0 1 0))
    (scale (vector 10 10 10))
    (build-plane))

(define-struct object (pos vel radius type) )


(define myworld (list ))


(define (place-cube pos)
    (with-state
        (set! myworld (cons (make-object pos (vector 0 0 0) 2 "cube")
myworld))
        (translate pos)
        (build-cube)))


(place-cube (vector 0 0 .5))

(define (position-cube)
    (let ((spot (vector (* 4.5 (crndf)) (* 4.5 (crndf)) .5)))
        (cond
            (not (andmap
                    (lambda (element) (> (vdist spot (object-pos element))
(object-radius element))) myworld))
            (place-cube spot))))

(position-cube)

The error has to be in the "cond" statement of "position-cube". Probably
easy for hardcore schemers but some of the scheme logic is still hesitant to
"click" with me.

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pawfal.org/pipermail/fluxus-pawfal.org/attachments/20100119/2e5ab949/attachment-0001.htm>


More information about the Fluxus mailing list