[Fluxus] some advice
gabor papp
gabor.lists at mndl.hu
Sun Aug 24 23:41:27 PDT 2008
hi Karsten,
you object is running off the scene, because you gradually decrease its
vertex coordinates, accumulating the results of substractions in
subsequent frames.
what you can do when working with primitives is to store the original
position of the vertices and use that. so instead of
p = p + random_vector were p goes to infinity with time, you use
p = origp + random_vector, leaving origp intact
> 1) could someone maybe explain quickly the 'unit' of the vectors i.e.
> if we have (vadd current-position (vector 0.1 0 0)) is the 0.1
> simply a magnitude, or pixels?
it's in world space coordinates. it might help to use (show-axis 1),
which displays the origin of the world. if you add the vector to the
position continuously, and you do this in every frame, your object will
shift out of the screen quickly.
> 2) how do people manage movement of objects so that they are
> on-screen doing things and don't immediately wonder off?
check out (identity), (with-state), (push), (pop) that can prevent this
behaviour.
----
clear-colour (vector 0.1 0.1 0.1))
(clear)
(reset-camera)
(hint-none)
(hint-wire)
(hint-vertcols)
(hint-solid)
(define numobs 10)
(define myobs (build-list numobs
(lambda (object)
(build-sphere 5 5))))
(define (init-object)
(for-each
(lambda (object)
(with-primitive object
(pdata-map!
(lambda (colour)
(vector (flxrnd) (flxrnd) (flxrnd)))
"c")
(pdata-copy "p" "origp")))
myobs))
(init-object)
(define (update-object)
(for-each
(lambda (object)
(with-primitive object
(pdata-index-map!
(lambda (i pos)
(vsub (pdata-ref "origp" i) (vmul pos (flxrnd))))
"p")))
myobs))
(every-frame (update-object))
---
best,
gabor
More information about the Fluxus
mailing list