source: OniSplit/Level/TextureImporter.cs@ 1162

Last change on this file since 1162 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 2.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Xml;
5
6namespace Oni.Level
7{
8 using Oni.Akira;
9 using Oni.Metadata;
10 using Oni.Motoko;
11 using Oni.Xml;
12
13 partial class LevelImporter
14 {
15 private Motoko.TextureImporter3 textureImporter;
16 private TextureFormat defaultTextureFormat = TextureFormat.BGR;
17 private TextureFormat defaultAlphaTextureFormat = TextureFormat.RGBA;
18 private int maxTextureSize = 512;
19
20 private void ReadTextures(XmlReader xml, string basePath)
21 {
22 if (xml.SkipEmpty())
23 return;
24
25 string format = xml.GetAttribute("Format");
26 string alphaFormat = xml.GetAttribute("AlphaFormat");
27 string size = xml.GetAttribute("MaxSize");
28
29 if (format != null)
30 defaultTextureFormat = TextureImporter.ParseTextureFormat(format);
31
32 if (alphaFormat != null)
33 defaultAlphaTextureFormat = TextureImporter.ParseTextureFormat(alphaFormat);
34
35 if (size != null)
36 maxTextureSize = int.Parse(size);
37
38 xml.ReadStartElement("Textures");
39
40 while (xml.IsStartElement())
41 {
42 if (xml.LocalName == "Import")
43 {
44 var importPath = Path.Combine(basePath, xml.ReadElementContentAsString());
45
46 var settings = new XmlReaderSettings {
47 IgnoreWhitespace = true,
48 IgnoreProcessingInstructions = true,
49 IgnoreComments = true
50 };
51
52 using (var importXml = XmlReader.Create(importPath, settings))
53 {
54 importXml.ReadStartElement("Oni");
55 ReadTextures(importXml, Path.GetDirectoryName(importPath));
56 importXml.ReadEndElement();
57 }
58 }
59 else
60 {
61 textureImporter.ReadOptions(xml, basePath);
62 }
63 }
64
65 xml.ReadEndElement();
66 }
67 }
68}
Note: See TracBrowser for help on using the repository browser.