protected override void InitializeInner() { base.InitializeInner(); DeviceContextHolder.Set <IMaterialsFactory>(new MaterialsProviderDeferred()); Scene.Add(SkyObject.Create(500f)); foreach (var showroom in _kn5.Skip(1)) { Scene.Add(new Kn5RenderableFile(showroom, Matrix.Identity)); } if (_kn5.Length > 1) { _car = new DeferredRenderableCar(CarDescription.FromKn5(_kn5[0]), Matrix.Identity, shadowsHeight: 0.001f, lights: Lights) { IsReflectable = false }; Scene.Add(_car); } Scene.UpdateBoundingBox(); Camera = new CameraOrbit(32) { Alpha = 0.9f, Beta = 0.1f, Radius = _car?.BoundingBox?.GetSize().Length() * 1.2f ?? 4.8f, Target = (_car?.BoundingBox?.GetCenter() ?? Vector3.Zero) - new Vector3(0f, 0.05f, 0f) }; _resetCamera = (CameraOrbit)Camera.Clone(); Sun = new DirectionalLight { Color = FixLight(new Vector3(1.2f, 1.0f, 0.9f)) * 5f, Direction = Vector3.Normalize(new Vector3(-1.2f, -3.4f, -2.2f)) }; _effect = DeviceContextHolder.GetEffect <EffectDeferredGObject>(); }
public void Initialize(IDeviceContextHolder contextHolder) { _effect = contextHolder.GetEffect <EffectDeferredGObject>(); _txDiffuse = GetTexture("txDiffuse", contextHolder); _txNormal = Kn5Material.ShaderName.Contains("damage") ? null : GetTexture("txNormal", contextHolder); _txMaps = GetTexture("txMaps", contextHolder); _txDetails = GetTexture("txDetail", contextHolder); _txDetailsNormal = GetTexture("txNormalDetail", contextHolder); uint flags = 0; if (_txNormal != null) { flags |= EffectDeferredGObject.HasNormalMap; } if (_txMaps != null) { flags |= EffectDeferredGObject.HasMaps; } if (Kn5Material.GetPropertyValueAByName("useDetail") > 0) { flags |= EffectDeferredGObject.HasDetailsMap; } if (_txDetailsNormal != null) { flags |= EffectDeferredGObject.HasDetailsNormalMap; } if (Kn5Material.ShaderName == "ksTyres" || Kn5Material.ShaderName == "ksBrakeDisc") { flags |= EffectDeferredGObject.UseDiffuseAlphaAsMap; } if (IsBlending) { flags |= EffectDeferredGObject.AlphaBlend; } if (Equals(Kn5Material.GetPropertyValueAByName("isAdditive"), 1.0f)) { flags |= EffectDeferredGObject.IsAdditive; } var specularExp = Kn5Material.GetPropertyValueAByName("ksSpecularEXP"); if (Equals(Kn5Material.GetPropertyValueAByName("isAdditive"), 2.0f)) { specularExp = 250f; } _material = new EffectDeferredGObject.Material { Ambient = Kn5Material.GetPropertyValueAByName("ksAmbient"), Diffuse = Kn5Material.GetPropertyValueAByName("ksDiffuse"), Specular = Kn5Material.GetPropertyValueAByName("ksSpecular"), SpecularExp = specularExp, Emissive = Kn5Material.GetPropertyValueCByName("ksEmissive"), FresnelC = Kn5Material.GetPropertyValueAByName("fresnelC"), FresnelExp = Kn5Material.GetPropertyValueAByName("fresnelEXP"), FresnelMaxLevel = Kn5Material.GetPropertyValueAByName("fresnelMaxLevel"), DetailsUvMultipler = Kn5Material.GetPropertyValueAByName("detailUVMultiplier"), DetailsNormalBlend = Kn5Material.GetPropertyValueAByName("detailNormalBlend"), Flags = flags }; }
public void Initialize(IDeviceContextHolder contextHolder) { _effect = contextHolder.GetEffect <EffectDeferredGObject>(); _txDiffuse = contextHolder.Get <ITexturesProvider>().GetTexture(contextHolder, _filename); }