[GRASS5] [bug #2152] (grass) VRML 1.0 export

Paul Kelly paul-grass at stjohnspoint.co.uk
Sun Oct 12 09:21:27 EDT 2003



On Fri, 10 Oct 2003, Request Tracker wrote:

> The VRML 1.0 export is not working well. The mesh producted is not standard VRML. It
> adds a ' , ' after the last Coordinate3 point description. Same for the last
> IndexedFaceSet : should be "a,b,c,-1"  and not "a,b,c,-1,"

The attached patch to p.vrml would fix this (presumably the Material Color
section should have the same treatment). But I haven't had any problems
with the current output. Are there some readers the VRML output won't work
with? Can you give a link to somewhere describing the VRML standard that
shows it as you describe? Then we could apply the change to p.vrml
-------------- next part --------------
Index: put_grid.c
===================================================================
RCS file: /grassrepository/grass/src/paint/p.vrml1.1/put_grid.c,v
retrieving revision 1.3
diff -u -r1.3 put_grid.c
--- put_grid.c	23 Apr 2002 20:25:03 -0000	1.3
+++ put_grid.c	12 Oct 2003 13:17:46 -0000
@@ -60,7 +60,10 @@
 		if (G_is_f_null_value (tf)) *tf = 0.0;
 		coordy = *tf;
 		do_coordcnv(&coordy, 'y');
-		sprintf(str,"%f %f %f,", coordx, coordy, coordz);
+		sprintf(str,"%f %f %f", coordx, coordy, coordz);
+		if ((row < (rows-1)) || (col < (cols-1)))
+		    /* No comma after last point */
+		    strcat(str,",");
 		vrml_putline(0,vout,str);
 		tf++;
 	    }
@@ -101,8 +104,11 @@
 	    G_lookup_f_raster_colors (tf, red, green, blue, set, cols, colr);
 
 	    for(col=0; col < cols; col++){
-		sprintf(str,"%.3f %.3f %.3f,", 
+		sprintf(str,"%.3f %.3f %.3f", 
 			red[col]/255., green[col]/255., blue[col]/255.);
+		if ((row < (rows-1)) || (col < (cols-1)))
+		    /* No comma after last point */
+		    strcat(str,",");
 		vrml_putline(0,vout,str);
 	    }
 	}
@@ -135,9 +141,12 @@
 	    for(col=0; col < cols-1; col++){
 		c1 = row*cols+col;
 		c2 = c1 + cols +1;
-	        sprintf(str,"%d, %d, %d, -1, %d, %d, %d, -1,",
+	        sprintf(str,"%d, %d, %d, -1, %d, %d, %d, -1",
 		c1, c1+cols, c1+1, 
 		c2, c2-cols, c2-1 );
+		if ((row < (rows-2)) || (col < (cols-2)))
+		    /* No comma after last point */
+		    strcat(str,",");
 		vrml_putline(0,vout,str);
 	    }
 	}


More information about the grass-dev mailing list