public bool LoadFromFile(string mwmFilepath) { MwmFilepath = MyMwmUtils.GetFullMwmFilepath(mwmFilepath); MwmContentPath = MyMwmUtils.GetFullMwmContentPath(mwmFilepath); if (!MyFileSystem.FileExists(MwmFilepath)) { MyRender11.Log.WriteLine(String.Format("Mesh asset {0} missing", MwmFilepath)); return(false); } MyModelImporter modelImporter = GetModelImporter(MwmFilepath); Dictionary <string, object> tagData = modelImporter.GetTagData(); // Lods if (tagData.ContainsKey(MyImporterConstants.TAG_LODS)) { Lods = (MyLODDescriptor[])tagData[MyImporterConstants.TAG_LODS]; } // Parts MyRenderProxy.Assert(tagData.ContainsKey(MyImporterConstants.TAG_MESH_PARTS)); PartInfos = tagData[MyImporterConstants.TAG_MESH_PARTS] as List <MyMeshPartInfo>; // Sort parts PartInfos.Sort(m_partsComparer); // Sections if (tagData.ContainsKey(MyImporterConstants.TAG_MESH_SECTIONS)) { SectionInfos = tagData[MyImporterConstants.TAG_MESH_SECTIONS] as List <MyMeshSectionInfo>; } // Common buffers Positions = (HalfVector4[])tagData[MyImporterConstants.TAG_VERTICES]; Normals = (Byte4[])tagData[MyImporterConstants.TAG_NORMALS]; Tangents = (Byte4[])tagData[MyImporterConstants.TAG_TANGENTS]; Bitangents = (Byte4[])tagData[MyImporterConstants.TAG_BINORMALS]; Texcoords = (HalfVector2[])tagData[MyImporterConstants.TAG_TEXCOORDS0]; // Animation Bones = (MyModelBone[])tagData[MyImporterConstants.TAG_BONES]; BoneIndices = (Vector4I[])tagData[MyImporterConstants.TAG_BLENDINDICES]; BoneWeights = (Vector4[])tagData[MyImporterConstants.TAG_BLENDWEIGHTS]; object objectPatternScale; float patternScale = 1f; if (tagData.TryGetValue(MyImporterConstants.TAG_PATTERN_SCALE, out objectPatternScale)) { patternScale = (float)objectPatternScale; } // Data validation BoundindBox = (BoundingBox)tagData[MyImporterConstants.TAG_BOUNDING_BOX]; BoundingSphere = (BoundingSphere)tagData[MyImporterConstants.TAG_BOUNDING_SPHERE]; if (patternScale != 1f && Texcoords.Length > 0) { for (int i = 0; i < Texcoords.Length; ++i) { Texcoords[i] = new HalfVector2(Texcoords[i].ToVector2() / patternScale); } } if (Normals.Length > 0 && Tangents.Length > 0 && Bitangents.Length > 0) { Tangents = CreateAlteredTangents(Normals, Tangents, Bitangents); } modelImporter.Clear(); return(true); }