Fortraneries/BloubWorld/toinc.awk

47 lines
862 B
Awk
Raw Normal View History

2022-02-07 09:45:08 +11:00
2022-03-26 08:42:15 +11:00
#
# Input for this script is generated by 'exportbloubs.f90'
2022-02-07 09:45:08 +11:00
#
# this code is (C) 2022 tTh
#
BEGIN {
count = 0
2022-03-18 22:21:40 +11:00
bx = by = bz = 0.0
2022-02-07 09:45:08 +11:00
print "// GENERATED FILE, DON'T TOUCH IT !"
print "#declare Bloubs = object\n{"
print "union\t{"
}
{
2022-03-18 22:21:40 +11:00
age = $5
2022-03-26 08:42:15 +11:00
merged = $6
color = "Cyan"
if (age < 2) color = "Yellow"
if (merged) {
if (age > 12) color = "Orange"
else color = "Red"
}
else {
if (age > 12) color = "CadetBlue"
else color = "Aquamarine"
}
2022-03-18 22:21:40 +11:00
bx += $1
by += $2
bz += $3
2022-02-18 00:10:15 +11:00
pigment = "pigment { color " color " }"
2022-03-18 22:21:40 +11:00
printf "\tsphere { <%f, %f, %f>, %f %s }\n", \
2022-02-18 00:10:15 +11:00
$1, $2, $3, $4, pigment
2022-02-07 09:45:08 +11:00
count++
}
END {
print "\t} // end of union\n}\n"
print "#declare Nb_Bloubs = ", count, ";\n"
2022-03-18 22:21:40 +11:00
print "#declare Bary_X = ", bx/count, ";";
print "#declare Bary_Y = ", by/count, ";";
print "#declare Bary_Z = ", bz/count, ";";
2022-02-07 09:45:08 +11:00
}