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 ## Test that vrml_faces works with "tex" option
20 ## Tetrahedron : Vertices
25 ## Tetrahedron : Faces
30 trgl = {[1 2 4],[2 3 4],[3 1 4],[1 2 3]};
32 slight = vrml_PointLight ("location", [0,5,0]);
35 s1 = vrml_faces (x, trg);
37 printf ("Going to show a tetrahedron\n");
39 printf (["\n If nothing appears, it may be due to problems",\
40 "\n with your FreeWRL installation\n"]);
41 vrml_browse ([slight, s1]);
42 printf ("Press a key in this terminal when done\n");pause;
46 s1 = vrml_faces (x, trgl,"col",[1,0.5,0.5]);
48 printf ("Going to show almost the same tetrahedron\n");
50 printf (["\n If nothing appears, it may be due to problems",\
51 "\n with your FreeWRL installation\n"]);
52 vrml_browse ([slight, s1]);
53 printf ("Press a key in this terminal when done\n");pause;
57 s1 = vrml_faces (x, trg, "col",[1 0 0 1;0 1 0 1;0 0 1 1]);
59 printf ("Coloring the vertices\n");
60 vrml_browse ([slight, s1]);
61 printf ("Press a key in this terminal when done\n");pause;
64 s1 = vrml_faces (x, trg, "col",[1 0 0 1;0 1 0 1;0 0 1 1],"colorPerVertex",0);
66 printf ("Coloring the faces\n");
67 vrml_browse ([slight, s1]);
68 printf ("Press a key in this terminal when done\n");pause;
73 W = 100; # Texture width
76 tr = tg = tb = zeros (H,W+1);
77 [j,i] = meshgrid (1:W+1,1:H);
79 tr(find (i<=h & i*W>=j*H )) = 1;
80 tg(find (i> h & i*W>=(j+w)*H )) = 1;
81 tb(find (i> h & i*W>=j*H & j> w)) = 1;
87 whiten = find(!(tr | tg | tb));
93 t0 = reshape (255*[tr;tg;tb], H,(W+1)*3);
94 t0 = t0 + 0.75 * rot90 (t0,2);
101 texfile = [pwd(),"/mytexfile.ppm"];
102 ims_save (tex, texfile);
104 s1 = vrml_faces (x, trg, "tex",texfile,"imsz",[H,W]);
105 s2 = vrml_faces (x, trg, "tex",texfile);
107 printf (["Tetrahedrons should appear like (R=red, G=green, B=blue)\n\n",\
118 vrml_browse ([slight, s1, vrml_transfo(s2,[2,0,0])]);