/[gr2lib]/trunk/gr2lib_UnitTest/Program.cs
ViewVC logotype

Annotation of /trunk/gr2lib_UnitTest/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90 - (hide annotations) (download)
Sat Jul 17 00:00:16 2010 UTC (9 years, 6 months ago) by william
File size: 12752 byte(s)
Add boolean indicators, that indicate if each type is present

1 william 9 using System;
2     using System.Collections.Generic;
3     using System.Text;
4    
5 william 16 using gr2lib.core;
6 william 70 //using gr2lib.core.coretypes;
7 william 16 using gr2lib.core.apiversion;
8 william 50 using gr2lib.core.exceptions;
9 william 69 using gr2lib.core.helpers;
10 william 70 using gr2lib.core.coretypes.implementation;
11 william 86 using System.Runtime.CompilerServices;
12 william 16
13 william 9 namespace gr2lib_UnitTest
14     {
15 william 77
16 william 9 class Program
17     {
18     static void Main(string[] args)
19 william 77 {
20 william 65 string GrannyFilename = shared.GRANNY_TEST_FILE;
21 william 50 try
22     {
23 william 70 #region Check Granny2 API Version
24 william 50 // Setup access to check loaded Granny2 API Version
25 william 58 granny2apiversion apiversion = new granny2apiversion(shared.EXPECTED_API_VERSION);
26 william 16
27 william 50 // Check if the Loaded API Version Matches
28     if (!apiversion.apiversionsmatch)
29     {
30     // the loaded version does not match
31     Console.WriteLine("Warning:\n" +
32     "\t Loaded Granny2 DLL Version: " + apiversion.apiversion.version + "\n" +
33     "\t Expected Version: " + apiversion.expectedapiversion.version);
34     // return from void to exit application
35     return;
36     }
37     else
38     {
39     // the loaded version matches
40     Console.WriteLine("Loaded granny2.dll: " + apiversion.apiversion.version);
41     }
42 william 70 #endregion
43    
44     #region Parse Commandline
45 william 69 if (args.Length == 1)
46 william 65 {
47 william 69 GrannyFilename = args[0];
48 william 65 }
49 william 69 else if (args.Length > 1)
50     {
51 william 77 throw new InvalidOperationException("ERROR: Recieved Invalid Commandline: " + new arraytostring<string, string[]>(args));
52 william 69 }
53 william 61
54 william 65 if (System.IO.File.Exists(GrannyFilename))
55     {
56     Console.WriteLine("Using Granny2 File: " + GrannyFilename);
57     }
58     else
59     {
60     throw new System.IO.FileNotFoundException("Unable to find: " + GrannyFilename);
61     }
62 william 70 #endregion
63 william 61
64 william 74 #region Read Granny2 Data
65 william 86
66 william 90 grnfileinfo info = grnfileinfo.ReadFromFile(GrannyFilename);
67 william 70
68 william 90 #region Read FromFileName
69     Console.WriteLine();
70     if (info.HaveFromFileName)
71     {
72 william 83 Console.WriteLine("From File Name: " + info.FromFileName);
73     Console.WriteLine("ExtendedData: " + info.ExtendedData);
74 william 90 }
75     else { Console.WriteLine("From File Name: " + "No From File Name Available"); }
76 william 72
77 william 90 #endregion
78    
79     #region Read ArtToolInfo
80     Console.WriteLine();
81     if (info.HaveArtToolInfo)
82     {
83 william 70 Console.WriteLine("Art Tool Data:");
84     Console.WriteLine("\tTool Name: " + info.ArtToolInfo.FromArtToolName);
85     Console.WriteLine("\tTool Version: " + string.Format("{0}.{1}", info.ArtToolInfo.ArtToolMajorRevision, info.ArtToolInfo.ArtToolMinorRevision));
86     Console.WriteLine("\tTool Units Per Meter: " + info.ArtToolInfo.UnitsPerMeter);
87    
88 william 83 Console.WriteLine("\tTool Origin: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Origin.x, info.ArtToolInfo.Origin.y, info.ArtToolInfo.Origin.z));
89     Console.WriteLine("\tTool Right: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Right.x, info.ArtToolInfo.Right.y, info.ArtToolInfo.Right.z));
90     Console.WriteLine("\tTool Up: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Up.x, info.ArtToolInfo.Up.y, info.ArtToolInfo.Up.z));
91     Console.WriteLine("\tTool Back: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Back.x, info.ArtToolInfo.Back.y, info.ArtToolInfo.Back.z));
92 william 70
93     Console.WriteLine("\tTool ExtendedData: " + info.ArtToolInfo.ExtendedData);
94 william 90 }
95     else { Console.WriteLine("Art Tool Data: " + "No Art Tool Info Available"); }
96     #endregion
97 william 71
98 william 90 #region Read ExporterInfo
99     Console.WriteLine();
100     if (info.HaveExporterInfo)
101     {
102 william 71 Console.WriteLine("Exporter Info:");
103     Console.WriteLine("\tExporter Name: " + info.ExporterInfo.ExporterName);
104    
105 william 77 Console.WriteLine("\tExporter Version: " +
106     string.Format("{0}.{1}.{2}.{3}",
107 william 71 info.ExporterInfo.ExporterMajorRevision,
108     info.ExporterInfo.ExporterMinorRevision,
109     info.ExporterInfo.ExporterCustomization,
110     info.ExporterInfo.ExporterBuildNumber));
111    
112     Console.WriteLine("\tExporter ExtendedData: " + info.ExporterInfo.ExtendedData);
113 william 90 }
114     else { Console.WriteLine("Exporter Info: " + "No Exporter Info Available"); }
115     #endregion
116 william 72
117 william 90 #region Read Textures
118     Console.WriteLine();
119     if (info.HaveTextures)
120     {
121 william 72 Console.WriteLine("Texture List:");
122     foreach (Texture t in info.Textures)
123     {
124     Console.WriteLine("\tName: " + t.FromFileName);
125     Console.WriteLine("\tType: " + t.TextureType);
126     Console.WriteLine("\tWidth: " + t.Width);
127     Console.WriteLine("\tHeight: " + t.Height);
128     Console.WriteLine("\tEncoding: " + t.Encoding);
129     Console.WriteLine("\tSubFormat: " + t.SubFormat);
130     // layout
131     Console.WriteLine("\tBytes Per Pixel: " + t.Layout.BytesPerPixel);
132     Console.WriteLine("\tShiftForComponent: " + new arraytostring<int, int[]>(t.Layout.ShiftForComponent));
133     Console.WriteLine("\tBitsForComponent: " + new arraytostring<int, int[]>(t.Layout.BitsForComponent));
134     // images
135 william 77 Console.WriteLine("\tImage List:");
136     foreach (Image img in t.Images)
137     {
138     foreach (MIPLevel mip in img.MIPLevels)
139     {
140     Console.WriteLine("\t\tMipLevel Stride: " + mip.Stride);
141     if (mip.Pixels.Count > 0)
142     {
143     Console.WriteLine("\t\tMipLevel Pixel: " + "{Pixel Data " + "[" + mip.Pixels.Count + "]}");
144     //// export image
145     //mip.Pixels.Export(@"exported_images\" + t.FromFileName.Name, t.Width, t.Height, mip.Stride);
146     }
147     }
148     }
149 william 72 Console.WriteLine("\tExtendedData: " + t.ExtendedData);
150     Console.WriteLine();
151     }
152 william 90 }
153     else { Console.WriteLine("Texture List: " + "No Textures Available"); }
154     #endregion
155 william 72
156 william 90 #region Read Materials
157     Console.WriteLine();
158     if (info.HaveMaterials)
159     {
160 william 81 Console.WriteLine("Material List:");
161     foreach (Material m in info.Materials)
162     {
163     Console.WriteLine("\tMaterial Name: " + m.Name);
164     Console.WriteLine("\t\tMaterial IsTexture: " + m.IsTexture.ToString());
165     if (m.IsTexture)
166     {
167     Texture t = m.Texture;
168     Console.WriteLine("\t\tTexture:");
169     Console.WriteLine("\t\t\tName: " + t.FromFileName);
170     Console.WriteLine("\t\t\tType: " + t.TextureType);
171     Console.WriteLine("\t\t\tWidth: " + t.Width);
172     Console.WriteLine("\t\t\tHeight: " + t.Height);
173     Console.WriteLine("\t\t\tEncoding: " + t.Encoding);
174     Console.WriteLine("\t\t\tSubFormat: " + t.SubFormat);
175     // layout
176     Console.WriteLine("\t\t\tBytes Per Pixel: " + t.Layout.BytesPerPixel);
177     Console.WriteLine("\t\t\tShiftForComponent: " + new arraytostring<int, int[]>(t.Layout.ShiftForComponent));
178     Console.WriteLine("\t\t\tBitsForComponent: " + new arraytostring<int, int[]>(t.Layout.BitsForComponent));
179 william 86
180    
181     Console.WriteLine("\t\t\tImage List:");
182     foreach (Image img in t.Images)
183     {
184     foreach (MIPLevel mip in img.MIPLevels)
185     {
186     Console.WriteLine("\t\t\t\tMipLevel Stride: " + mip.Stride);
187     if (mip.Pixels.Count > 0)
188     {
189     Console.WriteLine("\t\t\t\tMipLevel Pixel: " + "{Pixel Data " + "[" + mip.Pixels.Count + "]}");
190     //// export image
191     //mip.Pixels.Export(@"exported_images\" + t.FromFileName.Name, t.Width, t.Height, mip.Stride);
192     }
193     }
194     }
195    
196 william 81 Console.WriteLine("\t\t\tExtendedData: " + t.ExtendedData);
197     Console.WriteLine();
198     }
199     Console.WriteLine("\t\tExtendedData: " + m.ExtendedData);
200     Console.WriteLine();
201     }
202 william 90 }
203     else { Console.WriteLine("Material List: " + "No Materials Available"); }
204     #endregion
205 william 83
206    
207 william 90 #region Read Skeletons
208     Console.WriteLine();
209     if (info.HaveSkeletons)
210     {
211 william 83 Console.WriteLine("Skeleton List:");
212     foreach (Skeleton s in info.Skeletons)
213     {
214     Console.WriteLine("\tSkeleton Name: " + s.SkeletonName);
215     Console.WriteLine("\tSkeleton LodType: " + s.LodType);
216     Console.WriteLine("\tBones:");
217     foreach (Bone b in s.Bones)
218     {
219     Console.WriteLine("\t\tName: " + b.BoneName);
220     Console.WriteLine("\t\tParent Index: " + b.ParentIndex);
221     Console.WriteLine("\t\tLod Error: " + b.LodError);
222     Console.WriteLine("\t\tTransform: " + b.Transform.ToString());
223     if (b.HasLightInfo) { Console.WriteLine("\t\tLightInfo ExtendedData: " + b.LightInfo.ExtendedData); }
224 william 90 else { Console.WriteLine("\t\tLightInfo ExtendedData: " + "No LightInfo"); }
225 william 83 if (b.HasCameraInfo) { Console.WriteLine("\t\tCameraInfo ExtendedData: " + b.CameraInfo.ExtendedData); }
226 william 90 else { Console.WriteLine("\t\tCameraInfo ExtendedData: " + "No CameraInfo"); }
227 william 83 Console.WriteLine();
228     }
229     Console.WriteLine("\t\tExtendedData: " + s.ExtendedData);
230     Console.WriteLine();
231     }
232 william 90
233 william 70 }
234 william 90 else { Console.WriteLine("Skeleton List: " + "No Skeletons Available"); }
235 william 70 #endregion
236 william 90 }
237     #endregion
238 william 70
239 william 90
240 william 50 catch (granny2apiloadexception ex)
241 william 16 {
242 william 69 Console.WriteLine(ex.Message);
243 william 16 }
244 william 58 catch (Exception ex)
245     {
246 william 86 RuntimeWrappedException rwe = ex as RuntimeWrappedException;
247     if (rwe != null)
248     {
249     Console.WriteLine(rwe.ToString());
250     }
251     else
252     {
253     Console.WriteLine(ex.Message);
254     }
255 william 58 }
256 william 9 }
257     }
258     }
259 william 70

  ViewVC Help
Powered by ViewVC 1.1.22