public Effect UseSkinnedEffect(Schema2.Material srcMaterial) { if (_Device == null) { throw new InvalidOperationException(); } if (srcMaterial == null) { if (_DefaultSkinned == null) { _DefaultSkinned = new SkinnedEffect(_Device); _Disposables.AddDisposable(_DefaultRigid); } return(_DefaultSkinned); } if (_SkinnedEffects.TryGetValue(srcMaterial, out SkinnedEffect dstMaterial)) { return(dstMaterial); } dstMaterial = new SkinnedEffect(_Device); _SkinnedEffects[srcMaterial] = dstMaterial; _Disposables.AddDisposable(dstMaterial); dstMaterial.Name = srcMaterial.Name; dstMaterial.Alpha = GetAlphaLevel(srcMaterial); dstMaterial.DiffuseColor = GetDiffuseColor(srcMaterial); dstMaterial.SpecularColor = GetSpecularColor(srcMaterial); dstMaterial.SpecularPower = GetSpecularPower(srcMaterial); dstMaterial.EmissiveColor = GeEmissiveColor(srcMaterial); dstMaterial.Texture = GetDiffuseTexture(srcMaterial); dstMaterial.WeightsPerVertex = 4; dstMaterial.PreferPerPixelLighting = true; // apparently, SkinnedEffect does not support disabling textures, so we set a white texture here. if (dstMaterial.Texture == null) { dstMaterial.Texture = _TexFactory.UseWhiteImage(); } return(dstMaterial); }
internal Texture2D UseTexture(MaterialChannel?channel, string name) { if (!channel.HasValue) { return(_TexFactory.UseWhiteImage()); } if (channel.HasValue && name == null) { name = channel.Value.LogicalParent.Name; if (name == null) { name = "null"; } name += $"-{channel.Value.Key}"; } return(_TexFactory.UseTexture(channel.Value.Texture?.PrimaryImage?.Content ?? default, name)); }