Re: TOOLS: Virtus Walkthrough Pro 2.0 and VRML 1.0

James Waldrop ([email protected])
Fri, 19 May 1995 11:55:55 PDT


Kevin Hughes wrote:
> In doing Web work, some clients scream if the size of a page and its
>graphics gets any bigger than 50K. You can spend some time in trying to
>squeeze out a few bytes from graphics, but on the other end of a slow pipe,
>it's worth it. Let's try to keep worlds small (say, <= 100-200k, gzipped)
>until the rest of the world catches up.

I wholeheartedly agree with what Kevin has said here. What we at the
Interactive Media Festival have found in doing this is that the tools
just really aren't there yet. The vapor is still coalescing.

Just take a sphere as an example. I can one-line a sphere in VRML,
right? If I do it in 3DS, take it to DXF, and then bring it to WRL
via dxf2iv and IvToVrml, I find that I suddenly have a 40K file. Why?
Because DXF has no concept of curved surfaces. So you have a huge
file with lots of points taken out to 5 and 6 digits of precision.
And it's slow. Amazingly so.

Here's a rough and ready Perl script that I worked up to patch this
up somewhat. It takes all number down to 2 digits of precision, and
gets rid of numbers like 1.05678e-10 (makes them 0), which seem to
occur a LOT. It also gets rid of extraneous white-space by left-
margining everything. This is something you want to use once the
file is working locally, because you lose indenting info.

In the IMF's real-world examples, it took a 1.4M file down to 700K
with no visible differences. The resultant file also rendered more
quickly, feeling "lighter." A lamp, with lots of curved surfaces,
was used to get a feel for how many digits of precision is necessary.
Two was decided on.

This script is NOT CLEAN. I'm just throwing it out for all of you
folks who are in the thick of things NOW, before the tools are really
there. It's quick and dirty, but enough said:

#!/usr/local/bin/perl
#
# Written Fri May 19 11:48:25 PDT 1995 by James Waldrop ([email protected])
#
# invoke like so: scriptname foo1.wrl foo2.wrl
# produces output like foo1.wrl.new

for ($x=-1; $x++ < $#ARGV; ) {
$file = $ARGV[$x];
if (! (-e $file) ) {
print "$file not found, skipping...\n";
next;
}
&convert($file);
}

exit;

sub convert {
local ($file) = @_;
open (OLD, $file) || die "Couldn't open $file: $!\n";
open (NEW, ">$file.new") || die "Couldn't open $file.new: $!\n";

while (<OLD>) {
$line = $_;
$line =~ s/[-+]?[0-9]\.[0-9]+e[+-][0-9]+/0/g; # makes an assumption
$line =~ s/([0-9]+\.[0-9]{2})[0-9]+/$1/g; # replace 2 with
$line =~ s/0\.00/0/g; # get rid of 0.00 # digits of precision
$line =~ s/[ ]+/ /g;
$line =~ s/[\t]+/ /g;
$line =~ s/^ //g;
print NEW $line;
}
close OLD;
close NEW;
}