Merged in Governor-Tarkin/swg-src (pull request #17)
[swg-src.git] / tools / collectAssetCustomizationInfo.pl
blob2977a9cdc145ebbbbd7e3b47416c0861f6b5b377
1 # ======================================================================
2 # collectAssetCustomizationInfo.pl
3 # Copyright 2003, Sony Online Entertainment, Inc.
4 # All rights reserved.
5 # ======================================================================
7 use strict;
9 use AppearanceTemplate;
10 use BlueprintTextureRendererTemplate;
11 use ComponentAppearanceTemplate;
12 use CustomizableShaderTemplate;
13 use CustomizationVariableCollector;
14 use DetailAppearanceTemplate;
15 use LightsaberAppearanceTemplate;
16 use LodMeshGeneratorTemplate;
17 use MeshAppearanceTemplate;
18 use PortalAppearanceTemplate;
19 use SkeletalAppearanceTemplate;
20 use SkeletalMeshGeneratorTemplate;
21 use SwitchShaderTemplate;
22 use TreeFile;
23 use VehicleCustomizationVariableGenerator;
25 # ======================================================================
27 my $branch = "current";
28 my $debug = 0;
29 my $treeFileLookupDataFile;
31 # ======================================================================
33 sub printUsage
35 print "Usage:\n";
36 print "\tperl collectAssetCustomizationInfo.pl [-d] [-h] [-b <branch>] -t <treefile lookup filename>\n";
37 print "\n";
38 print "-d: if specified, turns on debugging info (Default: off)\n";
39 print "-h: print this help\n";
40 print "-t: loads the TreeFile lookup data from the specified filename\n";
43 # ----------------------------------------------------------------------
45 sub processCommandLineArgs
47 my $printHelp = 0;
48 my $requestedHelp = 0;
50 # Grab options from commandline.
51 while ((scalar @_) && !$printHelp)
53 if ($_[0] =~ m/^-h/)
55 $printHelp = 1;
56 $requestedHelp = 1;
58 elsif ($_[0] =~ m/^-b/)
60 shift;
61 $branch = $_[0];
62 if (!defined($branch))
64 print "User must specify a branch name after the -t option, printing help.\n";
65 $printHelp = 1;
67 else
69 print "\$branch=[$branch]\n" if $debug;
72 elsif ($_[0] =~ m/^-d/)
74 $debug = 1;
76 elsif ($_[0] =~ m/^-t/)
78 shift;
79 $treeFileLookupDataFile = $_[0];
80 if (!defined($treeFileLookupDataFile))
82 print "User must specify a treefile lookup data filename after the -t option, printing help.\n";
83 $printHelp = 1;
85 else
87 print "\$treeFileLookupDataFile=[$treeFileLookupDataFile]\n" if $debug;
90 else
92 print "Unsupported option [$_[0]], printing help.\n";
93 $printHelp = 1;
96 # Shift past current argument.
97 shift;
100 # Check if we're missing anything required.
101 if (!$requestedHelp)
103 if (!defined($treeFileLookupDataFile))
105 print "No TreeFile lookup data file specified, printing usage info.\n";
106 $printHelp = 1;
110 if ($printHelp)
112 printUsage();
113 exit ($requestedHelp ? 0 : -1);
117 # ----------------------------------------------------------------------
119 sub initialize
121 # Initialize data handlers.
122 &AppearanceTemplate::install();
123 &BlueprintTextureRendererTemplate::install();
124 &ComponentAppearanceTemplate::install();
125 &CustomizableShaderTemplate::install();
126 &DetailAppearanceTemplate::install();
127 &LightsaberAppearanceTemplate::install();
128 &LodMeshGeneratorTemplate::install();
129 &MeshAppearanceTemplate::install();
130 &PortalAppearanceTemplate::install();
131 &SkeletalAppearanceTemplate::install();
132 &SkeletalMeshGeneratorTemplate::install();
133 &SwitchShaderTemplate::install();
134 &VehicleCustomizationVariableGenerator::install();
136 # Open the TreeFile lookup datafile.
137 my $dataFileHandle;
138 die "Failed to open [$treeFileLookupDataFile]: $!" unless open($dataFileHandle, "< " . $treeFileLookupDataFile);
140 # Initialize the treefile.
141 TreeFile::loadFileLookupTable($dataFileHandle);
143 # Close the TreeFile lookup datafile.
144 die "Failed to close [$treeFileLookupDataFile]: $!" unless close($dataFileHandle);
147 # ======================================================================
148 # Main Program
149 # ======================================================================
151 # Handle command line.
152 processCommandLineArgs(@ARGV);
154 # Initialize subsystems (e.g. TreeFile)
155 initialize();
157 # Setup the list of patterns to match against
158 # TreeFile-relative filenames. Any files in the TreeFile system
159 # that match one of these patterns will be processed by the
160 # CustomizationVariableCollector.
162 my @processFilePatterns =
164 '^texturerenderer/.+\.trt$', '^shader/.+\.sht$',
165 '^appearance/.+\.(apt|cmp|lmg|lod|lsb|mgn|msh|sat|pob)$'
166 # ---
167 # TEST ENTRIES: don't include these for real processing, used to test formats one-at-a-time.
168 # ---
169 # '^appearance/.+\.sat$'
170 # '^appearance/.+\.mgn$'
171 # '^shader/.+\.sht$'
172 # '^appearance/.+\.lsb$'
173 # '^appearance/.+\.lod$'
174 # '^appearance/.+\.apt$'
175 # '^appearance/.+\.msh$'
176 # '^appearance/.+\.cmp$'
177 # ---
180 CustomizationVariableCollector::collectData(@processFilePatterns);
182 # Handle vehicle customization steps that cannot be handled by analyzing IFF file contents.
183 VehicleCustomizationVariableGenerator::collectData($branch);