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_PointLight (...) - Vrml PointLight node
18 ## s is a string of the form :
19 ## ------------------------------------------------------------------
21 ## exposedField SFFloat ambientIntensity 0 ## [0,1]
22 ## exposedField SFVec3f attenuation 1 0 0 ## [0,inf)
23 ## exposedField SFColor color 1 1 1 ## [0,1]
24 ## exposedField SFFloat intensity 1 ## [0,1]
25 ## exposedField SFVec3f location 0 0 0 ## (-inf,inf)
26 ## exposedField SFBool on TRUE
27 ## exposedField SFFloat radius 100 ## [0,inf)
29 ## ------------------------------------------------------------------
32 ## All the fields of the node
34 ## Example : s = vrml_PointLight ("location",[0 0 1]);
36 ## See also : vrml_DirectionalLight
38 function s = vrml_PointLight (varargin)
40 if mod(nargin,2) != 0, print_usage; end
41 h = struct (varargin{:});
43 tpl = struct ("ambientIntensity", "%8.3f",\
44 "intensity", "%8.3f",\
47 "attenuation", "%8.3f %8.3f %8.3f",\
48 "color", "%8.3f %8.3f %8.3f",\
49 "location", "%8.3f %8.3f %8.3f");
54 if strcmp (key, "DEF")
56 elseif !(isnumeric(val) && isnan (val))
58 # Check validity of field
59 if ! isfield (tpl, key)
60 error (sprintf ("vrml_PointLight : unknown field '%s'",key));
65 sprintf(" %-20s %s\n",key, \
66 sprintf (getfield (tpl,key), val))];
69 s = sprintf ("PointLight {\n%s}\n", body);
70 if isfield (h,"DEF") && !isempty (h.DEF)
71 s = ["DEF ",h.DEF," ",s];