]> Creatis software - CreaPhase.git/blob - octave_packages/vrml-1.0.13/vrml_anim.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / vrml-1.0.13 / vrml_anim.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_anim (typ, val, eventin, time)
17 ##
18 ## Assemble 
19 ## - an interpolator of type typ, with values val
20 ## - a TimeSensor with period time
21 ## and route the event to eventin
22 ## 
23 function [s,tname] = vrml_anim (typ, val, eventin, key, period)
24
25 if nargin < 4, key = [0 1]; end
26 if nargin < 5, period = 5; end
27
28 iname = vrml_newname ();
29
30 si = vrml_interp (typ, val,"key",key, "DEF",iname);
31 if isnumeric (period)
32   tname = vrml_newname ();
33   st = vrml_TimeSensor ("cycleInterval",period,"loop",1,"DEF",tname);
34
35 else                            # Use previously declared TimeSensor
36   tname = period;
37   st = "";
38 end
39
40 sr = vrml_ROUTE ([tname,".fraction_changed"],[iname,".set_fraction"]);
41 sr2 = vrml_ROUTE ([iname,".value_changed"],eventin);
42
43 s = [si, st, sr, sr2];
44 endfunction
45