#!/usr/bin/perl # This script converts many LDraw formatted files to povray. To do the conversion, # you need L3P and the LDraw folder. # # LDraw http://www.ldraw.org/article/96 # L3P http://www.hassings.dk/l3/download2.html # # Of course, you will need some files to convert also. Personally, I like Mladen # Pejic's models, and they are a good place to start. Here is a nice model: # http://www3.sympatico.ca/mladenpejic/Loiterer.htm ( click on "Download LDraw File") # # Place all model files in a folder named "./modelfiles". # # Lastly, you need to save these files in your Sites folder so that they can be # downloaded by the Xgrid jobs. ###################################################################################### $mydir = `dirname "$0"`; chomp $mydir; # Critical file stuff $ldrawDir = "/Library/ldraw"; # Get this from http://www.ldraw.org/article/96 $l3p = "$mydir/l3p"; # Get this from http://www.hassings.dk/l3/download2.html # Working files stuff $savepath = "/Users/james/Sites/xgridfilelist"; # (make sure this folder exists) # Check before doing anything die "$savepath does not exist.\n" if ( ! -e $savepath); # die "$l3p does not exist.\n" if ( ! -e $l3p); # die "$ldrawDir does not exist.\n" if ( ! -e $ldrawDir); # ###################################################################################### # L3P Conversion Options # for hints on these, download L3P Launcher http://www.cc.utah.edu/~jer29950/lego/l3p/ $l3p_options = " -o"; # -o (overwrite pov file if it exists) $l3p_options = $l3p_options . " -b0.8,0.8,1"; # -b (background color 0 to 1, r,g,b) $l3p_options = $l3p_options . " -q3"; # -q (quality 0-3, 3 best, 2 default) $distance = ""; # set this if you want a constant distance # (otherwise L3P will zoom to fit the entire # model, which can look funny if your step is large # or pretty dramatic if the steps are small # This stuff determines start and stop loops, which is what creates the frames $lat_beg = 0; #180; # set this if you want horizontal slices (for a QTVR) $lat_end = 0; #-180; # set this if you want horizontal slices (for a QTVR) $step = 2; # this is how many degrees to move around ###################################################################################### # Create POV-Ray files create_files("$mydir/modelfiles/Dritver.mpd", "Dritver", 1); # declare 1 to create floor create_files("$mydir/modelfiles/Vampire.mpd", "Vampire"); ############################################################# sub create_files { my ($filename, $savename, $floor) = @_; die "$filename does not exist.\n" if ( ! -e $filename); if (defined $floor) { $my_options = $l3p_options . " -f"; $long_beg = 90; # this sets the start spin point (must be high #) $long_end = -270; # this sets the end spin point (must be low #) } else { $my_options = $l3p_options; $long_beg = 180; # this sets the start spin point (must be high #) $long_end = -180; # this sets the end spin point (must be low #) } $i = 0; for ($lat = $lat_beg ; $lat >= $lat_end ; $lat = $lat - $step) { for ($long = $long_beg ; $long >= $long_end ; $long = $long - $step) { $my_number = sprintf ("%0.5d",$i); system "export LDRAWDIR=$ldrawDir; $l3p $my_options -cg$lat,$long$distance $filename $savepath/$savename$my_number.pov"; $i++; } } }