1 ## Copyright (C) 2002 Etienne Grossmann <etienne@egdn.net>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
16 ## s = vrml_Background (...) - Vrml Background node
18 ## s is a string of the form :
19 ## ------------------------------------------------------------------
23 ## groundColor [0 0 0]
32 ## ------------------------------------------------------------------
35 ## All the fields of the node
37 ## Example : s = vrml_Background ("skyColor",[0 0 1]);
40 function s = vrml_Background (varargin)
42 hash = struct(varargin{:});
44 opts = struct ("skyColor", 3,
57 if isfield (opts, key)
61 body = [ body, sprintf(' %-20s "%s"\n', key, val) ];
63 error ("vrml_Background: field '%s' expects string", key);
67 body = [ body, sprintf(' %-20s [ %8.3f ]\n', key, val) ];
69 error ("vrml_Background: field '%s' expects scalar", key);
72 if (isvector(val) && length(val) == 3)
73 body = [body, sprintf(' %-20s [ %8.3f %8.3f %8.3f ]\n', key, val)];
75 error ("vrml_Background: field '%s' expects [r g b]", key);
79 error ("vrml_Background : unknown field '%s'",key);
82 s = sprintf ("Background { \n%s}\n", body);