adding a lot of grabage

This commit is contained in:
tth 2022-03-18 12:21:40 +01:00
parent dd94a4a2a8
commit ed2b04caeb
13 changed files with 292 additions and 88 deletions

View File

@ -13,6 +13,7 @@ exportbloubs
genbloubs genbloubs
movebloubs movebloubs
mergebloubs mergebloubs
listbloubs
essai essai
core core

View File

@ -1,6 +1,7 @@
all: genbloubs movebloubs exportbloubs mergebloubs \ all: genbloubs movebloubs exportbloubs mergebloubs \
listbloubs \
essai essai
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -10,8 +11,8 @@ OBJS = bloubspace.o povstuff.o mathstuff.o
# ------------------------------------------------------------ # ------------------------------------------------------------
essai: essai.f90 Makefile mathstuff.o essai: essai.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< mathstuff.o -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -46,6 +47,9 @@ genbloubs: genbloubs.f90 Makefile $(OBJS)
movebloubs: movebloubs.f90 Makefile $(OBJS) movebloubs: movebloubs.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
listbloubs: listbloubs.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
exportbloubs: exportbloubs.f90 Makefile $(OBJS) exportbloubs: exportbloubs.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@

View File

@ -6,15 +6,17 @@ Le BloubWorld (que l'on appelle aussi BloubSpace) est un espace borné
dans lequel se déplacent des **bloubs**, lesquels sont dans lequel se déplacent des **bloubs**, lesquels sont
des sortes de particule des sortes de particule
munie de certaines propriétés (age, grosseur, vitesses, etc...). munie de certaines propriétés (age, grosseur, vitesses, etc...).
Lesquelles évoluent en fonction du temps. Lesquelles valeurs peuvent évoluer en fonction du temps.
## Description d'un bloub ## Description d'un bloub
Attention cette description n'est qu'un exemple !
``` ```
type t_bloubs type t_bloubs
character(8) :: nick character(8) :: nick
logical :: alive logical :: alive
integer :: num integer :: state
real :: px, py, pz real :: px, py, pz
real :: vx, vy, vz real :: vx, vy, vz
real :: radius real :: radius
@ -67,14 +69,18 @@ Sortie sur `stdout` de certaines propriétes des bloubs, qui seront
reprise par un (ou des) scripts écrits en `awk`, afin de générer reprise par un (ou des) scripts écrits en `awk`, afin de générer
ce qu'il faut pour les différents moteurs de rendu. ce qu'il faut pour les différents moteurs de rendu.
Bon, pour le moment, il n'y a que POVray :) Bon, pour le moment, il n'y a que POVray, mais Gnuplot arrivera en second.
### mergebloubs ### mergebloubs
Alors, celui-ci, il n'est pas vraiment au point. Alors, celui-ci, il n'est pas vraiment au point. Il faut tout ré-écrire
et faire gaffe à l'explosion quadratique.
## TODO ## TODO
- Concevoir un système de _bouding box_ facile à utiliser - Concevoir un système de _bouding box_ facile à utiliser
- Réfléchir à une politique de vieillissement des bloubs - Réfléchir à une politique de vieillissement des bloubs
- le `merge` de deux bloubs est-il un acte politique ?

View File

@ -0,0 +1 @@
cube -0.35 -0.5 -0.5 5.0 5.0 5.0

View File

@ -11,35 +11,139 @@ module bloubspace
type t_bloubs type t_bloubs
character(8) :: nick character(8) :: nick
logical :: alive logical :: alive
integer :: state
integer :: num ! ??? integer :: num ! ???
real :: px, py, pz real :: px, py, pz
real :: vx, vy, vz real :: vx, vy, vz
real :: radius real :: radius
integer :: age integer :: age, agemax
end type t_bloubs end type t_bloubs
type t_boundingbox
character(8) :: id
real :: xm, ym, zm
real :: xp, yp, zp
end type t_boundingbox
contains ! ----------------------------------------- contains ! -----------------------------------------
! ----------------------------------------------------------------
subroutine load_boundingbox(infile, where, name)
character(*), intent(in) :: infile
type(t_boundingbox), intent (out) :: where
character(8), intent(in) :: name
integer :: fd, errcode
character(200) :: message
print *, "try to load ", infile
! put some default values
where%id = "default"
where%xm = -5.0 ; where%ym = -5.0 ; where%zm = -5.0
where%xp = 5.0 ; where%yp = 5.0 ; where%zp = 5.0
! and now, try to read the file
open (newunit=fd, file=trim(infile), &
status='old', action='read', &
iostat=errcode, iomsg=message)
if (errcode .NE. 0) then
stop 'OPEN ERROR ' // message
endif
do
read(unit=fd, iostat=errcode, iomsg=message, &
fmt='(A,6F8.3)') where
if (errcode .NE. 0) then
! print *, "errcode ", errcode
print *, "message: ", message
exit
endif
enddo
close(fd)
end subroutine load_boundingbox
! ----------------------------------------------------------------
subroutine random_pv (blb) subroutine random_pv (blb)
type(t_bloubs), intent (inout) :: blb type(t_bloubs), intent (out) :: blb
blb%px = 1.35 * (rand() - 0.50) blb%px = 4.33 * (rand() - 0.50)
blb%py = 0.50 + (rand() * 0.50) blb%py = 3.33 * (rand() - 0.50)
blb%pz = 1.90 * (rand() - 0.50) blb%pz = 4.51 * (rand() - 0.50)
blb%vx = (rand() - 0.5) / 2.500 blb%vx = (rand()) / 2.000
blb%vy = (rand() - 0.1) / 4.000 blb%vy = (rand()) / 2.900
blb%vz = (rand() - 0.5) / 2.500 blb%vz = (rand()) / 2.000
blb%state = 0
blb%alive = .TRUE. blb%alive = .TRUE.
blb%age = 0
blb%agemax = 500
end subroutine end subroutine
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
! Load a blbs file into an array of bloubs ! Load a blbs file into an array of bloubs
subroutine spit_bloubs_to_file (fname, blbarray, towrite)
character(*), intent(in) :: fname
type(t_bloubs), dimension(:) :: blbarray
integer, intent(in) :: towrite
write (0, '(" spiting", (I6), "bloubs to", (A), "file")') &
towrite, trim(fname)
STOP ' : NOT IMPLEMENTED'
end subroutine
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
! Dump an array of bloubs to a blbs file. ! Dump an array of bloubs to a blbs file.
!
subroutine slurp_bloubs_file_in_array (infile, blbarray, nbread)
character(*), intent(in) :: infile
type(t_bloubs), dimension(:), intent(out) :: blbarray
integer, intent(out) :: nbread
character(200) :: chaine
integer :: input, errcode, idx
type(t_bloubs) :: bloub
write(0, '(" slurping from file [", (A), "]")') trim(infile)
open( newunit=input, &
file=trim(infile), form='unformatted', &
iostat=errcode, iomsg=chaine, &
action='read', status='old')
if (0 .ne. errcode) then
write(0, '(" errcode ", I8, 2X, A)') errcode, chaine
STOP " : CAN'T OPEN FILE " // trim(infile)
endif
! write(0, '((A, I3))') " slurping from unit ", input
nbread = 0
idx = 1;
do
read (unit=input, iostat=errcode, iomsg=chaine) bloub
if (0 .ne. errcode) then
! may be we got an EOF ?
! write(0, '(" got errcode on read ", (I8,1X,A))') errcode, chaine
exit
endif
nbread = nbread + 1
! print *, bloub%nick, bloub%radius
if (bloub%alive) then
blbarray(idx) = bloub
idx = idx + 1
endif
enddo
close(input) ! no error checking ?
write(0, '(" read ", (I8), " bloubs")') nbread
end subroutine
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
! Display a bloub content to stderr ! Display a bloub content to stderr
@ -52,7 +156,7 @@ module bloubspace
if (blb%alive) then if (blb%alive) then
life = "alive" life = "alive"
else else
life = "dead" life = "dead "
endif endif
write (0, '(4X, A)') '+--------------- ' // message // " -------" write (0, '(4X, A)') '+--------------- ' // message // " -------"
write (0, '(4X,A3,A8,2X,I6,4X,A5,4X,I5)') '| ', & write (0, '(4X,A3,A8,2X,I6,4X,A5,4X,I5)') '| ', &
@ -76,37 +180,42 @@ module bloubspace
end subroutine end subroutine
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
!
! detection des collisions avec les parois de la boite
! laquelle boite gagnerais beaucoup a etre parametrable.
!
subroutine bound_a_blob (blb) subroutine bound_a_blob (blb)
type(t_bloubs), intent (inout) :: blb type(t_bloubs), intent (inout) :: blb
if (5.0 .lt. blb%px) then if ( 5.0 .lt. (blb%px + blb%radius)) then
blb%vx = -1.0 * blb%vx blb%vx = -1.0 * blb%vx
blb%px = 5.0 blb%px = 5.0
blb%age = blb%age + 1 blb%age = blb%age + 1
endif endif
if (-5.0 .gt. blb%px) then if (-5.0 .gt. (blb%px + blb%radius)) then
blb%vx = -1.0 * blb%vx blb%vx = -1.0 * blb%vx
blb%px = -5.0 blb%px = -5.0
blb%age = blb%age + 1 blb%age = blb%age + 1
endif endif
if (0.0 .gt. blb%py) then ! vertical axe
if (-4.99 .gt. (blb%py + blb%radius)) then
blb%vy = -1.0 * blb%vy blb%vy = -1.0 * blb%vy
blb%py = 0.0 blb%py = blb%radius
blb%age = blb%age + 1 blb%age = blb%age + 1
endif endif
if (4.99 .lt. blb%py) then !! if ( 4.99 .lt. (blb%py + blb%radius)) then ! overshoot ?
blb%vy = -1.0 * blb%vy blb%vy = -1.0 * blb%vy
blb%age = blb%age + 1 blb%age = blb%age + 1
blb%py = 4.99 !! blb%py = 5.0 - blb%radius !!
endif endif
if (5.0 .lt. blb%pz) then if ( 5.0 .lt. (blb%pz + blb%radius)) then
blb%vz = -1.0 * blb%vz blb%vz = -1.0 * blb%vz
blb%age = blb%age + 1 blb%age = blb%age + 1
blb%pz = 5.0 blb%pz = 5.0
endif endif
if (-5.0 .gt. blb%pz) then if (-5.0 .gt. (blb%pz + blb%radius)) then
blb%vz = -1.0 * blb%vz blb%vz = -1.0 * blb%vz
blb%age = blb%age + 1 blb%age = blb%age + 1
blb%pz = -5.0 blb%pz = -5.0
@ -134,7 +243,14 @@ module bloubspace
subroutine green_soylent (blb) subroutine green_soylent (blb)
type(t_bloubs), intent (inout) :: blb type(t_bloubs), intent (inout) :: blb
if (blb%age .gt. 8) then
if (blb%age .gt. 18) then
blb%alive = .FALSE.
endif
! this is juste a molly-guard, don't worry
!
if (blb%radius .GT. 2.0) then
blb%alive = .FALSE. blb%alive = .FALSE.
endif endif
end subroutine end subroutine

View File

@ -1,19 +1,39 @@
program essai program essai
use bloubspace
use mathstuff use mathstuff
implicit none implicit none
integer :: foo type(t_boundingbox) :: bbox
call load_boundingbox("WS/boundinboxes.dat", bbox, "cube ")
print *, bbox
! call test_random(20)
STOP ': BECAUSE JOB IS DONE'
! --------------------------------------------------------------
contains
subroutine test_random(nbre)
integer, intent(in) :: nbre
integer :: foo, bar
real :: quux real :: quux
double precision :: somme double precision :: somme
call init_random_seed() call init_random_seed() ! in module 'mathstuff'
somme = 0.0 somme = 0.0
do foo=1, nbre
do foo=1, 5
quux = rand() quux = rand()
somme = somme + quux somme = somme + quux
print *, foo, quux, somme/foo bar = mod(irand(), 7)
print *, foo, quux, somme/foo, bar
enddo enddo
end subroutine test_random
! --------------------------------------------------------------
end program end program

View File

@ -18,22 +18,20 @@ program genbloubs
call getarg(2, str) call getarg(2, str)
read(str,*) nbbloubs read(str,*) nbbloubs
write (0, '(A,I6,A)') & write (0, '(A,I8,A)') &
"*** generating ", nbbloubs, " bloubs to "//trim(filename) "*** generating ", nbbloubs, " bloubs to "//trim(filename)
! print *, "generating ", nbbloubs, "bloubs to ", filename open(newunit=idu, file=trim(filename), &
form='unformatted', &
open(newunit=idu, file=trim(filename), form='unformatted', & access="sequential", &
action='write', status='replace') action='write', status='replace')
do i = 1, nbbloubs do i = 1, nbbloubs
bloub%nick = 'noname ' bloub%nick = 'noname '
bloub%num = i + 41 bloub%num = i + 41
bloub%alive = .TRUE.
call random_pv(bloub) call random_pv(bloub)
bloub%radius = 0.025 bloub%radius = 0.035 + (0.03*rand())
bloub%age = 0
write(idu) bloub ! no error control ? write(idu) bloub ! no error control ?

45
BloubWorld/listbloubs.f90 Normal file
View File

@ -0,0 +1,45 @@
program movebloubs
use bloubspace
implicit none
integer, parameter :: NB_MAX_BLOUBS = 200000
! --------------------------------------------------------------
character(200) :: infile
integer :: errcode, i
integer :: nbgot
type(t_bloubs), dimension(:), allocatable :: bloubs
i = IARGC()
if (i .ne. 1) then
STOP ": BAD ARG ON COMMAND LINE"
endif
call getarg(1, infile)
write (0, '(A)') &
"*** listing bloubs from "//trim(infile)
allocate (bloubs(NB_MAX_BLOUBS), stat=errcode)
if (0 .NE. errcode) then
STOP " : NO ENOUGH MEMORY"
endif
do i = 1, NB_MAX_BLOUBS
bloubs(i)%alive = .FALSE.
enddo
call slurp_bloubs_file_in_array(trim(infile), bloubs, nbgot)
write(0, '(A,I6,1X,A)') "slurped ", nbgot, "bloubs"
do i=1,nbgot
write(6, '(A8, 1X, 1L, 1X, I2, 3X, F8.3, 3X, 3F8.3, 3X, 3F8.3)') &
bloubs(i)%nick, bloubs(i)%alive, &
bloubs(i)%state, &
bloubs(i)%radius, &
bloubs(i)%px, bloubs(i)%py, bloubs(i)%pz, &
bloubs(i)%vx, bloubs(i)%vy, bloubs(i)%vz
enddo
end program
! \o_

View File

@ -5,21 +5,23 @@ module mathstuff
! ---------------------------------------------------------------- ! ----------------------------------------------------------------
! really quick'n'dirty hack ! really quick'n'dirty hack
! not working yet... ! not really tested yet...
subroutine init_random_seed() subroutine init_random_seed()
integer, dimension(3) :: tarray integer, dimension(3) :: tarray
integer :: t3 integer :: t3, foo
real :: dummy real :: dummy
call itime(tarray) call itime(tarray)
t3 = 3600*tarray(1) + 60*tarray(2) + tarray(3) t3 = 3600*tarray(1) + 60*tarray(2) + tarray(3)
write(0, '(A,3I3,A,I6)') "sranding: ", tarray, " --> ", t3 ! write(0, '(A,3I3,A,I6)') "sranding: ", tarray, " --> ", t3
call srand(t3) call srand(t3)
! after initializing the random generator engine, ! after initializing the random generator engine,
! you MUST use it for initializing the initializer ! you MUST use it for initializing the initializer
do foo=1, tarray(1)+5
dummy = rand() dummy = rand()
enddo
end subroutine end subroutine

View File

@ -42,6 +42,8 @@ program movebloubs
STOP " : CAN'T OPEN " // trim(outfile) // "FOR WRITE" STOP " : CAN'T OPEN " // trim(outfile) // "FOR WRITE"
endif endif
! write(0, '("Units: ", 2I5)') inu, outu
bx = 0.0; by = 0.0; bz = 0.0 bx = 0.0; by = 0.0; bz = 0.0
compteur = 0 compteur = 0
killed = 0 killed = 0
@ -53,18 +55,20 @@ program movebloubs
exit exit
endif endif
! moving and boundingboxing ! moving, morphing and boundingboxing
call move_bloub (bloub, 0.14) call move_bloub (bloub, 0.185)
call bound_a_blob (bloub) call bound_a_blob (bloub)
if (bloub%radius .GT. 0.052) then if (bloub%radius .GT. 0.0151) then
bloub%radius = bloub%radius * 0.985 bloub%radius = bloub%radius * 0.9970
endif endif
call green_soylent (bloub) call green_soylent (bloub)
if (.NOT. bloub%alive) then if (.NOT. bloub%alive) then
! write(0, '(A)') " KILL!" ! write(0, '(A)') " KILL!"
killed = killed + 1 killed = killed + 1
cycle ! cycle ! ???
endif endif
! calcul du barycentre ! calcul du barycentre
bx = bx + dble(bloub%px) bx = bx + dble(bloub%px)
by = by + dble(bloub%py) by = by + dble(bloub%py)
@ -83,11 +87,11 @@ program movebloubs
! ok, we have read all the bloubs in the input file ! ok, we have read all the bloubs in the input file
! insert some fancy conditional here ! insert some fancy conditional here
if (compteur .LT. 1600) then if (compteur .LT. 3000) then
rnd = rand() rnd = rand()
write (0, '(A,1X,F5.3)') "try to add bloubs, rnd is", rnd write (0, '(A,1X,F9.6)') "try to add bloubs, rnd is", rnd
if (rnd .LT. 0.02) then if (rnd .LT. 0.0450) then
call add_more_bloubs(outu, 12, 0.210) call add_more_bloubs(outu, 24, 0.0990)
endif endif
endif endif
@ -105,22 +109,23 @@ program movebloubs
! -------------------------------------------------------------- ! --------------------------------------------------------------
contains contains
subroutine add_more_bloubs(un, nbre, wtf) subroutine add_more_bloubs(un, nbre, rayon)
integer, intent(in) :: un, nbre integer, intent(in) :: un, nbre
real, intent(in) :: wtf real, intent(in) :: rayon
type(t_bloubs) :: bloub type(t_bloubs) :: bloub
integer :: foo integer :: foo, count
write(0, '(A,I4,1X,A)') "adding", nbre, "bloubs" count = nbre+mod(irand(), 7)
write(0, '(A,I4,1X,A)') "adding", count, "bloubs"
do foo=1, nbre do foo=1, count
bloub%nick = 'newbie ' bloub%nick = 'newbie '
call random_pv(bloub) call random_pv(bloub)
bloub%radius = wtf bloub%radius = rayon + (0.15*rand())
bloub%age = 1 bloub%age = 1
bloub%alive = .TRUE. bloub%alive = .TRUE.
! call display_bloub (bloub, "new bloub") bloub%num = mod(irand(), 42)
write(un) bloub ! no error control ? write(un) bloub ! no error control ?
enddo enddo

View File

@ -7,15 +7,15 @@
INCFILE="WS/bloubs.inc" INCFILE="WS/bloubs.inc"
TMPPNG="/dev/shm/bloubs7.png" TMPPNG="/dev/shm/bloubs7.png"
POVOPT="+Q9 +a -v -d -W1024 -H768 -WT2" POVOPT="+Q9 +a -v -d -W1600 -H1200 -WT2"
DDIR="frames" DDIR="frames/a"
LOGERR="log.error" LOGERR="log.error"
# --- put the work file in ramdisk # --- put the work file in ramdisk
BLBS_IN="/dev/shm/in.blbs" BLBS_IN="/dev/shm/in.blbs"
BLBS_OUT="/dev/shm/out.blbs" BLBS_OUT="/dev/shm/out.blbs"
NBIMG=1800 NBIMG=3000
make all make all
err=$? err=$?
@ -30,9 +30,9 @@ printf "\n#declare NbImg = %d;\n" $NBIMG > WS/nbimg.inc
# first, we have to make a seminal buch of bloubs # first, we have to make a seminal buch of bloubs
# --> this function need to be parametrizable # --> this function need to be parametrizable
# #
./genbloubs ${BLBS_IN} 15 ./genbloubs ${BLBS_IN} 3000
for idx in $(seq 0 $NBIMG) for idx in $(seq 0 $((NBIMG-1)) )
do do
echo "======== run passe $idx =========" echo "======== run passe $idx ========="
@ -43,45 +43,41 @@ do
if [ 0 -ne $? ] ; then if [ 0 -ne $? ] ; then
tail -15 $LOGERR tail -15 $LOGERR
sleep 30 sleep 30
else
grep "Trace Time" $LOGERR
fi fi
td=$(date +'%F %R:%S') td=$(date +'%F %R:%S')
hi=$(printf "#%05d" $idx) hi=$(printf "#%05d" $idx)
count=$(head -1 "WS/log.nb_bloubs") count=$(tail -1 "WS/log.nb_bloubs")
PNG=$(printf "%s/%05d.png" ${DDIR} $idx) PNG=$(printf "%s/%05d.png" ${DDIR} $idx)
convert ${TMPPNG} \ convert ${TMPPNG} \
-font Courier-Bold \ -font Courier-Bold \
-pointsize 16 \ -pointsize 24 \
-fill Orange \
-gravity south-east \
-annotate +15+10 "$td" \
-gravity south-west \
-annotate +15+10 "$hi" \
-fill Yellow \ -fill Yellow \
-pointsize 32 \ -gravity south-east \
-annotate +25+5 "$td" \
-gravity south-west \
-annotate +25+5 "$hi" \
-fill Yellow \
-pointsize 48 \
-gravity north-east \ -gravity north-east \
-annotate +15+10 "$count" \ -annotate +25+5 "$count" \
-gravity north-west \
-annotate +25+5 "BloubWorld" \
$PNG $PNG
echo $PNG '[done]' echo $PNG '[done]'
./movebloubs ${BLBS_IN} ${BLBS_OUT} ./movebloubs ${BLBS_IN} ${BLBS_OUT}
# ./mergebloubs ${BLBS_OUT} ${BLBS_IN}
mv ${BLBS_OUT} ${BLBS_IN} mv ${BLBS_OUT} ${BLBS_IN}
echo echo
sleep 15
done done
rm $LOGERR rm $LOGERR
# XXX convert -delay 10 -resize 50% -colors 192 \
# XXX $DDIR/????[0]*.png foo.gif
nice ./encode.sh nice ./encode.sh

View File

@ -11,6 +11,8 @@ global_settings {
#include "colors.inc" #include "colors.inc"
#include "WS/nbimg.inc" #include "WS/nbimg.inc"
#declare NormClock = clock / NbImg; #declare NormClock = clock / NbImg;
@ -31,15 +33,15 @@ object {
object { object {
union { union {
plane { <1, 0, 0>, -23 } plane { <1, 0, 0>, -32 }
plane { <1, 0, 0>, 23 } plane { <1, 0, 0>, 32 }
plane { <0, 1, 0>, -23 } plane { <0, 1, 0>, -23 }
plane { <0, 1, 0>, 23 } plane { <0, 1, 0>, 23 }
plane { <0, 0, 1>, 50 } plane { <0, 0, 1>, 50 }
texture { texture {
pigment { color srgb <0.195, 0.144, 0.111> } pigment { color srgb <0.125, 0.144, 0.111> }
finish { phong 0.18 metallic 0.35 reflection 0.35 } finish { phong 0.18 metallic 0.25 reflection 0.35 }
} }
} }
} }
@ -54,7 +56,7 @@ object {
{ {
merge { merge {
cylinder { <0, BV, 0>, <0, -BV, 0>, BR } cylinder { <0, BV, 0>, <0, -BV, 0>, BR }
cylinder { <0, 0.012, 0>, <0, -0.012, 0>, BR*3 } cylinder { <0, 0.012, 0>, <0, -0.012, 0>, BR*4 }
} }
} }

View File

@ -5,17 +5,22 @@
BEGIN { BEGIN {
count = 0 count = 0
bx = by = bz = 0.0
print "// GENERATED FILE, DON'T TOUCH IT !" print "// GENERATED FILE, DON'T TOUCH IT !"
print "#declare Bloubs = object\n{" print "#declare Bloubs = object\n{"
print "union\t{" print "union\t{"
} }
{ {
if ($5 > 6) color = "Turquoise" age = $5
if (age < 2) color = "Orange"
else if (age > 8) color = "Gray70"
else color = "Sienna" else color = "Sienna"
bx += $1
by += $2
bz += $3
pigment = "pigment { color " color " }" pigment = "pigment { color " color " }"
printf "\t\tsphere { <%f, %f, %f>, %f %s }\n", \ printf "\tsphere { <%f, %f, %f>, %f %s }\n", \
$1, $2, $3, $4, pigment $1, $2, $3, $4, pigment
count++ count++
} }
@ -23,4 +28,7 @@ BEGIN {
END { END {
print "\t} // end of union\n}\n" print "\t} // end of union\n}\n"
print "#declare Nb_Bloubs = ", count, ";\n" print "#declare Nb_Bloubs = ", count, ";\n"
print "#declare Bary_X = ", bx/count, ";";
print "#declare Bary_Y = ", by/count, ";";
print "#declare Bary_Z = ", bz/count, ";";
} }