root growth tweaks

This commit is contained in:
Dave Griffiths 2009-08-25 15:48:05 +01:00
parent d1dbef3f32
commit a86bd6aa47
5 changed files with 34 additions and 24 deletions

View file

@ -49,7 +49,7 @@
(define/public (setup) (define/public (setup)
(lock-camera cam) (lock-camera cam)
(camera-lag 0.2) (camera-lag 0.2)
(clip 1 100) (clip 1 300)
(set-camera-transform (mtranslate (vector 0 0 -4)))) (set-camera-transform (mtranslate (vector 0 0 -4))))
; moveme ; moveme

View file

@ -18,7 +18,7 @@
(define curl-amount 40) (define curl-amount 40)
(define start-size 50) (define start-size 50)
(define max-ornaments 10) ; per twig (define max-ornaments 10) ; per twig
(define nutrient-twig-size-increase 4) (define nutrient-twig-size-increase 2)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the base class logic object - all logic side objects can ; the base class logic object - all logic side objects can
@ -91,6 +91,9 @@
(define/public (get-dist) (define/public (get-dist)
dist) dist)
(define/public (get-w)
w)
(define/public (get-dir) (define/public (get-dir)
dir) dir)
@ -131,7 +134,8 @@
(set! w (if (zero? (- num-points 2)) width (set! w (if (zero? (- num-points 2)) width
(+ 0.1 (* width (- 1 (/ (length points) (- num-points 2))))))) (* width (- 1 (/ (length points) (- num-points 2))))))
(set! dist (* w 1.5))
(set! last-point new-point) (set! last-point new-point)
(set! points (append points (list new-point))) (set! points (append points (list new-point)))
(set! widths (append widths (list w))) (set! widths (append widths (list w)))
@ -324,7 +328,7 @@
(field (field
(twigs '()) ; a assoc list map of ids to twigs (twigs '()) ; a assoc list map of ids to twigs
(leader-twig #f) ; the temporary twig controlled by the player (leader-twig #f) ; the temporary twig controlled by the player
(properties '(leaf flower fork horn inflatoe)) ; a list of symbols - properties come from pickups (properties '()) ; a list of symbols - properties come from pickups
(ornaments '()) ; map of ids to ornaments on the plant (ornaments '()) ; map of ids to ornaments on the plant
(size start-size) ; the age of this plant (size start-size) ; the age of this plant
(max-twigs default-max-twigs) ; the maximum twigs allowed at any time - oldest removed first (max-twigs default-max-twigs) ; the maximum twigs allowed at any time - oldest removed first

View file

@ -582,23 +582,29 @@
send (get-twig twig-id) get-width twig-point)))))) send (get-twig twig-id) get-width twig-point))))))
(define/public (update-nutrients t d) (define/public (update-nutrients t d)
(when (not (null? twigs)) (when (not (null? twigs))
(with-primitive nutrients (with-primitive nutrients
(pdata-index-map! (pdata-index-map!
(lambda (i p twig-id point offset speed) (lambda (i p twig-id point offset speed)
(let* ((twig-id (inexact->exact twig-id)) (let* ((twig-id (inexact->exact twig-id))
(twig (get-twig twig-id)) (twig (get-twig twig-id))
(point (inexact->exact point))) (point (inexact->exact point)))
(if twig (cond
(cond ((or (< point 1) (not twig))
((< point 1) (pdata-set! "twig" i -1) (vector 0 0 0)) (let* ((new-twig (choose twigs))
((< (vdist (vadd (send twig get-point point) offset) p) 0.1) (num-points (send (cadr new-twig) get-num-points))
(pdata-set! "point" i (- point 1)) (new-point (if (zero? num-points) 0 (random num-points))))
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point (- point 1)) offset) p)) (* speed d)))) (pdata-set! "twig" i (car new-twig))
(else (pdata-set! "point" i new-point)
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point point) offset) p)) (* speed d))))) (pdata-set! "offset" i (vmix offset (vmul (srndvec) (send (cadr new-twig) get-width new-point)) 0.2))
(vector 0 0 0)))) (send (cadr new-twig) get-point new-point)))
"p" "twig" "point" "offset" "speed")))) ((< (vdist (vadd (send twig get-point point) offset) p) 0.1)
(pdata-set! "point" i (- point 1))
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point (- point 1)) offset) p)) (* speed d))))
(else
(vadd p (vmul (vnormalise (vsub (vadd (send twig get-point point) offset) p)) (* speed d)))))))
"p" "twig" "point" "offset" "speed"))))
(define/public (update t d) (define/public (update t d)
(update-nutrients t d) (update-nutrients t d)

View file

@ -49,7 +49,7 @@
(lambda (_) (lambda (_)
(make-ob 'seed 'seed "meshes/seed.obj" (make-ob 'seed 'seed "meshes/seed.obj"
(vmul (srndvec) (* size area 0.5)) (vmul (srndvec) (* size area 0.5))
(* 0.5 50) (* 0.3 50)
(vmul (rndvec) 0) 0))) (vmul (rndvec) 0) 0)))
(build-list num-pickups (build-list num-pickups

File diff suppressed because one or more lines are too long