#!/bin/bash

source ./config.sh

DDIR="frames/triplane"
DSTOPT="/dev/shm/triplane-altitude.png"
FIMGTMP="/dev/shm/triplane-cumul.fimg"

# rm "WS/log.timelapse"

DEBUT=$(date +'%s')

for i in $( seq 0 $((NBIMG - 1)) )
do

	dst=$(printf "%s/%05d.png" $DDIR $i)
	tag=$(printf "[%06d:%04d]"			\
			$(($(date +'%s')-$DEBUT))    $i   )
	echo $dst $tag

	j=$(( i * 2 ))
	fimgA=$(printf "%s/%04d.fimg" $SILO $j		)
	fimgB=$(printf "%s/%04d.fimg" $SILO $((j+1))	)
	fimgC=$(printf "%s/%04d.fimg" $SILO $((j+2))	)
	fimgD=$(printf "%s/%04d.fimg" $SILO $((j+3))	)
	fimgE=$(printf "%s/%04d.fimg" $SILO $((j+3))	)
	# echo $fimgA $fimgB $fimgC

	cumulfimgs -o $FIMGTMP   $fimgA $fimgB $fimgC $fimgD $fimgE

	./separator $FIMGTMP

	povray -itriplane +K$i ${POVOPT} -o${DSTOPT}

	convert   $DSTOPT					\
			-font		Courier-Bold		\
			-fill		Orange			\
			-pointsize	48			\
			-annotate +21+49 "${tag}"		\
			$dst

	sleep  9

done