public static string ModelTypeToUserDefinedProperties(DivinityModelType modelType) { switch (modelType) { case DivinityModelType.Normal: return(""); case DivinityModelType.Rigid: return(UserDefinedProperties_Rigid); case DivinityModelType.Cloth: return(UserDefinedProperties_Cloth); default: throw new ArgumentException(); } }
public static DivinityMeshExtendedData MakeMeshExtendedData(Mesh mesh, DivinityModelInfoFormat format, DivinityModelType meshModelType) { var extendedData = DivinityMeshExtendedData.Make(); if (mesh.ModelType != DivinityModelType.Undefined) { meshModelType = mesh.ModelType; } if (meshModelType == DivinityModelType.Cloth && mesh.VertexFormat.ColorMaps == 0) { meshModelType = DivinityModelType.Normal; } if (meshModelType == DivinityModelType.Undefined) { meshModelType = DivinityHelpers.DetermineModelType(mesh); } extendedData.UserDefinedProperties = DivinityHelpers.ModelTypeToUserDefinedProperties(meshModelType); if (format == DivinityModelInfoFormat.UserDefinedProperties) { extendedData.LSMVersion = 0; extendedData.UserMeshProperties = null; } else { DivinityModelFlag flags = 0; if (mesh.VertexFormat.HasBoneWeights) { flags |= DivinityModelFlag.Skinned; } if (mesh.VertexFormat.ColorMaps > 0) { flags |= DivinityModelFlag.HasColor; } switch (meshModelType) { case DivinityModelType.Normal: // No special flag should be set here break; case DivinityModelType.Cloth: flags |= DivinityModelFlag.Cloth; break; case DivinityModelType.Rigid: flags |= DivinityModelFlag.Rigid; break; case DivinityModelType.MeshProxy: flags |= DivinityModelFlag.MeshProxy; break; default: throw new NotImplementedException(); } extendedData.UserMeshProperties.MeshFlags = flags; if (format == DivinityModelInfoFormat.LSMv1) { extendedData.LSMVersion = 1; extendedData.UserMeshProperties.FormatDescs = DivinityFormatDesc.FromVertexFormat(mesh.VertexFormat); } else { extendedData.LSMVersion = 0; extendedData.UserMeshProperties.FormatDescs = new List <DivinityFormatDesc>(); } } return(extendedData); }