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_material (dc,ec,tr) - Returns a "material" vrml node
18 ## dc : 3x1 : diffuseColor
19 ## ec : 3x1 : emissiveColor
20 ## or 1x1 : use dc as emissiveColor if ec is true. Default = 0
21 ## tr : 1x1 : transparency Default = 0
23 function s = vrml_material (dc, ec, tran,DEF)
25 if nargin < 1, dc = [0.3 0.4 0.9] ; # Default color
26 elseif prod (size (dc)) != 3,
27 error ("dc should have length 3 (it is %i x %i)",size (dc));
32 if nargin < 2, ec = 0; end
33 if nargin < 3, tran = 0; end
34 if nargin < 4, DEF = ""; end
36 if prod (size (ec)) == 1 && !isnan (ec) , emit = ec ; ec = dc ; end
41 if emit && !isnan (ec)
42 se = sprintf (" emissiveColor %8.3g %8.3g %8.3g\n",ec);
46 if ! isnan (tran) && tran
47 st = sprintf (" transparency %8.3g\n",tran);
52 if isempty (DEF), sd = "";
53 else sd = ["DEF ",DEF];
56 s = sprintf ([" material ",sd," Material {\n",\
58 " diffuseColor %8.3g %8.3g %8.3g \n",\