public override bool canLoadShape(string filename, VirtualFileSystem vfs) { bool canLoad = filename.EndsWith(extension); if (canLoad) { try { using (var stream = vfs.openStream(filename, FileMode.Open, FileAccess.Read)) { using (XmlReader xmlReader = XmlReader.Create(stream, new XmlReaderSettings() { DtdProcessing = DtdProcessing.Prohibit, IgnoreWhitespace = true })) { } } } catch (Exception e) { Log.Error("Failed to load {0} because of exception {1}", filename, e.Message); canLoad = false; } } return(canLoad); }
public override void loadShapes(ShapeBuilder builder, string filename, VirtualFileSystem vfs) { Log.Default.sendMessage("Loading collision shapes from " + filename + ".", LogLevel.Info, "ShapeLoading"); using (var stream = vfs.openStream(filename, FileMode.Open, FileAccess.Read)) { using (XmlReader textReader = XmlReader.Create(stream, new XmlReaderSettings() { DtdProcessing = DtdProcessing.Prohibit, IgnoreWhitespace = true })) { while (textReader.Read()) { if (textReader.NodeType == XmlNodeType.Element) { if (textReader.Name.Equals(COMPOUND)) { loadCompound(textReader, builder); } else if (textReader.Name.Equals(SPHERE)) { loadSphere(textReader, builder); } else if (textReader.Name.Equals(BOX)) { loadBox(textReader, builder); } else if (textReader.Name.Equals(MESH)) { loadMesh(textReader, builder); } else if (textReader.Name.Equals(CONVEXHULL)) { loadConvexHull(textReader, builder); } else if (textReader.Name.Equals(MATERIAL)) { loadMaterial(textReader, builder); } else if (textReader.Name.Equals(PLANE)) { loadPlane(textReader, builder); } else if (textReader.Name.Equals(CAPSULE)) { loadCapsule(textReader, builder); } else if (textReader.Name.Equals(SOFT_BODY)) { loadSoftBody(textReader, builder); } } } } } #if VERBOSE Log.Default.sendMessage("Finished loading collision shapes from " + filename + ".", LogLevel.Info, "ShapeLoading"); #endif }