From c8667ce6ae94929e9bc06c9af51b6589bc528946 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 17 Jun 2010 09:16:20 -0600 Subject: Fully implement POV-Ray transformations. --- tests/dimension/Makefile.am | 2 ++ tests/dimension/csg.sh | 5 +-- tests/dimension/demo.sh | 10 +++--- tests/dimension/transformations.pov | 39 +++++++++++++++++++++++ tests/dimension/transformations.sh | 63 +++++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 tests/dimension/transformations.pov create mode 100755 tests/dimension/transformations.sh (limited to 'tests/dimension') diff --git a/tests/dimension/Makefile.am b/tests/dimension/Makefile.am index d13b56e..bdb94ed 100644 --- a/tests/dimension/Makefile.am +++ b/tests/dimension/Makefile.am @@ -25,6 +25,7 @@ TESTS = punctuation.sh \ labels.sh \ directives.sh \ arithexp.sh \ + transformations.sh \ csg.sh \ demo.sh TESTS_ENVIRONMENT = top_builddir=$(top_builddir) @@ -40,6 +41,7 @@ EXTRA_DIST = $(TESTS) \ directives.inc \ directives.pov \ arithexp.pov \ + transformations.pov \ csg.pov \ demo.pov diff --git a/tests/dimension/csg.sh b/tests/dimension/csg.sh index 7f4732c..360398c 100755 --- a/tests/dimension/csg.sh +++ b/tests/dimension/csg.sh @@ -75,8 +75,9 @@ csg_exp="$(echo -n \ (integer 0) (integer 0)) pigment-modifiers)))) (object-modifiers - (translate (vector (integer 0) (integer 20) (integer 0) - (integer 0) (integer 0))))))' \ + (transformation + (translation (vector (integer 0) (integer 20) (integer 0) + (integer 0) (integer 0)))))))' \ | tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')" if [ "$csg" != "$csg_exp" ]; then diff --git a/tests/dimension/demo.sh b/tests/dimension/demo.sh index 22308dc..18f1c05 100755 --- a/tests/dimension/demo.sh +++ b/tests/dimension/demo.sh @@ -28,8 +28,9 @@ demo_exp=$(echo -n \ (right (vector (float 1.6) (integer 0) (integer 0) (integer 0) (integer 0))) (look_at (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0))) - (rotate (vector (integer 0) (integer 53) (integer 0) - (integer 0) (integer 0)))) + (transformation + (rotation (vector (integer 0) (integer 53) (integer 0) + (integer 0) (integer 0))))) (background (vector (integer 0) (float 0.1) (float 0.2) (float 0.1) (integer 0))) (light_source @@ -42,8 +43,9 @@ demo_exp=$(echo -n \ (vector (integer -1) (integer -1) (integer -1) (integer 0) (integer 0)) (vector (integer 1) (integer 1) (integer 1) (integer 0) (integer 0)) (object-modifiers - (rotate (vector (integer 45) (integer 0) (integer 0) - (integer 0) (integer 0))) + (transformation + (rotation (vector (integer 45) (integer 0) (integer 0) + (integer 0) (integer 0)))) (texture (pigment (vector (integer 0) (integer 0) (integer 1) diff --git a/tests/dimension/transformations.pov b/tests/dimension/transformations.pov new file mode 100644 index 0000000..4b56c3f --- /dev/null +++ b/tests/dimension/transformations.pov @@ -0,0 +1,39 @@ +/************************************************************************* + * Copyright (C) 2009-2010 Tavian Barnes * + * * + * This file is part of The Dimension Test Suite. * + * * + * The Dimension Test Suite is free software; you can redistribute it * + * and/or modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * The Dimension Test Suite is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +// Test transformations + +#declare Trans = transform { translate 1*z } + +sphere { + 0, 0 + translate -1*x + rotate 90*y + scale 2 + transform Trans + matrix <1, 1, 0, + 0, 1, 0, + 0, 0, 1, + 0, 0, 0> + transform { + Trans + rotate 45*z + inverse + } +} diff --git a/tests/dimension/transformations.sh b/tests/dimension/transformations.sh new file mode 100755 index 0000000..3e6b8e2 --- /dev/null +++ b/tests/dimension/transformations.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +######################################################################### +# Copyright (C) 2009-2010 Tavian Barnes # +# # +# This file is part of The Dimension Test Suite. # +# # +# The Dimension Test Suite is free software; you can redistribute it # +# and/or modify it under the terms of the GNU General Public License as # +# published by the Free Software Foundation; either version 3 of the # +# License, or (at your option) any later version. # +# # +# The Dimension Test Suite is distributed in the hope that it will be # +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty # +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # +# General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +######################################################################### + +transformations=$(${top_builddir}/dimension/dimension --parse ${srcdir}/transformations.pov) +transformations_exp="$(echo -n \ +'((sphere + (vector (integer 0) (integer 0) (integer 0) (integer 0) (integer 0)) + (integer 0) + (object-modifiers + (transformation + (translation + (vector (integer -1) (integer 0) (integer 0) + (integer 0) (integer 0)))) + (transformation + (rotation + (vector (integer 0) (integer 90) (integer 0) + (integer 0) (integer 0)))) + (transformation + (scale + (vector (integer 2) (integer 2) (integer 2) (integer 2) (integer 2)))) + (transformation + (translation + (vector (integer 0) (integer 0) (integer 1) (integer 0) (integer 0)))) + (transformation + (matrix + (integer 1) (integer 1) (integer 0) + (integer 0) (integer 1) (integer 0) + (integer 0) (integer 0) (integer 1) + (integer 0) (integer 0) (integer 0))) + (transformation + (translation + (vector (integer 0) (integer 0) (integer 1) (integer 0) (integer 0))) + (rotation + (vector (integer 0) (integer 0) (integer 45) + (integer 0) (integer 0))) + inverse))))' \ +| tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g')" + +if [ "$transformations" != "$transformations_exp" ]; then + echo "transformations.pov parsed as \"$transformations\"" >&2 + echo " -- expected \"$transformations_exp\"" >&2 + exit 1 +fi + +${top_builddir}/dimension/dimension -w1 -h1 -o /dev/null ${srcdir}/transformations.pov -- cgit v1.2.3