/// <summary> /// Parsing a small part of the Collada file, searching for the /// "asset" element, containing information about the up axis. /// Default up axis is Z. /// </summary> /// <remarks> /// Scale is handled by the Collada importer in Unity. /// </remarks> /// <param name="colladaFilename">Collada filename including path.</param> /// <returns>Collada info parsed.</returns> public static ColladaInfo ParseColladaInfo(string colladaFilename) { var colladaInfo = new ColladaInfo() { UpAxis = ColladaInfo.Axis.Z }; try { var lines = ParseColladaAssetElement(colladaFilename); if (lines != null) { var doc = XDocument.Parse(string.Join("\n", lines)); var assetElement = doc?.Element("asset"); var upAxisStr = assetElement?.Element("up_axis")?.Value; if (!string.IsNullOrEmpty(upAxisStr)) { colladaInfo.UpAxis = upAxisStr == "Z_UP" ? ColladaInfo.Axis.Z : upAxisStr == "Y_UP" ? ColladaInfo.Axis.Y : upAxisStr == "X_UP" ? ColladaInfo.Axis.X : ColladaInfo.Axis.Z; // Defaults to z if something is wrong. } } } catch { } return(colladaInfo); }
private void ConvertColladaToSchematic() { CarbonFile targetFile = this.sourceFile.ChangeExtension(".schematic"); using (new ProfileRegion("Load Model Info")) { this.modelInfo = new ColladaInfo(this.sourceFile); System.Diagnostics.Trace.TraceInformation("Model has {0} meshes", this.modelInfo.MeshInfos.Count); } using (new ProfileRegion("Process collada")) { this.model = ColladaProcessor.Process(this.modelInfo, null, null); } if (this.model.Groups == null) { Diagnostic.Error("Model has no group information"); return; } using (new ProfileRegion("Updating bounding box")) { this.UpdateBoundingBox(); } using (new ProfileRegion("Converting mesh")) { this.ConvertMesh(); } this.WriteSchematic(targetFile); }