//Match what Wes's compiler does public static void FixUVScales(this GenericRCOLResource rcolResource, MLOD.Mesh mesh) { MATD matd = GetMATDforMesh(rcolResource, mesh.MaterialIndex); if (matd == null) { throw new ArgumentException("No MATD found for requested mesh"); } foreach (FieldType ft in new FieldType[] { FieldType.UVScales, FieldType.DiffuseUVSelector, FieldType.SpecularUVSelector, }) { ShaderData data = (matd.Version < 0x0103 ? matd.Mtrl.SData : matd.Mtnf.SData).Find(x => x.Field == ft); if (data == null) { continue; } if (!(data is ElementFloat3)) { throw new InvalidOperationException(String.Format("Found " + ft + " of type '{0}'; expected 'ElementFloat3'.", data.GetType().Name)); } ElementFloat3 e = data as ElementFloat3; e.Data0 = 1f / short.MaxValue; e.Data1 = 0f; e.Data2 = 0f; } }
public static float[] GetUVScales(this GenericRCOLResource rcolResource, MLOD.Mesh mesh) { MATD matd = GetMATDforMesh(rcolResource, mesh.MaterialIndex); if (matd != null) { ShaderData data = (matd.Version < 0x0103 ? matd.Mtrl.SData : matd.Mtnf.SData).Find(x => x.Field == FieldType.UVScales); if (data != null) { if (data is ElementFloat3) { ElementFloat3 e = data as ElementFloat3; return(new float[] { e.Data0, e.Data1, e.Data2, }); } else { throw new InvalidOperationException(String.Format("Found UVScales of type '{0}'; expected 'ElementFloat3'.", data.GetType().Name)); } } } return(new float[] { 1f / 32767f, 0f, 0f, }); }