inflatoes and horns

This commit is contained in:
Dave Griffiths 2009-08-15 09:03:28 +01:00
parent 610762c1ee
commit 1d47d17299
12 changed files with 2275 additions and 126 deletions

View file

@ -82,7 +82,7 @@
(send player-plant add-twig current-twig) (send player-plant add-twig current-twig)
(set! current-twig-growing #t)))) (set! current-twig-growing #t))))
(when (and (key-pressed "f") current-twig-growing) (when (and (key-pressed "f") current-twig-growing)
(let ((vel (vmul fwd (* d -3)))) (let ((vel (vmul fwd (* d -3))))
(when (when
(not (collide? (list pos (vadd pos vel)) (send game-view get-stones))) (not (collide? (list pos (vadd pos vel)) (send game-view get-stones)))

View file

@ -12,19 +12,19 @@
(field (field
(players (list (players (list
(make-player-info "plant0000001@fo.am" "plant0000001" (make-player-info "plant0000001@fo.am" "plant0000001"
"textures/plant0000001.png" (list-ref (list-ref seed-obs 0) 1) "textures/plant0000001.png" (list-ref (list-ref seed-obs 0) 2)
(vector 0.5 1 0.5)) (vector 0.5 1 0.5))
(make-player-info "plant0000002@fo.am" "plant0000002" (make-player-info "plant0000002@fo.am" "plant0000002"
"textures/plant0000002.png" (list-ref (list-ref seed-obs 1) 1) "textures/plant0000002.png" (list-ref (list-ref seed-obs 1) 2)
(vector 0.5 1 0)) (vector 0.5 1 0))
(make-player-info "plant0000003@fo.am" "plant0000003" (make-player-info "plant0000003@fo.am" "plant0000003"
"textures/plant0000003.png" (list-ref (list-ref seed-obs 2) 1) "textures/plant0000003.png" (list-ref (list-ref seed-obs 2) 2)
(vector 0 1 0.5)) (vector 0 1 0.5))
(make-player-info "plant0000004@fo.am" "plant0000004" (make-player-info "plant0000004@fo.am" "plant0000004"
"textures/plant0000004.png" (list-ref (list-ref seed-obs 3) 1) "textures/plant0000004.png" (list-ref (list-ref seed-obs 3) 2)
(vector 0.75 1 0.5)) (vector 0.75 1 0.5))
(make-player-info "plant0000005@fo.am" "plant0000005" (make-player-info "plant0000005@fo.am" "plant0000005"
"textures/plant0000005.png" (list-ref (list-ref seed-obs 4) 1) "textures/plant0000005.png" (list-ref (list-ref seed-obs 4) 2)
(vector 0.5 1 0.75)) (vector 0.5 1 0.75))
)) ))
(seeds '()) (seeds '())

View file

@ -6,9 +6,9 @@
(define branch-width-reduction 0.5) (define branch-width-reduction 0.5)
(define twig-jitter 0.1) (define twig-jitter 0.1)
(define branch-jitter 0.5) (define branch-jitter 0.5)
(define max-twig-points 30) (define max-twig-points 15)
(define start-twig-dist 0.05) (define start-twig-dist 0.05)
(define start-twig-width 0.2) (define start-twig-width 0.1)
(define default-max-twigs 10) (define default-max-twigs 10)
(define default-scale-factor 1.05) (define default-scale-factor 1.05)
(define num-pickups 10) (define num-pickups 10)
@ -127,8 +127,7 @@
pos))) pos)))
(set! w (* width (- 1 (/ (length points) num-points)))) (set! w (* width (- 1 (/ (length points) (- num-points 2)))))
(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)))
@ -220,8 +219,8 @@
(set! i (+ i 1)) (set! i (+ i 1))
; if we havent found anything yet and it's intersecting ; if we havent found anything yet and it's intersecting
(cond ((and (not found) (< (vdist (vadd (send plant get-pos) point) (cond ((and (not found) (< (vdist (vadd (send plant get-pos) point)
(send pickup get-pos)) (send pickup get-pos))
(+ width (send pickup get-size)))) (+ width (send pickup get-size))))
(send plant add-property (send pickup get-type)) (send plant add-property (send pickup get-type))
(send pickup pick-up) ; this will remove the pickup for us (send pickup pick-up) ; this will remove the pickup for us
(send-message 'pick-up-pickup (send-message 'pick-up-pickup
@ -325,7 +324,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 '()) ; a list of symbols - properties come from pickups (properties '(horn inflatoe)) ; 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
@ -411,9 +410,9 @@
(set! twigs (cons-twig twig twigs max-twigs '()))) (set! twigs (cons-twig twig twigs max-twigs '())))
(define/public (add-sub-twig ptwig point-index dir) (define/public (add-sub-twig ptwig point-index dir)
(set! leader-twig (send ptwig add-twig point-index dir)) (set! leader-twig (send ptwig add-twig point-index dir))
leader-twig) leader-twig)
(define/public (get-random-twig) (define/public (get-random-twig)
(if (not (null? twigs)) (if (not (null? twigs))
(send (choose twigs) get-random-twig) (send (choose twigs) get-random-twig)
@ -432,7 +431,7 @@
(define/public (serialise) (define/public (serialise)
(append (list (make-object message% 'new-plant (list (append (list (make-object message% 'new-plant (list
(list 'plant-id id) (list 'plant-id id)
(list 'pos pos) (list 'pos pos)
(list 'size size) (list 'size size)
(list 'col col) (list 'col col)
@ -448,7 +447,7 @@
; grow a new ornament? ; grow a new ornament?
(when (and (not (null? properties)) (zero? (random ornament-grow-probability))) (when (and (not (null? properties)) (zero? (random ornament-grow-probability)))
(let ((twig (get-random-twig))) (let ((twig (get-random-twig)))
(when twig (when (and twig (not (send twig growing?)))
(let (let
((property (choose properties)) ((property (choose properties))
(point-index (+ 1 (random (- (send twig get-length) 2))))) (point-index (+ 1 (random (- (send twig get-length) 2)))))
@ -458,6 +457,8 @@
(cond (cond
((or ((or
(eq? property 'leaf) (eq? property 'leaf)
(eq? property 'inflatoe)
(eq? property 'horn)
(eq? property 'wiggle)) (eq? property 'wiggle))
(make-object ornament-logic% (make-object ornament-logic%
(get-next-ornament-id) (get-next-ornament-id)
@ -486,14 +487,14 @@
(inherit send-message) (inherit send-message)
(define/public (setup world-list) (define/public (setup world-list)
(let ((pickups (list-ref world-list 1))) (let ((pickups (list-ref world-list 1)))
(let ((i 0)) (let ((i 0))
(for-each (for-each
(lambda (pickup) (lambda (pickup)
(add-pickup (make-object pickup-logic% i (choose (list 'leaf)) (add-pickup (make-object pickup-logic% i (list-ref pickup 0)
(list-ref pickup 1))) (list-ref pickup 2)))
(set! i (+ i 1))) (set! i (+ i 1)))
pickups)))) pickups))))
(define/public (add-player plant) (define/public (add-player plant)
(printf "new player plant added ~a~n" (send plant get-id)) (printf "new player plant added ~a~n" (send plant get-id))

1262
plant-eyes/meshes/horn.obj Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,377 @@
# Blender3D v245 OBJ File:
# www.blender3d.org
mtllib inflatoe-empty.mtl
o Sphere_Sphere.004_(nu
v -0.258270 -0.166060 1.446520
v -0.038165 -0.185562 1.440088
v -0.091614 -0.256987 1.627843
v -0.019370 -0.210698 2.514796
v -0.066842 -0.153343 2.620445
v -0.042503 -0.288337 2.278201
v -0.426562 -0.226227 2.292146
v -0.568837 -0.160779 1.991169
v -0.418335 -0.134456 2.390263
v -0.485910 -0.075599 2.066889
v 0.016305 -0.055664 1.370447
v 0.088817 -0.087492 1.342034
v 0.070511 0.012160 0.976933
v -0.290191 -0.047968 2.227410
v -0.290559 -0.285152 1.921172
v -0.011207 -0.305508 1.935047
v 0.295902 -0.217925 1.574355
v 0.364544 -0.287458 1.909856
v -0.269099 -0.046800 1.531153
v -0.049971 -0.082761 1.348119
v -0.467711 -0.104025 1.683471
v 0.541381 -0.105213 2.257928
v 0.146622 -0.050834 2.564120
v 0.443054 -0.193032 2.396733
v -0.488087 -0.208298 1.806224
v 0.025536 -0.020212 2.181950
v -0.113466 -0.022705 1.766086
v -0.263962 -0.081104 2.489385
v 0.481752 -0.139275 1.650118
v 0.247807 -0.062137 1.547299
v 0.264517 -0.034446 1.770225
v 0.511188 -0.089502 1.932410
v 0.278799 -0.031003 2.156239
v 0.582307 -0.184192 1.897767
v 0.021390 -0.009214 0.983717
v 0.010705 0.078459 1.006324
vt 0.331806 0.243816 0.0
vt 0.309750 0.258955 0.0
vt 0.438126 0.089822 0.0
vt 0.944618 0.296456 0.0
vt 1.000000 0.444043 0.0
vt 0.821842 0.085807 0.0
vt 0.853758 0.174637 0.0
vt 0.821842 0.085807 0.0
vt 1.000000 0.444043 0.0
vt 0.677280 0.289721 0.0
vt 0.890330 0.463204 0.0
vt 0.693236 0.606739 0.0
vt 0.236977 0.631576 0.0
vt 0.219841 0.558109 0.0
vt 0.000000 0.623297 0.0
vt 0.890330 0.463204 0.0
vt 0.760736 0.786765 0.0
vt 0.693236 0.606739 0.0
vt 0.635334 0.000000 0.0
vt 0.438126 0.089822 0.0
vt 0.619137 0.032835 0.0
vt 0.358654 0.325113 0.0
vt 0.560397 0.217925 0.0
vt 0.438126 0.089822 0.0
vt 0.331806 0.243816 0.0
vt 0.356408 0.611583 0.0
vt 0.236442 0.527343 0.0
vt 0.477172 0.412006 0.0
vt 0.331806 0.243816 0.0
vt 0.677280 0.289721 0.0
vt 0.710197 0.805091 0.0
vt 0.924506 0.789457 0.0
vt 0.823646 0.484268 0.0
vt 0.572389 0.131006 0.0
vt 0.853758 0.174637 0.0
vt 0.677280 0.289721 0.0
vt 0.694780 0.976196 0.0
vt 0.693236 0.606739 0.0
vt 0.760736 0.786765 0.0
vt 0.477172 0.412006 0.0
vt 0.693236 0.606739 0.0
vt 0.467134 0.851933 0.0
vt 0.944618 0.296456 0.0
vt 0.821842 0.085807 0.0
vt 0.823646 0.484268 0.0
vt 0.853758 0.174637 0.0
vt 1.000000 0.444043 0.0
vt 0.923018 0.655812 0.0
vt 0.366501 0.636697 0.0
vt 0.314959 0.756322 0.0
vt 0.432990 0.938857 0.0
vt 0.693236 0.606739 0.0
vt 0.694780 0.976196 0.0
vt 0.467134 0.851933 0.0
vt 0.432990 0.938857 0.0
vt 0.515614 0.857875 0.0
vt 0.366501 0.636697 0.0
vt 0.515614 0.857875 0.0
vt 0.656967 1.000000 0.0
vt 0.710197 0.805091 0.0
vt 0.560397 0.217925 0.0
vt 0.358654 0.325113 0.0
vt 0.509161 0.587830 0.0
vt 1.000000 0.444043 0.0
vt 0.823646 0.484268 0.0
vt 0.924506 0.789457 0.0
vt 0.853758 0.174637 0.0
vt 0.572389 0.131006 0.0
vt 0.635334 0.000000 0.0
vt 0.853758 0.174637 0.0
vt 0.890330 0.463204 0.0
vt 0.677280 0.289721 0.0
vt 0.000000 0.623297 0.0
vt 0.236442 0.527343 0.0
vt 0.010030 0.592832 0.0
vt 0.694780 0.976196 0.0
vt 0.923018 0.655812 0.0
vt 0.924506 0.789457 0.0
vt 0.656967 1.000000 0.0
vt 0.515614 0.857875 0.0
vt 0.432990 0.938857 0.0
vt 0.467134 0.851933 0.0
vt 0.356408 0.611583 0.0
vt 0.477172 0.412006 0.0
vt 0.366501 0.636697 0.0
vt 0.509161 0.587830 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236442 0.527343 0.0
vt 0.000000 0.623297 0.0
vt 1.000000 0.444043 0.0
vt 0.944618 0.296456 0.0
vt 0.823646 0.484268 0.0
vt 0.467134 0.851933 0.0
vt 0.432990 0.938857 0.0
vt 0.314959 0.756322 0.0
vt 0.572389 0.131006 0.0
vt 0.331806 0.243816 0.0
vt 0.438126 0.089822 0.0
vt 0.923018 0.655812 0.0
vt 0.890330 0.463204 0.0
vt 0.853758 0.174637 0.0
vt 0.821842 0.085807 0.0
vt 0.635334 0.000000 0.0
vt 0.619137 0.032835 0.0
vt 0.619137 0.032835 0.0
vt 0.560397 0.217925 0.0
vt 0.821842 0.085807 0.0
vt 0.823646 0.484268 0.0
vt 0.821842 0.085807 0.0
vt 0.560397 0.217925 0.0
vt 0.619137 0.032835 0.0
vt 0.438126 0.089822 0.0
vt 0.560397 0.217925 0.0
vt 0.438126 0.089822 0.0
vt 0.309750 0.258955 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236977 0.631576 0.0
vt 0.314959 0.756322 0.0
vt 0.236442 0.527343 0.0
vt 0.356408 0.611583 0.0
vt 0.236977 0.631576 0.0
vt 0.477172 0.412006 0.0
vt 0.677280 0.289721 0.0
vt 0.693236 0.606739 0.0
vt 0.432990 0.938857 0.0
vt 0.467134 0.851933 0.0
vt 0.656967 1.000000 0.0
vt 0.560397 0.217925 0.0
vt 0.509161 0.587830 0.0
vt 0.823646 0.484268 0.0
vt 0.309750 0.258955 0.0
vt 0.219841 0.558109 0.0
vt 0.358654 0.325113 0.0
vt 0.710197 0.805091 0.0
vt 0.656967 1.000000 0.0
vt 0.924506 0.789457 0.0
vt 0.438126 0.089822 0.0
vt 0.635334 0.000000 0.0
vt 0.572389 0.131006 0.0
vt 0.467134 0.851933 0.0
vt 0.314959 0.756322 0.0
vt 0.236977 0.631576 0.0
vt 0.694780 0.976196 0.0
vt 0.760736 0.786765 0.0
vt 0.923018 0.655812 0.0
vt 0.635334 0.000000 0.0
vt 0.821842 0.085807 0.0
vt 0.853758 0.174637 0.0
vt 0.331806 0.243816 0.0
vt 0.236442 0.527343 0.0
vt 0.219841 0.558109 0.0
vt 0.366501 0.636697 0.0
vt 0.219841 0.558109 0.0
vt 0.314959 0.756322 0.0
vt 0.677280 0.289721 0.0
vt 0.331806 0.243816 0.0
vt 0.572389 0.131006 0.0
vt 0.509161 0.587830 0.0
vt 0.710197 0.805091 0.0
vt 0.823646 0.484268 0.0
vt 0.760736 0.786765 0.0
vt 0.890330 0.463204 0.0
vt 0.923018 0.655812 0.0
vt 0.923018 0.655812 0.0
vt 1.000000 0.444043 0.0
vt 0.924506 0.789457 0.0
vt 0.309750 0.258955 0.0
vt 0.331806 0.243816 0.0
vt 0.219841 0.558109 0.0
vt 0.467134 0.851933 0.0
vt 0.694780 0.976196 0.0
vt 0.656967 1.000000 0.0
vt 0.509161 0.587830 0.0
vt 0.515614 0.857875 0.0
vt 0.710197 0.805091 0.0
vt 0.236977 0.631576 0.0
vt 0.356408 0.611583 0.0
vt 0.467134 0.851933 0.0
vt 0.656967 1.000000 0.0
vt 0.694780 0.976196 0.0
vt 0.924506 0.789457 0.0
vt 0.515614 0.857875 0.0
vt 0.509161 0.587830 0.0
vt 0.366501 0.636697 0.0
vt 0.366501 0.636697 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236977 0.631576 0.0
vt 0.000000 0.623297 0.0
vt 0.019340 0.660371 0.0
vt 0.236442 0.527343 0.0
vt 0.019340 0.660371 0.0
vt 0.010030 0.592832 0.0
vt 0.236442 0.527343 0.0
vt 0.236977 0.631576 0.0
vt 0.019340 0.660371 0.0
vt 0.356408 0.611583 0.0
vt 0.331806 0.243816 0.0
vt 0.477172 0.412006 0.0
vn -0.092673 -0.921580 -0.376964
vn -0.345773 -0.881004 0.322914
vn -0.136667 -0.924800 0.355059
vn -0.798016 0.541123 0.265248
vn 0.461253 0.861562 0.212031
vn -0.321596 0.917460 0.234188
vn -0.065102 -0.988145 -0.139033
vn 0.068389 -0.974026 -0.215861
vn -0.523028 0.461167 -0.716775
vn -0.591344 -0.735780 -0.330060
vn 0.590898 0.423599 0.686588
vn -0.462377 -0.886307 0.025841
vn -0.095285 0.993935 -0.054909
vn -0.204774 0.975366 -0.082032
vn 0.112742 -0.947304 0.299840
vn -0.603005 -0.318454 0.731418
vn 0.365594 0.919929 -0.141675
vn -0.114816 0.992857 0.032426
vn 0.335387 0.921169 -0.197392
vn 0.263979 0.964276 0.022054
vn 0.401290 -0.877115 -0.263886
vn 0.367691 -0.278086 0.887396
vn -0.368832 -0.929413 0.012406
vn -0.886215 -0.298940 0.353918
vn 0.383768 -0.916867 -0.109897
vn -0.092753 0.989739 0.108691
vn 0.228525 0.973387 -0.017137
vn -0.235946 0.970104 0.056808
vn 0.480985 -0.807386 -0.341734
vn -0.044319 -0.964325 -0.260985
vn 0.166427 -0.833304 0.527168
vn 0.032175 0.991561 -0.125581
vn -0.231234 -0.938095 -0.257893
vn -0.191014 -0.708840 0.679014
vn -0.074737 -0.996274 0.043036
vn 0.051564 -0.997176 0.054600
vn 0.151117 -0.974704 0.164668
vn 0.036274 -0.985599 -0.165165
vn 0.047153 -0.938002 -0.343406
vn 0.271671 0.906769 -0.322435
vn -0.214274 0.877552 -0.428940
vn -0.674372 0.733322 -0.086376
vn 0.031155 0.999464 -0.010067
vn 0.430862 -0.896363 0.104365
vn 0.159222 -0.793474 -0.587408
vn 0.226530 0.966534 0.120402
vn -0.225378 -0.943368 -0.243438
vn 0.072924 0.995590 -0.059020
vn -0.067949 0.988933 0.131888
vn -0.155349 -0.982870 0.099163
vn -0.055068 -0.701571 -0.710469
vn 0.450667 0.774051 -0.444685
vn -0.784918 0.424129 -0.451685
vn 0.801032 -0.559198 0.213647
vn -0.410006 0.898860 0.154743
vn -0.174398 0.727673 0.663383
vn -0.079758 -0.651258 -0.754653
vn 0.040578 0.998985 -0.019551
vn 0.791037 0.610190 -0.043922
vn -0.019360 0.995816 -0.089308
vn 0.048998 0.996724 0.064339
vn 0.750429 0.633090 -0.189877
vn 0.498417 -0.486621 -0.717482
vn 0.770453 0.601958 0.209879
vn -0.976596 -0.066259 -0.204620
vn -0.448173 0.836592 0.315047
vn -0.626216 0.412592 -0.661530
usemtl (null)
s off
f 1/1/1 2/2/1 3/3/1
f 4/4/2 5/5/2 6/6/2
f 7/7/3 6/8/3 5/9/3
f 8/10/4 9/11/4 10/12/4
f 11/13/5 12/14/5 13/15/5
f 9/16/6 14/17/6 10/18/6
f 15/19/7 3/20/7 16/21/7
f 17/22/8 18/23/8 3/24/8
f 1/25/9 19/26/9 20/27/9
f 21/28/10 1/29/10 8/30/10
f 22/31/11 23/32/11 24/33/11
f 25/34/12 7/35/12 8/36/12
f 26/37/13 10/38/13 14/39/13
f 21/40/14 10/41/14 27/42/14
f 4/43/15 6/44/15 24/45/15
f 7/46/16 5/47/16 28/48/16
f 29/49/17 30/50/17 31/51/17
f 10/52/18 26/53/18 27/54/18
f 31/55/19 32/56/19 29/57/19
f 32/58/20 33/59/20 22/60/20
f 18/61/21 17/62/21 34/63/21
f 5/64/22 24/65/22 23/66/22
f 7/67/23 25/68/23 15/69/23
f 7/70/24 9/71/24 8/72/24
f 13/73/25 20/74/25 35/75/25
f 26/76/26 28/77/26 23/78/26
f 33/79/27 32/80/27 31/81/27
f 27/82/28 19/83/28 21/84/28
f 29/85/29 34/86/29 17/87/29
f 12/88/30 20/89/30 13/90/30
f 5/91/31 4/92/31 24/93/31
f 27/94/32 31/95/32 30/96/32
f 25/97/33 1/98/33 3/99/33
f 28/100/34 9/101/34 7/102/34
f 6/103/35 15/104/35 16/105/35
f 16/106/36 18/107/36 6/108/36
f 24/109/37 6/110/37 18/111/37
f 16/112/38 3/113/38 18/114/38
f 3/115/39 2/116/39 17/117/39
f 12/118/40 11/119/40 30/120/40
f 20/121/41 19/122/41 11/123/41
f 21/124/42 8/125/42 10/126/42
f 31/127/43 27/128/43 33/129/43
f 18/130/44 34/131/44 24/132/44
f 2/133/45 12/134/45 17/135/45
f 22/136/46 33/137/46 23/138/46
f 3/139/47 15/140/47 25/141/47
f 27/142/48 30/143/48 11/144/48
f 26/145/49 14/146/49 28/147/49
f 15/148/50 6/149/50 7/150/50
f 1/151/51 20/152/51 12/153/51
f 29/154/52 12/155/52 30/156/52
f 8/157/53 1/158/53 25/159/53
f 34/160/54 22/161/54 24/162/54
f 14/163/55 9/164/55 28/165/55
f 28/166/56 5/167/56 23/168/56
f 2/169/57 1/170/57 12/171/57
f 27/172/58 26/173/58 33/174/58
f 34/175/59 32/176/59 22/177/59
f 11/178/60 19/179/60 27/180/60
f 33/181/61 26/182/61 23/183/61
f 32/184/62 34/185/62 29/186/62
f 29/187/63 17/188/63 12/189/63
f 11/190/64 13/191/64 36/192/64
f 20/193/65 36/194/65 35/195/65
f 20/196/66 11/197/66 36/198/66
f 19/199/67 1/200/67 21/201/67

View file

@ -0,0 +1,346 @@
# Blender3D v245 OBJ File:
# www.blender3d.org
mtllib inflatoe-full.mtl
o Sphere_Sphere.004
v -0.262736 -0.424645 1.446520
v -0.040502 -0.490365 1.440088
v -0.101674 -0.715473 1.627843
v -0.044527 -0.615077 2.514796
v -0.089726 -0.424164 2.620445
v -0.072741 -0.837604 2.278201
v -0.463284 -0.573517 2.292146
v -0.597910 -0.323740 1.991169
v -0.455672 -0.219889 2.390263
v -0.522068 0.043760 2.066889
v 0.015644 -0.019807 1.370447
v 0.088785 -0.138439 1.342034
v 0.070511 0.012160 0.976933
v -0.333119 0.176694 2.227410
v -0.318531 -0.794888 1.921172
v -0.032821 -0.865716 1.935047
v 0.295283 -0.557191 1.574355
v 0.360304 -0.775354 1.909856
v -0.278413 0.042464 1.531153
v -0.050627 -0.125002 1.348119
v -0.484612 -0.159861 1.683471
v 0.539579 -0.143540 2.257928
v 0.129802 -0.054346 2.564120
v 0.438874 -0.541165 2.396733
v -0.509955 -0.532734 1.806224
v -0.006362 0.301730 2.181950
v -0.134785 0.258782 1.766086
v -0.299321 -0.048071 2.489385
v 0.481752 -0.239679 1.650118
v 0.246483 0.022839 1.547299
v 0.257666 0.217909 1.770225
v 0.509874 -0.010950 1.932410
v 0.263770 0.231728 2.156239
v 0.582283 -0.382062 1.897767
v 0.021390 -0.009195 0.983717
v 0.010705 0.078471 1.006324
vt 0.331806 0.243816 0.0
vt 0.309750 0.258955 0.0
vt 0.438126 0.089822 0.0
vt 0.944618 0.296456 0.0
vt 1.000000 0.444043 0.0
vt 0.821842 0.085807 0.0
vt 0.853758 0.174637 0.0
vt 0.821842 0.085807 0.0
vt 1.000000 0.444043 0.0
vt 0.677280 0.289721 0.0
vt 0.890330 0.463204 0.0
vt 0.693236 0.606739 0.0
vt 0.236977 0.631576 0.0
vt 0.219841 0.558109 0.0
vt 0.000000 0.623297 0.0
vt 0.890330 0.463204 0.0
vt 0.760736 0.786765 0.0
vt 0.693236 0.606739 0.0
vt 0.635334 0.000000 0.0
vt 0.438126 0.089822 0.0
vt 0.619137 0.032835 0.0
vt 0.358654 0.325113 0.0
vt 0.560397 0.217925 0.0
vt 0.438126 0.089822 0.0
vt 0.331806 0.243816 0.0
vt 0.356408 0.611583 0.0
vt 0.236442 0.527343 0.0
vt 0.477172 0.412006 0.0
vt 0.331806 0.243816 0.0
vt 0.677280 0.289721 0.0
vt 0.710197 0.805091 0.0
vt 0.924506 0.789457 0.0
vt 0.823646 0.484268 0.0
vt 0.572389 0.131006 0.0
vt 0.853758 0.174637 0.0
vt 0.677280 0.289721 0.0
vt 0.694780 0.976196 0.0
vt 0.693236 0.606739 0.0
vt 0.760736 0.786765 0.0
vt 0.477172 0.412006 0.0
vt 0.693236 0.606739 0.0
vt 0.467134 0.851933 0.0
vt 0.944618 0.296456 0.0
vt 0.821842 0.085807 0.0
vt 0.823646 0.484268 0.0
vt 0.853758 0.174637 0.0
vt 1.000000 0.444043 0.0
vt 0.923018 0.655812 0.0
vt 0.366501 0.636697 0.0
vt 0.314959 0.756322 0.0
vt 0.432990 0.938857 0.0
vt 0.693236 0.606739 0.0
vt 0.694780 0.976196 0.0
vt 0.467134 0.851933 0.0
vt 0.432990 0.938857 0.0
vt 0.515614 0.857875 0.0
vt 0.366501 0.636697 0.0
vt 0.515614 0.857875 0.0
vt 0.656967 1.000000 0.0
vt 0.710197 0.805091 0.0
vt 0.560397 0.217925 0.0
vt 0.358654 0.325113 0.0
vt 0.509161 0.587830 0.0
vt 1.000000 0.444043 0.0
vt 0.823646 0.484268 0.0
vt 0.924506 0.789457 0.0
vt 0.853758 0.174637 0.0
vt 0.572389 0.131006 0.0
vt 0.635334 0.000000 0.0
vt 0.853758 0.174637 0.0
vt 0.890330 0.463204 0.0
vt 0.677280 0.289721 0.0
vt 0.000000 0.623297 0.0
vt 0.236442 0.527343 0.0
vt 0.010030 0.592832 0.0
vt 0.694780 0.976196 0.0
vt 0.923018 0.655812 0.0
vt 0.924506 0.789457 0.0
vt 0.656967 1.000000 0.0
vt 0.515614 0.857875 0.0
vt 0.432990 0.938857 0.0
vt 0.467134 0.851933 0.0
vt 0.356408 0.611583 0.0
vt 0.477172 0.412006 0.0
vt 0.366501 0.636697 0.0
vt 0.509161 0.587830 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236442 0.527343 0.0
vt 0.000000 0.623297 0.0
vt 1.000000 0.444043 0.0
vt 0.944618 0.296456 0.0
vt 0.823646 0.484268 0.0
vt 0.467134 0.851933 0.0
vt 0.432990 0.938857 0.0
vt 0.314959 0.756322 0.0
vt 0.572389 0.131006 0.0
vt 0.331806 0.243816 0.0
vt 0.438126 0.089822 0.0
vt 0.923018 0.655812 0.0
vt 0.890330 0.463204 0.0
vt 0.853758 0.174637 0.0
vt 0.821842 0.085807 0.0
vt 0.635334 0.000000 0.0
vt 0.619137 0.032835 0.0
vt 0.619137 0.032835 0.0
vt 0.560397 0.217925 0.0
vt 0.821842 0.085807 0.0
vt 0.823646 0.484268 0.0
vt 0.821842 0.085807 0.0
vt 0.560397 0.217925 0.0
vt 0.619137 0.032835 0.0
vt 0.438126 0.089822 0.0
vt 0.560397 0.217925 0.0
vt 0.438126 0.089822 0.0
vt 0.309750 0.258955 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236977 0.631576 0.0
vt 0.314959 0.756322 0.0
vt 0.236442 0.527343 0.0
vt 0.356408 0.611583 0.0
vt 0.236977 0.631576 0.0
vt 0.477172 0.412006 0.0
vt 0.677280 0.289721 0.0
vt 0.693236 0.606739 0.0
vt 0.432990 0.938857 0.0
vt 0.467134 0.851933 0.0
vt 0.656967 1.000000 0.0
vt 0.560397 0.217925 0.0
vt 0.509161 0.587830 0.0
vt 0.823646 0.484268 0.0
vt 0.309750 0.258955 0.0
vt 0.219841 0.558109 0.0
vt 0.358654 0.325113 0.0
vt 0.710197 0.805091 0.0
vt 0.656967 1.000000 0.0
vt 0.924506 0.789457 0.0
vt 0.438126 0.089822 0.0
vt 0.635334 0.000000 0.0
vt 0.572389 0.131006 0.0
vt 0.467134 0.851933 0.0
vt 0.314959 0.756322 0.0
vt 0.236977 0.631576 0.0
vt 0.694780 0.976196 0.0
vt 0.760736 0.786765 0.0
vt 0.923018 0.655812 0.0
vt 0.635334 0.000000 0.0
vt 0.821842 0.085807 0.0
vt 0.853758 0.174637 0.0
vt 0.331806 0.243816 0.0
vt 0.236442 0.527343 0.0
vt 0.219841 0.558109 0.0
vt 0.366501 0.636697 0.0
vt 0.219841 0.558109 0.0
vt 0.314959 0.756322 0.0
vt 0.677280 0.289721 0.0
vt 0.331806 0.243816 0.0
vt 0.572389 0.131006 0.0
vt 0.509161 0.587830 0.0
vt 0.710197 0.805091 0.0
vt 0.823646 0.484268 0.0
vt 0.760736 0.786765 0.0
vt 0.890330 0.463204 0.0
vt 0.923018 0.655812 0.0
vt 0.923018 0.655812 0.0
vt 1.000000 0.444043 0.0
vt 0.924506 0.789457 0.0
vt 0.309750 0.258955 0.0
vt 0.331806 0.243816 0.0
vt 0.219841 0.558109 0.0
vt 0.467134 0.851933 0.0
vt 0.694780 0.976196 0.0
vt 0.656967 1.000000 0.0
vt 0.509161 0.587830 0.0
vt 0.515614 0.857875 0.0
vt 0.710197 0.805091 0.0
vt 0.236977 0.631576 0.0
vt 0.356408 0.611583 0.0
vt 0.467134 0.851933 0.0
vt 0.656967 1.000000 0.0
vt 0.694780 0.976196 0.0
vt 0.924506 0.789457 0.0
vt 0.515614 0.857875 0.0
vt 0.509161 0.587830 0.0
vt 0.366501 0.636697 0.0
vt 0.366501 0.636697 0.0
vt 0.358654 0.325113 0.0
vt 0.219841 0.558109 0.0
vt 0.236977 0.631576 0.0
vt 0.000000 0.623297 0.0
vt 0.019340 0.660371 0.0
vt 0.236442 0.527343 0.0
vt 0.019340 0.660371 0.0
vt 0.010030 0.592832 0.0
vt 0.236442 0.527343 0.0
vt 0.236977 0.631576 0.0
vt 0.019340 0.660371 0.0
vt 0.356408 0.611583 0.0
vt 0.331806 0.243816 0.0
vt 0.477172 0.412006 0.0
vn -0.592151 -0.249245 -0.766289
vn 0.034150 -0.472549 -0.880612
vn -0.135502 -0.775780 -0.616260
vn -0.180761 -0.611164 0.770562
vn -0.267525 -0.284341 0.920621
vn -0.210212 -0.849696 0.483505
vn -0.704398 -0.419660 0.572436
vn -0.985778 -0.066347 -0.154180
vn -0.743065 0.041444 0.667898
vn -0.779931 0.625813 0.002075
vn 0.025422 0.925993 -0.376659
vn 0.635517 -0.196020 -0.746788
vn 0.747246 -0.611286 -0.260567
vn -0.515305 0.803064 0.299203
vn -0.529588 -0.833644 -0.156560
vn 0.003632 -0.984985 -0.172430
vn 0.498917 -0.501907 -0.706473
vn 0.570544 -0.806452 -0.155156
vn -0.571245 0.551805 -0.607532
vn -0.646352 -0.325724 -0.689993
vn -0.851924 0.264168 -0.452101
vn 0.867550 0.273293 0.415479
vn 0.257515 0.409528 0.875179
vn 0.674703 -0.421430 0.605914
vn -0.847713 -0.376690 -0.373394
vn -0.101840 0.974029 0.202185
vn -0.232276 0.914792 -0.330393
vn -0.473983 0.273354 0.837001
vn 0.810083 0.079928 -0.580828
vn 0.459822 0.616474 -0.639119
vn 0.429640 0.831965 -0.351024
vn 0.866451 0.480697 -0.134709
vn 0.456313 0.861629 0.222114
vn 0.969054 -0.191107 -0.156072
vn -0.499130 -0.792444 -0.350475
vn -0.497635 0.847682 0.183721
usemtl (null).002
s 1
f 1/1/1 2/2/2 3/3/3
f 4/4/4 5/5/5 6/6/6
f 7/7/7 6/8/6 5/9/5
f 8/10/8 9/11/9 10/12/10
f 11/13/11 12/14/12 13/15/13
f 9/16/9 14/17/14 10/18/10
f 15/19/15 3/20/3 16/21/16
f 17/22/17 18/23/18 3/24/3
f 1/25/1 19/26/19 20/27/20
f 21/28/21 1/29/1 8/30/8
f 22/31/22 23/32/23 24/33/24
f 25/34/25 7/35/7 8/36/8
f 26/37/26 10/38/10 14/39/14
f 21/40/21 10/41/10 27/42/27
f 4/43/4 6/44/6 24/45/24
f 7/46/7 5/47/5 28/48/28
f 29/49/29 30/50/30 31/51/31
f 10/52/10 26/53/26 27/54/27
f 31/55/31 32/56/32 29/57/29
f 32/58/32 33/59/33 22/60/22
f 18/61/18 17/62/17 34/63/34
f 5/64/5 24/65/24 23/66/23
f 7/67/7 25/68/25 15/69/15
f 7/70/7 9/71/9 8/72/8
f 13/73/13 20/74/20 35/75/35
f 26/76/26 28/77/28 23/78/23
f 33/79/33 32/80/32 31/81/31
f 27/82/27 19/83/19 21/84/21
f 29/85/29 34/86/34 17/87/17
f 12/88/12 20/89/20 13/90/13
f 5/91/5 4/92/4 24/93/24
f 27/94/27 31/95/31 30/96/30
f 25/97/25 1/98/1 3/99/3
f 28/100/28 9/101/9 7/102/7
f 6/103/6 15/104/15 16/105/16
f 16/106/16 18/107/18 6/108/6
f 24/109/24 6/110/6 18/111/18
f 16/112/16 3/113/3 18/114/18
f 3/115/3 2/116/2 17/117/17
f 12/118/12 11/119/11 30/120/30
f 20/121/20 19/122/19 11/123/11
f 21/124/21 8/125/8 10/126/10
f 31/127/31 27/128/27 33/129/33
f 18/130/18 34/131/34 24/132/24
f 2/133/2 12/134/12 17/135/17
f 22/136/22 33/137/33 23/138/23
f 3/139/3 15/140/15 25/141/25
f 27/142/27 30/143/30 11/144/11
f 26/145/26 14/146/14 28/147/28
f 15/148/15 6/149/6 7/150/7
f 1/151/1 20/152/20 12/153/12
f 29/154/29 12/155/12 30/156/30
f 8/157/8 1/158/1 25/159/25
f 34/160/34 22/161/22 24/162/24
f 14/163/14 9/164/9 28/165/28
f 28/166/28 5/167/5 23/168/23
f 2/169/2 1/170/1 12/171/12
f 27/172/27 26/173/26 33/174/33
f 34/175/34 32/176/32 22/177/22
f 11/178/11 19/179/19 27/180/27
f 33/181/33 26/182/26 23/183/23
f 32/184/32 34/185/34 29/186/29
f 29/187/29 17/188/17 12/189/12
f 11/190/11 13/191/13 36/192/36
f 20/193/20 36/194/36 35/195/35
f 20/196/20 11/197/11 36/198/36
f 19/199/19 1/200/1 21/201/21

View file

@ -12,7 +12,7 @@ void main()
float HighlightSize=0.1; float HighlightSize=0.1;
float ShadowSize=0.2; float ShadowSize=0.2;
float OutlineWidth=0.4; float OutlineWidth=0.2;
vec4 MidColour=gl_FrontMaterial.diffuse; vec4 MidColour=gl_FrontMaterial.diffuse;
vec4 HighlightColour=MidColour*2.0; vec4 HighlightColour=MidColour*2.0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -4,8 +4,8 @@
; the fluxus code to make things look the way they do ; the fluxus code to make things look the way they do
(define debug-messages #t) ; prints out all the messages sent to the renderer (define debug-messages #f) ; prints out all the messages sent to the renderer
(define audio-on #f) (define audio-on #t)
(define (ornament-colour) (vector 0.5 1 0.4)) (define (ornament-colour) (vector 0.5 1 0.4))
(define (pickup-colour) (vector 1 1 1)) (define (pickup-colour) (vector 1 1 1))
@ -15,10 +15,30 @@
(define wire-mode #f) (define wire-mode #f)
(define fog-col (earth-colour)) (define fog-col (earth-colour))
(define fog-strength 0.001) (define fog-strength 0.001)
(define max-ornaments 30) ; per twig (define max-ornaments 10) ; per twig
(define default-grow-speed 0.5) (define default-grow-speed 0.5)
(define grow-overshoot 10)
(when audio-on (oa-start)) ;; start openAL audio (when audio-on (oa-start)) ;; start openAL audio
(define (pre-ripple)
(when (not (pdata-exists? "rip-pref"))
(pdata-copy "p" "rip-pref")))
(define (ripple t speed wave-length)
(pdata-map!
(lambda (p pref)
(vadd pref (vmul (srndvec)
(* 0.1 (+ 1 (sin (+ (* t speed) (* wave-length
(vdist (vtransform p
(minverse (get-transform)))
(vector 0 0 0))))))))))
"p" "rip-pref"))
(define (play-sound sound pos freq)
(when audio-on (let ((growing-noise (oa-load-sample (fullpath "snd/event01.wav"))))
(oa-play growing-noise (vector 0 0 0) (rndf) 0.3))))
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -26,19 +46,25 @@
(class object% (class object%
(init-field (init-field
(pos (vector 0 0 0)) (pos (vector 0 0 0))
(sc 1) (sc 1)
(dir (vector 0 0 1)) (dir (vector 0 0 1))
(property 'none) (property 'none)
(time 0)) (col (vector 1 1 1))
(time 0)
(ev-time 0)
(ev-dur 8)
(ev-col (vector 0 0 1)))
(field (field
(const-scale 2) (const-scale (if (eq? property 'leaf) 2 4))
(rot (vector 0 0 0)) (rot (vector 0 0 0))
(root (with-state (root (with-state
(translate pos) (translate pos)
;(hint-frustum-cull)
(concat (maim dir (vector 0 1 0))) (concat (maim dir (vector 0 1 0)))
(scale (* const-scale sc)) (scale (* const-scale sc))
;(shader "shaders/textoon.vert.glsl" "shaders/textoon.frag.glsl") ;(hint-origin)
;(shader "shaders/textoon.vert.glsl" "shaders/textoon.frag.glsl")
(cond (cond
((eq? property 'wiggle) ((eq? property 'wiggle)
; (opacity 1) ; (opacity 1)
@ -46,22 +72,110 @@
(colour (vector 0.5 0.0 0.0)) (colour (vector 0.5 0.0 0.0))
(load-primitive "meshes/wiggle.obj")) (load-primitive "meshes/wiggle.obj"))
((eq? property 'leaf) ((eq? property 'leaf)
(colour (vector 0.8 1 0.6)) (colour (vector 0.8 1 0.6))
(texture (load-texture "textures/leaf.png")) (texture (load-texture "textures/leaf.png"))
(set! rot (vector 0 0 0)) (set! rot (vector 0 0 0))
(hint-origin) (load-primitive "meshes/leaf.obj"))
(load-primitive "meshes/leaf.obj")) ((eq? property 'horn)
(else (error "")))))) (backfacecull 0)
(shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl")
(colour col)
(set! rot (vector (* (rndf) 360) 0 0))
(load-primitive "meshes/horn.obj"))
((eq? property 'inflatoe)
(backfacecull 0)
(shader "shaders/toon.vert.glsl" "shaders/textoon.frag.glsl")
(texture (load-texture "textures/wiggle.png"))
(colour col)
(set! rot (vector (* (rndf) 360) 0 0))
(let ((p (load-primitive "meshes/inflatoe-full.obj")))
(let ((dp (load-primitive "meshes/inflatoe-empty.obj")))
(with-primitive p
(pdata-copy "p" "p1")
(pdata-add "p2" "v")
(pdata-index-map!
(lambda (i p2)
(with-primitive dp
(pdata-ref "p" i)))
"p2"))
(destroy dp))
p))
(else (error "unrecognised pickup property")))))
(particles (if (eq? property 'horn)
(let ((p (with-state
(parent root)
(translate (vector 0 0 2))
(hint-depth-sort)
(hint-unlit)
(blend-mode 'src-alpha 'one)
(texture (load-texture "textures/particle.png"))
(build-particles 30))))
(with-primitive p
(pdata-add "vel" "v")
(pdata-map!
(lambda (vel)
(vmul (srndvec) 0.01))
"vel")
(pdata-map!
(lambda (s)
(vmul (vector 1 1 1) (* 0.25 (rndf))))
"s")
(pdata-map!
(lambda (c)
(vadd ev-col (vmul (rndvec) (* 0.2 (rndf)))))
"c"))
p)
0)))
(define/public (set-excitations! a b)
(set! ev-dur (if (zero? a) 9999 (/ 1 a)))
(set! ev-col (vmix (vector 0 0 1) (vector 1 0 0) b))
(set! ev-time (* ev-dur 4 (rndf)))
(printf "excite: ~a ~a~n" ev-dur ev-col))
(define/public (update t d) (define/public (update t d)
(when (< time 1) (when (< time 1)
(with-primitive root (with-primitive root
(identity) (identity)
(translate pos) (translate pos)
(concat (maim dir (vector 0 1 0))) (concat (maim dir (vector 0 1 0)))
(rotate rot) (rotate rot)
(scale (* const-scale sc 0.2 time))) (scale (* const-scale sc 0.2 time)))
(set! time (+ time (* 0.1 d))))) (set! time (+ time (* 0.05 d))))
(when (eq? property 'inflatoe)
(with-primitive root
(pdata-map!
(lambda (p p1 p2)
(vmix p1 p2 (+ 0.5 (* 0.5 (sin ev-time)))))
"p" "p1" "p2"))
(set! ev-time (+ ev-time d)))
(when (eq? property 'horn)
(with-primitive particles
(pdata-op "+" "p" "vel")
(pdata-op "*" "c" 0.995))
(when (< ev-time 0)
#;(with-primitive root
(identity)
(translate pos)
(concat (maim dir (vector 0 1 0)))
(rotate rot)
(scale (* const-scale sc 0.2 ev-time)))
; todo inherit and call event happen or somesuch
(with-primitive particles
(pdata-index-map!
(lambda (i p)
(cond ((zero? (random 2)) p)
(else
(pdata-set! "c" i (vector (+ 0.5 (* 0.5 (rndf))) (+ 0.5 (* 0.5 (rndf))) 1))
(vector 0 0 0))))
"p"))
(set! ev-time ev-dur))
(set! ev-time (- ev-time d))))
(super-new))) (super-new)))
@ -81,16 +195,20 @@
(rotate rot) (rotate rot)
(colour (pickup-colour)) (colour (pickup-colour))
(scale 0.3) (scale 0.3)
;(shader "shaders/textoon.vert.glsl" "shaders/textoon.frag.glsl") (hint-frustum-cull)
;(shader "shaders/textoon.vert.glsl" "shaders/textoon.frag.glsl")
(texture (texture
(cond (cond
((eq? type 'wiggle) (load-texture "textures/wiggle.png")) ((eq? type 'wiggle) (load-texture "textures/wiggle.png"))
((eq? type 'leaf) (load-texture "textures/leaf.png")) ((eq? type 'leaf) (load-texture "textures/leaf.png"))
((eq? type 'curly) (load-texture "textures/curl.png")))) ((eq? type 'curly) (load-texture "textures/curl.png"))
(cond (else 0)))
(cond
((eq? type 'wiggle) (load-primitive "meshes/pickup.obj")) ((eq? type 'wiggle) (load-primitive "meshes/pickup.obj"))
((eq? type 'leaf) (load-primitive "meshes/leaf.obj")) ((eq? type 'leaf) (load-primitive "meshes/leaf.obj"))
((eq? type 'curly) (load-primitive "meshes/pickup.obj"))))) ((eq? type 'curly) (load-primitive "meshes/pickup.obj"))
((eq? type 'horn) (backfacecull 0) (scale 5) (load-primitive "meshes/horn.obj"))
((eq? type 'inflatoe) (backfacecull 0) (scale 5) (load-primitive "meshes/inflatoe.obj")))))
(from pos) (from pos)
(destination (vector 0 0 0)) (destination (vector 0 0 0))
(speed 0.05) (speed 0.05)
@ -136,10 +254,10 @@
(ornaments '()) (ornaments '())
(col (vector 1 1 1)) (col (vector 1 1 1))
(tex "") (tex "")
(markers '()) (markers '())
(grow-t 999) (grow-t -1)
(marker-destroy-t 0) (marker-destroy-t 0)
(grow-speed default-grow-speed)) (grow-speed default-grow-speed))
(define/public (get-id) (define/public (get-id)
id) id)
@ -182,27 +300,32 @@
(define/public (add-child-twig-id twig-id) (define/public (add-child-twig-id twig-id)
(set! child-twig-ids (cons twig-id child-twig-ids))) (set! child-twig-ids (cons twig-id child-twig-ids)))
(define/public (growing?)
(< grow-t (+ num-points grow-overshoot)))
(define/public (start-growing) (define/public (start-growing)
(set! grow-t 0) (set! grow-t 0)
(set! markers (cons (build-locator) markers))) (set! markers (cons (build-locator) markers)))
(define/pubment (add-point point width) (define/pubment (add-point point width)
(when audio-on (let ((growing-noise (oa-load-sample (fullpath "snd/event01.wav")))) (when audio-on (let ((growing-noise (oa-load-sample (fullpath "snd/event01.wav"))))
(oa-play growing-noise (vector 0 0 0) (rndf) 0.3))) (oa-play growing-noise (vector 0 0 0) (rndf) 0.3)))
(set! markers (append markers (list (with-state (set! markers (append markers (list (with-state
(parent (get-root)) (parent (get-root))
(translate point) (translate point)
(scale 0.2) (scale 0.1)
(shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl") (shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl")
(colour col) (colour col)
(build-sphere 10 10))))) (build-sphere 8 8)))))
(inner (void) add-point point width)) (inner (void) add-point point width))
(define/public (add-ornament point-index property) (define/public (add-ornament point-index property)
(when (< (length ornaments) max-ornaments) (when (and
(< point-index grow-t)
(< (length ornaments) max-ornaments))
(with-state (with-state
(parent (get-root)) (parent (get-root))
; todo - different ornament-view objects per property needed? ; todo - different ornament-view objects per property needed?
@ -212,10 +335,16 @@
(get-point point-index) (get-point point-index)
(get-width point-index) (get-width point-index)
(vnormalise (vsub (get-point point-index) (vnormalise (vsub (get-point point-index)
(get-point (- point-index 1)))) (get-point (- point-index 1))))
property)) property col))
ornaments))))) ornaments)))))
(define/pubment (set-excitations! a b)
(for-each
(lambda (ornament)
(send (cadr ornament) set-excitations! a b))
ornaments))
(define/pubment (update t d) (define/pubment (update t d)
(for-each (for-each
(lambda (ornament) (lambda (ornament)
@ -223,14 +352,17 @@
ornaments) ornaments)
(inner (void) update t d) (inner (void) update t d)
(when (< grow-t num-points) (when (< grow-t (+ num-points grow-overshoot))
(set! grow-t (+ grow-t (* d grow-speed))) (set! grow-t (+ grow-t (* d grow-speed)))
(when (> 0 (- marker-destroy-t grow-t)) (when (and (not (null? markers)) (> 0 (- marker-destroy-t grow-t)))
; soundtodo: marker gobble ; soundtodo: marker gobble
(set! marker-destroy-t (+ 1 marker-destroy-t)) (set! marker-destroy-t (+ 1 marker-destroy-t))
(destroy (car markers)) (destroy (car markers))
(set! markers (cdr markers))))) (set! markers (cdr markers))))
(when (> grow-t (+ num-points 10))
(set! grow-t 999)))
(super-new))) (super-new)))
@ -296,6 +428,7 @@
(define extruded-twig-view% (define extruded-twig-view%
(class twig-view% (class twig-view%
(inherit growing?)
(inherit-field index radius num-points pos dir col tex grow-t) (inherit-field index radius num-points pos dir col tex grow-t)
(field (field
@ -313,7 +446,7 @@
(when wire-mode (when wire-mode
(hint-none) (hint-none)
(hint-wire)) (hint-wire))
(shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl") (shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl")
(texture (load-texture tex)) (texture (load-texture tex))
(opacity 0.6) (opacity 0.6)
(colour col) (colour col)
@ -342,12 +475,17 @@
(set! index (+ index 1))) (set! index (+ index 1)))
(define/augment (update t d) (define/augment (update t d)
(when (< grow-t (length path)) (when (not (eq? grow-t 999))
(with-primitive root (with-primitive root
(partial-extrude grow-t profile path widths (vector 1 0 0) 0.05)))) (partial-extrude grow-t profile path widths (vector 1 0 0) 0.05)))
#;(when (not (growing?))
(with-primitive root
(pre-ripple)
(ripple t 1 0.001))))
(define/public (get-end-pos) (define/public (get-end-pos)
(list-ref path (if (zero? index) 0 (- index 1))) (list-ref path (if (zero? index) 0 (- index 1)))
#;(with-primitive root (pdata-ref "p" (- (* index (length profile)) 1)))) #;(with-primitive root (pdata-ref "p" (- (* index (length profile)) 1))))
(super-new))) (super-new)))
@ -372,7 +510,7 @@
(build-locator))) (build-locator)))
(seed (with-state (seed (with-state
(parent root) (parent root)
(shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl") (shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl")
(texture (load-texture tex)) (texture (load-texture tex))
(backfacecull 0) (backfacecull 0)
(opacity 0.6) (opacity 0.6)
@ -467,19 +605,25 @@
(set! twigs (cons (list (send twig get-id) twig) twigs)))) (set! twigs (cons (list (send twig get-id) twig) twigs))))
(define/public (add-twig-point twig-id point width) (define/public (add-twig-point twig-id point width)
(when (get-twig twig-id) (when (get-twig twig-id)
(send (get-twig twig-id) add-point point width))) (send (get-twig twig-id) add-point point width)))
(define/public (start-twig-growing twig-id) (define/public (start-twig-growing twig-id)
(when (get-twig twig-id) (when (get-twig twig-id)
(send (get-twig twig-id) start-growing))) (send (get-twig twig-id) start-growing)))
(define/public (grow-seed amount) (define/public (grow-seed amount)
(with-primitive seed (scale amount))) (with-primitive seed (scale amount)))
(define/public (add-ornament twig-id point-index property) (define/public (add-ornament twig-id point-index property)
(when (get-twig twig-id) (when (get-twig twig-id)
(send (get-twig twig-id) add-ornament point-index property))) (send (get-twig twig-id) add-ornament point-index property)))
(define/public (set-excitations! a b)
(for-each
(lambda (twig)
(send (cadr twig) set-excitations! a b))
twigs))
(define/public (update-nutrients t d) (define/public (update-nutrients t d)
(when (not (null? twigs)) (when (not (null? twigs))
@ -536,7 +680,7 @@
(lambda (t) (lambda (t)
(vmul t 10)) (vmul t 10))
"t")) "t"))
) t) ) t)
(with-state (with-state
(texture (load-texture left)) (texture (load-texture left))
@ -580,6 +724,7 @@
(camera-dist 1) (camera-dist 1)
(env-root (with-state (scale 1000) (build-locator))) (env-root (with-state (scale 1000) (build-locator)))
(root-camera-t 0) (root-camera-t 0)
(num-msgs 0)
#;(upper-env (with-state #;(upper-env (with-state
(parent env-root) (parent env-root)
(hint-depth-sort) (hint-depth-sort)
@ -612,8 +757,8 @@
(build-env-box "textures/floor.png" "textures/earth-bottom.png" (build-env-box "textures/floor.png" "textures/earth-bottom.png"
"textures/earth-side.png" "textures/earth-side.png" "textures/earth-side.png" "textures/earth-side.png"
"textures/earth-side.png" "textures/earth-side.png" #t))) "textures/earth-side.png" "textures/earth-side.png" #t)))
(stones '())) (stones '()))
(define/public (setup world-list) (define/public (setup world-list)
(let ((l (make-light 'point 'free))) (let ((l (make-light 'point 'free)))
@ -622,30 +767,29 @@
(light-position l (vector 10 50 -4))) (light-position l (vector 10 50 -4)))
(clear-colour fog-col) (clear-colour fog-col)
(clip 0.5 10000) (clip 1 2000)
(fog fog-col fog-strength 1 100) (fog fog-col fog-strength 1 100)
(set! stones (set! stones
(map (map
(lambda (stone) (lambda (stone)
(let ((p (with-state (let ((p (with-state
(hint-frustum-cull) (hint-frustum-cull)
(shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl") (shader "shaders/toon.vert.glsl" "shaders/toon.frag.glsl")
(colour (stones-colour)) (colour (stones-colour))
(translate (list-ref stone 1)) (translate (list-ref stone 2))
(scale (list-ref stone 2)) (scale (list-ref stone 3))
(rotate (list-ref stone 3)) (rotate (list-ref stone 4))
(texture (load-texture "textures/quartz.png")) (texture (load-texture "textures/quartz.png"))
(load-primitive (list-ref stone 0))))) (load-primitive (list-ref stone 1)))))
(with-primitive p (apply-transform) (recalc-bb)) ; apply the transform to speed up the ray tracing, don't have to tranform the ray into object space (with-primitive p (apply-transform) (recalc-bb)) ; apply the transform to speed up the ray tracing, don't have to tranform the ray into object space
p)) p))
(list-ref world-list 2)))) (list-ref world-list 2))))
(define/public (get-stones) (define/public (get-stones)
stones) stones)
(define/public (add-plant plant) (define/public (add-plant plant)
(printf "ADD-PLANT~n")
;(destroy-plant (send plant get-id)) ; just in case ;(destroy-plant (send plant get-id)) ; just in case
(set! plants (cons (list (send plant get-id) plant) plants))) (set! plants (cons (list (send plant get-id) plant) plants)))
@ -662,11 +806,11 @@
(send (get-plant plant-id) destroy-branch-twig twig-id)) (send (get-plant plant-id) destroy-branch-twig twig-id))
(define/public (add-twig plant-id parent-twig-id point-index twig) (define/public (add-twig plant-id parent-twig-id point-index twig)
(when (get-plant plant-id) (when (get-plant plant-id)
(send (get-plant plant-id) add-twig parent-twig-id point-index twig))) (send (get-plant plant-id) add-twig parent-twig-id point-index twig)))
(define/public (grow-seed plant-id amount) (define/public (grow-seed plant-id amount)
(when (get-plant plant-id) (when (get-plant plant-id)
(send (get-plant plant-id) grow-seed amount))) (send (get-plant plant-id) grow-seed amount)))
(define/public (get-pickup pickup-id) (define/public (get-pickup pickup-id)
@ -680,11 +824,17 @@
(set! pickups (assoc-remove pickup-id pickups))) (set! pickups (assoc-remove pickup-id pickups)))
(define/public (add-ornament plant-id twig-id point-index property) (define/public (add-ornament plant-id twig-id point-index property)
(when (get-plant plant-id) (when (get-plant plant-id)
(send (get-plant plant-id) add-ornament twig-id point-index property))) (send (get-plant plant-id) add-ornament twig-id point-index property)))
(define/public (update t d messages) (define/public (set-excitations! a b)
(for-each
(lambda (plant)
(send (cadr plant) set-excitations! a b))
plants))
(define/public (update t d messages)
(for-each (for-each
(lambda (plant) (lambda (plant)
(send (cadr plant) update t d)) (send (cadr plant) update t d))
@ -770,16 +920,24 @@
(pick-up-pickup (pick-up-pickup
(send msg get-data 'pickup-id))) (send msg get-data 'pickup-id)))
((eq? (send msg get-name) 'pick-up-pickup) ((eq? (send msg get-name) 'new-ornament)
(pick-up-pickup (add-ornament
(send msg get-data 'pickup-id))) (send msg get-data 'plant-id)
(send msg get-data 'twig-id)
((eq? (send msg get-name) 'light-level) (send msg get-data 'point-index)
(for-each (send msg get-data 'property)))
(lambda (p)
(with-primitive p ((eq? (send msg get-name) 'vrob)
(colour (send msg get-data 'amount)))) (set! num-msgs (+ num-msgs 1))
upper-env)) (printf "num light-level msgs: ~a~n" num-msgs)
(set-excitations!
(send msg get-data 'light-level)
(send msg get-data 'soil-moisture))
#;(for-each
(lambda (p)
(with-primitive p
(colour (send msg get-data 'amount))))
upper-env))
)) ))
messages)) messages))

View file

@ -1,4 +1,4 @@
(define-struct ob (type mesh (pos #:mutable) size rot (root #:mutable))) (define-struct ob (type subtype mesh (pos #:mutable) size rot (root #:mutable)))
(define stone-models (list (define stone-models (list
; "meshes/fork.obj" ; "meshes/fork.obj"
@ -7,13 +7,16 @@
"meshes/stone3.obj")) "meshes/stone3.obj"))
(define pickup-models (list (define pickup-models (list
"meshes/leaf.obj")) (list 'leaf "meshes/leaf.obj")
(list 'horn "meshes/horn.obj")
(list 'inflatoe "meshes/inflatoe-full.obj")))
(define (extract-list t l) (define (extract-list t l)
(foldl (foldl
(lambda (ob l) (lambda (ob l)
(if (eq? (ob-type ob) t) (if (eq? (ob-type ob) t)
(cons (list (cons (list
(ob-subtype ob)
(ob-mesh ob) (ob-mesh ob)
(ob-pos ob) (ob-pos ob)
(ob-size ob) (ob-size ob)
@ -36,22 +39,23 @@
(append (append
(build-list num-seeds (build-list num-seeds
(lambda (_) (lambda (_)
(make-ob 'seed "meshes/seed.obj" (make-ob 'seed 'seed "meshes/seed.obj"
(vmul (srndvec) (* size area 0.5)) (vmul (srndvec) (* size area 0.5))
(* 0.12 50) (* 0.12 50)
(vmul (rndvec) 0) 0))) (vmul (rndvec) 0) 0)))
(build-list num-pickups (build-list num-pickups
(lambda (_) (lambda (_)
(make-ob 'pickup (choose pickup-models) (let ((pickup (choose pickup-models)))
(vmul (srndvec) area) (make-ob 'pickup (car pickup) (cadr pickup)
0.1 (vmul (srndvec) (* 150 area))
(vmul (rndvec) 360) 0))) 0.5
(vmul (rndvec) 360) 0))))
(build-list num-stones (build-list num-stones
(lambda (_) (lambda (_)
(make-ob 'stone (choose stone-models) (make-ob 'stone 'stone (choose stone-models)
(vmul (srndvec) area) (vmul (srndvec) area)
(* size (- 1 (expt (rndf) 2))) (* size (- 1 (expt (rndf) 2)))
(vmul (rndvec) 360) 0))))) (vmul (rndvec) 360) 0)))))
@ -63,9 +67,10 @@
(set-ob-root! ob (with-state (set-ob-root! ob (with-state
(cond (cond
((eq? (ob-type ob) 'seed) (colour (vector 0 1 0))) ((eq? (ob-type ob) 'seed) (colour (vector 0 1 0)))
((eq? (ob-type ob) 'pickup) (colour (vector 1 1 0))) ((eq? (ob-type ob) 'pickup) (backfacecull 0) (hint-unlit) (colour (vector 1 1 0)))
((eq? (ob-type ob) 'stone) (colour (vector 1 0.5 0)))) ((eq? (ob-type ob) 'stone) (colour (vector 1 0.5 0))))
(load-primitive (ob-mesh ob))))) (load-primitive (ob-mesh ob))))
(when (eq? (ob-type ob) 'stone) (with-primitive (ob-root ob) (hide 1))))
l)) l))
(define (relax l amount) (define (relax l amount)
@ -95,7 +100,7 @@
(clear) (clear)
(clear-colour 0) (clear-colour 0)
(define s (init 5 30 200 1 10)) (define s (init 5 200 200 1 10))
(build s) (build s)
(define l (make-light 'spot 'free)) (define l (make-light 'spot 'free))

File diff suppressed because one or more lines are too long