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_lines(x,f,...)
18 ## x : 3xP : The 3D points
19 ## f : 3xQ : The indexes of the points forming the lines. Indexes
22 ## Returns a Shape -> IndexedLineSet vrml node.
24 ## No check is done on anything
28 ## "col" , col : 3x1 : Color, default = [1,0,0]
30 function s = vrml_lines(x,f,varargin)
32 if nargin < 2, f = ones (1,columns(x)); end
42 while (nargin -2) >=i ,
44 tmp = varargin{i++} ; # pos 2.1.39
46 error ("vrml_lines : Non-string option : \n") ;
50 if index(opt1,[" ",tmp," "]) ,
53 tmp2 = varargin{i++}; # pos 2.1.39
55 eval([tmp,"=tmp2;"]) ;
57 if verbose , printf ("vrml_lines : Read option : %s.\n",tmp); end
59 elseif index(opt0,[" ",tmp," "]) ,
62 if verbose , printf ("vrml_lines : Read boolean option : %s\n",tmp); end
65 error ("vrml_lines : Unknown option : %s\n",tmp) ;
70 if exist("col")!=1, col = [0.5, 0.5, 0.8]; end
72 s = sprintf([... # string of indexed face set
74 " appearance Appearance {\n",...
75 " material Material {\n",...
76 " diffuseColor %8.3f %8.3f %8.3f \n",...
77 " emissiveColor %8.3f %8.3f %8.3f\n",...
80 " geometry IndexedLineSet {\n",...
81 " coordIndex [\n%s]\n",...
82 " coord Coordinate {\n",...
89 sprintf(" %4d, %4d, %4d, -1,\n",f-1),...
90 sprintf(" %8.3f %8.3f %8.3f,\n",x)) ;