Fortraneries/BloubWorld/toinc.awk

53 lines
1.0 KiB
Awk
Raw Normal View History

2022-02-06 23:45:08 +01:00
2022-03-25 22:42:15 +01:00
#
# Input for this script is generated by 'exportbloubs.f90'
2022-02-06 23:45:08 +01:00
#
# this code is (C) 2022 tTh
#
BEGIN {
count = 0
2022-03-18 12:21:40 +01:00
bx = by = bz = 0.0
2022-02-06 23:45:08 +01:00
print "// GENERATED FILE, DON'T TOUCH IT !"
print "// --------------------------------"
print
2022-02-06 23:45:08 +01:00
print "#declare Bloubs = object\n{"
print "union\t{"
}
{
2022-03-18 12:21:40 +01:00
age = $5
2022-03-25 22:42:15 +01:00
merged = $6
color = "Cyan"
if (merged) {
2024-02-06 17:03:00 +01:00
if (age > 150) color = "Orange"
else color = "Yellow"
2022-03-25 22:42:15 +01:00
}
else {
2024-02-06 17:03:00 +01:00
if (age > 150) color = "DarkGreen"
2022-03-25 22:42:15 +01:00
else color = "Aquamarine"
}
2024-02-01 17:39:33 +01:00
if (age < 18) color = "Gray40"
if (age < 9) color = "Blue"
2022-03-25 22:42:15 +01:00
2022-03-18 12:21:40 +01:00
bx += $1
by += $2
bz += $3
2022-02-17 14:10:15 +01:00
pigment = "pigment { color " color " }"
2024-01-30 13:31:54 +01:00
printf "\tsphere { <%f, %f, %f>, %f \n\t\t%s }\n", \
2022-02-17 14:10:15 +01:00
$1, $2, $3, $4, pigment
2022-02-06 23:45:08 +01:00
count++
}
END {
2024-01-30 13:31:54 +01:00
# print "\t}\n"
print "\t} // end of union\n"
2024-01-31 11:10:54 +01:00
print "finish { phong 0.57 specular 0.67 }\n"
2024-01-30 13:31:54 +01:00
print "}\n"
2022-02-06 23:45:08 +01:00
print "#declare Nb_Bloubs = ", count, ";\n"
2022-03-18 12:21:40 +01:00
print "#declare Bary_X = ", bx/count, ";";
print "#declare Bary_Y = ", by/count, ";";
print "#declare Bary_Z = ", bz/count, ";";
2022-02-06 23:45:08 +01:00
}