]> Creatis software - CreaPhase.git/blob - octave_packages/vrml-1.0.13/vrml_DirectionalLight.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / vrml-1.0.13 / vrml_DirectionalLight.m
1 ## Copyright (C) 2005-2012 Etienne Grossmann <etienne@egdn.net>
2 ##
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
6 ## version.
7 ##
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
11 ## details.
12 ##
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/>.
15
16 ##  s = vrml_DirectionalLight (...)   - Vrml DirectionalLight node
17 ##
18 ##  s is a string of the form :
19 ##  ------------------------------------------------------------------
20 ##  DirectionalLight { 
21 ##    exposedField SFFloat ambientIntensity  0        # [0,1]
22 ##    exposedField SFColor color             1 1 1    # [0,1]
23 ##    exposedField SFVec3f direction         0 0 -1   # (-,)
24 ##    exposedField SFFloat intensity         1        # [0,1]
25 ##    exposedField SFBool  on                TRUE 
26 ##  }
27 ##  ------------------------------------------------------------------
28 ##
29 ## Options :
30 ## All the fields of the node
31 ##
32 ## See also : vrml_PointLight
33
34 function s = vrml_DirectionalLight (varargin) # pos 2.1.39
35
36
37 hash = struct ();
38 for k=1:2:nargin,
39    hash = setfield(hash,varargin{k:k+1}); 
40 end
41
42 tpl = struct ("ambientIntensity", "%8.3f",\
43               "intensity",        "%8.3f",\
44               "direction",        "%8.3f",\
45               "on",               "%s",\
46               "color",            "%8.3f %8.3f %8.3f");
47
48 body = "";
49 for [val,key] = hash,
50
51   if !(isnumeric(val) && isnan (val)),
52
53                                 # Check validity of field
54     if !isfield (tpl, key)
55       error (sprintf ("vrml_PointLight : unknown field '%s'",key));
56     end
57
58     body = [body,\
59             sprintf("   %-20s   %s\n",key,
60                      sprintf(getfield (tpl,key), val))];
61   end
62 end
63 s = sprintf ("DirectionalLight { \n%s}\n", body);
64 endfunction
65