void DumpStandardMaterial(NovaStandardMaterial stdMaterial, BabylonScene babylonScene) { var babylonMaterial = new BabylonMaterial(); babylonScene.MaterialsList.Add(babylonMaterial); babylonMaterial.name = stdMaterial.Name; babylonMaterial.id = stdMaterial.ID.ToString(); babylonMaterial.alpha = stdMaterial.Alpha; babylonMaterial.ambient = (stdMaterial.Ambient * (1.0f - stdMaterial.SelfIllumination)).ToArray(); babylonMaterial.diffuse = (stdMaterial.Diffuse * (1.0f - stdMaterial.SelfIllumination)).ToArray(); babylonMaterial.emissive = (stdMaterial.Emissive * stdMaterial.SelfIllumination).ToArray(); babylonMaterial.specular = stdMaterial.Specular.ToArray(); babylonMaterial.specularPower = stdMaterial.SpecularSharpness; babylonMaterial.backFaceCulling = (stdMaterial.CullMode == NovaCull.CounterClockwise); if (stdMaterial.DiffuseTexture != null && stdMaterial.DiffuseTexture.HasTextureData && stdMaterial.OpacityTexture != null && stdMaterial.OpacityTexture.HasTextureData) { if (stdMaterial.DiffuseTexture.LoadedTexture == stdMaterial.OpacityTexture.LoadedTexture) { stdMaterial.DiffuseTexture = stdMaterial.OpacityTexture; stdMaterial.OpacityTexture = null; } } if (stdMaterial.DiffuseTexture != null && stdMaterial.DiffuseTexture.HasTextureData && !stdMaterial.DiffuseTexture.IsVideo && !stdMaterial.DiffuseTexture.IsCubeRender) { babylonMaterial.diffuseTexture = new BabylonTexture(); DumpTexture(stdMaterial.DiffuseTexture, babylonMaterial.diffuseTexture, babylonScene); } if (stdMaterial.AmbientTexture != null && stdMaterial.AmbientTexture.HasTextureData && !stdMaterial.AmbientTexture.IsVideo && !stdMaterial.AmbientTexture.IsCubeRender) { babylonMaterial.ambientTexture = new BabylonTexture(); DumpTexture(stdMaterial.AmbientTexture, babylonMaterial.ambientTexture, babylonScene); } if (stdMaterial.OpacityTexture != null && stdMaterial.OpacityTexture.HasTextureData && !stdMaterial.OpacityTexture.IsVideo && !stdMaterial.OpacityTexture.IsCubeRender) { babylonMaterial.opacityTexture = new BabylonTexture(); DumpTexture(stdMaterial.OpacityTexture, babylonMaterial.opacityTexture, babylonScene); } if (mirrorsMaterials.ContainsKey(stdMaterial)) { babylonMaterial.reflectionTexture = new BabylonTexture(); var novaObject = mirrorsMaterials[stdMaterial]; DumpRenderTargetTexture(stdMaterial.ReflectionTexture, babylonMaterial.reflectionTexture, novaObject.MirrorMapSize, novaObject.MirrorLevel, novaObject.MirroredObjects); AttachMirrorPlane(babylonMaterial.reflectionTexture, novaObject); } else if (stdMaterial.ReflectionTexture != null && stdMaterial.ReflectionTexture.HasTextureData && !stdMaterial.ReflectionTexture.IsVideo && !stdMaterial.ReflectionTexture.IsCubeRender) { babylonMaterial.reflectionTexture = new BabylonTexture(); DumpTexture(stdMaterial.ReflectionTexture, babylonMaterial.reflectionTexture, babylonScene); } if (stdMaterial.EmissiveTexture != null && stdMaterial.EmissiveTexture.HasTextureData && !stdMaterial.EmissiveTexture.IsVideo && !stdMaterial.EmissiveTexture.IsCubeRender) { babylonMaterial.emissiveTexture = new BabylonTexture(); DumpTexture(stdMaterial.EmissiveTexture, babylonMaterial.emissiveTexture, babylonScene); } if (stdMaterial.SpecularTexture != null && stdMaterial.SpecularTexture.HasTextureData && !stdMaterial.SpecularTexture.IsVideo && !stdMaterial.SpecularTexture.IsCubeRender) { babylonMaterial.specularTexture = new BabylonTexture(); DumpTexture(stdMaterial.SpecularTexture, babylonMaterial.specularTexture, babylonScene); } if (stdMaterial.BumpTexture != null && stdMaterial.BumpTexture.HasTextureData && !stdMaterial.BumpTexture.IsVideo && !stdMaterial.BumpTexture.IsCubeRender) { babylonMaterial.bumpTexture = new BabylonTexture(); DumpTexture(stdMaterial.BumpTexture, babylonMaterial.bumpTexture, babylonScene); babylonMaterial.bumpTexture.level /= 2.0f; } }