public static Vector2 ToVector2(this XVec2 v) { return(new Vector2(v.x, v.y)); }
private XMapping ReadTexture(AssetProperty asset) { switch (asset.Type) { case AssetPropertyType.APT_DoubleArray4d: TextureType t = TextureType.None; switch (asset.Name) { case "generic_diffuse": case "ceramic_color": t = TextureType.Diffuse; break; case "generic_bump_map": case "ceramic_bump_map": t = TextureType.Normal; break; } if (t != TextureType.None) { IList <AssetProperty> la = asset.GetAllConnectedProperties(); if (la.Count > 0) { Asset a = la[0] as Asset; XMapping m = new XMapping(); m.Type = t; XVec2 s = new XVec2(); XVec2 o = new XVec2(); for (int i = 0; i < a.Size; i++) { AssetProperty _a = a[i]; switch (_a.Name) { case "unifiedbitmap_Bitmap": AssetPropertyString aps = _a as AssetPropertyString; string p = aps.Value.Split('|')[0]; if (!p.Contains(":")) { if (p.Contains("/") || p.Contains("\\")) { p = Path.Combine(localMap, p); } else { p = Path.Combine(localMap, localMap1, p); } } if (texLink.ContainsKey(p)) { m.ID = texLink[p]; } else { if (File.Exists(p)) { using (FileStream fs = new FileStream(p, FileMode.Open, FileAccess.Read)) { XTexture tex = new XTexture(); tex.Name = fs.Name; tex.Data = new byte[fs.Length]; fs.Read(tex.Data, 0, (int)fs.Length); m.ID = XData.Textures.Count; texLink.Add(p, m.ID); XData.Textures.Add(tex); } } else { return(null); } } break; case "texture_RealWorldScaleX": AssetPropertyDistance asx = _a as AssetPropertyDistance; s.x = 1 / (float)UnitUtils.Convert(asx.Value, asx.DisplayUnitType, DisplayUnitType.DUT_DECIMAL_FEET); break; case "texture_RealWorldScaleY": AssetPropertyDistance asy = _a as AssetPropertyDistance; s.y = 1 / (float)UnitUtils.Convert(asy.Value, asy.DisplayUnitType, DisplayUnitType.DUT_DECIMAL_FEET); break; case "texture_RealWorldOffsetX": AssetPropertyDistance aox = _a as AssetPropertyDistance; o.x = s.x * (float)UnitUtils.Convert(aox.Value, aox.DisplayUnitType, DisplayUnitType.DUT_DECIMAL_FEET); break; case "texture_RealWorldOffsetY": AssetPropertyDistance aoy = _a as AssetPropertyDistance; o.y = s.y * (float)UnitUtils.Convert(aoy.Value, aoy.DisplayUnitType, DisplayUnitType.DUT_DECIMAL_FEET); break; } } m.Scale = s; m.Offset = o; return(m); } } break; } return(null); }