private void RenderSelf(RenderEventArgs arg, LightBase light) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var method = this.RenderUnit.Methods[(int)MethodName.renderUnderLight]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); //fillNearOffsetState.On(); method.Render(); //fillNearOffsetState.Off(); }
public void ExtrudeShadow(RenderEventArgs arg, LightBase light) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var method = this.RenderUnit.Methods[(int)MethodName.extrudeShadow]; ShaderProgram program = method.Program; program.SetUniform("gProjectionView", projection * view); program.SetUniform("gWorld", model); if (light is DirectionalLight) { var d = light as DirectionalLight; program.SetUniform("gLightPos", d.Direction); program.SetUniform("farAway", true); } else { program.SetUniform("gLightPos", light.Position); program.SetUniform("farAway", false); } fillFarOffsetState.On(); this.lineWidthSwitch.On(); method.Render(); this.lineWidthSwitch.Off(); fillFarOffsetState.Off(); }
void FixedUpdate() { // If there are multiple of these, very bad things may happen Assert.AreEqual(GetAllCount(), 1); Profiler.BeginSample("RotatableLights"); foreach (var light in LightBase.GetAll()) { light.DoFixedUpdate(); } Profiler.EndSample(); Profiler.BeginSample("Shadows"); foreach (var shadow in Shadow.GetAll()) { shadow.DoFixedUpdate(); } Profiler.EndSample(); Profiler.BeginSample("Shadow and Light Edges"); foreach (var lightDivider in ShadowEdgeBase.GetAll()) { lightDivider.DoFixedUpdate(); } Profiler.EndSample(); }
public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); LightBase light = arg.Light; mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); RenderMethod method = this.RenderUnit.Methods[2]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); program.SetUniform("shadowMat", lightBias * lightProjection * lightView); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); program.SetUniform("depthTexture", arg.ShadowMap); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); program.SetUniform("useShadow", this.UseShadow); method.Render(); }
public void RenderBeforeChildren(RenderEventArgs arg, LightBase light) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); RenderMethod method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Diffuse); program.SetUniform("material.specular", this.Specular); program.SetUniform("material.shiness", this.Shiness); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); method.Render(); }
public void Init(LightBase lightSource, Side illuminatedSide) { Debug.Assert(!initialized); initialized = true; this.lightSource = lightSource; this.initialIlluminatedSide = illuminatedSide; this.illuminatedSide = illuminatedSide; }
public LightBase(LightBase copy) { TileX = copy.TileX; TileY = copy.TileY; OffsetX = copy.OffsetX; OffsetY = copy.OffsetY; Intensity = copy.Intensity; Size = copy.Size; Expand = copy.Expand; Color = Color.FromArgb(copy.Color.R, copy.Color.G, copy.Color.B); }
public void RenderBeforeChildren(RenderEventArgs arg, LightBase light) { if (this.renderOutline) { ExtrudeShadow(arg, light); } if (this.renderBody) { RenderSelf(arg, light); } }
protected virtual bool SegmentDividesLightAndDark(LineSegment seg) { var sideToCheck = illuminatedSide == Side.right ? seg.GetLeftSide() : seg.GetRightSide(); foreach (var light in LightBase.GetAll()) { if (light != lightSource && !light.IsInDark(sideToCheck)) { return(false); } } return(true); }
public void CastShadow(ShadowMappingCastShadowEventArgs arg) { LightBase light = arg.Light; mat4 projection = light.GetProjectionMatrix(); mat4 view = light.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; program.SetUniform("mvpMat", projection * view * model); method.Render(); }
public ModDrawTerrain() { currentChunk = new int[18 * 18 * 18]; currentChunkShadows = new byte[18 * 18 * 18]; tempnearestpos = new int[3]; ids = new int[1024]; idsCount = 0; redraw = new TerrainRendererRedraw[128]; redrawCount = 0; CalculateShadowslightRadius = new int[GlobalVar.MAX_BLOCKTYPES]; CalculateShadowsisTransparentForLight = new bool[GlobalVar.MAX_BLOCKTYPES]; lightBase = new LightBase(); lightBetweenChunks = new LightBetweenChunks(); lastPerformanceInfoupdateMilliseconds = 0; lastchunkupdates = 0; started = false; }
public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { if (!this.IsInitialized) { Initialize(); } //this.RotationAngle += this.RotateSpeed; ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 lightBias = glm.translate(mat4.identity(), new vec3(1, 1, 1) * 0.5f); lightBias = glm.scale(lightBias, new vec3(1, 1, 1) * 0.5f); LightBase light = arg.Light; mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); var method = this.RenderUnit.Methods[(int)MethodName.renderUnderLight]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); program.SetUniform("shadow_matrix", lightBias * lightProjection * lightView); // light info. light.SetUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); program.SetUniform("depth_texture", arg.ShadowMap); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); method.Render(); }
public void LoadEditor(LightBase tmpLight) { mEditingLight = tmpLight; mBackupLight = new LightBase(tmpLight); nudIntensity.Value = tmpLight.Intensity; nudSize.Value = tmpLight.Size; nudOffsetX.Value = tmpLight.OffsetX; nudOffsetY.Value = tmpLight.OffsetY; nudExpand.Value = (int)tmpLight.Expand; pnlLightColor.BackColor = System.Drawing.Color.FromArgb( tmpLight.Color.A, tmpLight.Color.R, tmpLight.Color.G, tmpLight.Color.B ); if (!CanClose) { btnOkay.Hide(); } InitLocalization(); }
public void CastShadow(ShadowMappingCastShadowEventArgs arg) { if (!this.IsInitialized) { this.Initialize(); } this.RotationAngle += this.RotateSpeed; LightBase light = arg.Light; mat4 projection = light.GetProjectionMatrix(); mat4 view = light.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var method = this.RenderUnit.Methods[0]; // shadowmapBuilder. ShaderProgram program = method.Program; program.SetUniform(mvpMatrix, projection * view * model); method.Render(); }
public void CastShadow(ShdowMappingEventArgs arg) { if (!this.IsInitialized) { this.Initialize(); } this.RotationAngle += this.RotateSpeed; LightBase light = arg.CurrentLight; mat4 projection = light.GetProjectionMatrix(); mat4 view = light.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var renderUnit = this.RenderUnits[0]; ShaderProgram program = renderUnit.Program; program.SetUniform(mvpMatrix, projection * view * model); renderUnit.Render(); }
void UpdateUpperFrames() { LightBase[] newArray; scrlUpperFrame.Maximum = (int)nudUpperFrameCount.Value; if (mEditorItem.Upper.Lights == null || mEditorItem.Upper.FrameCount != mEditorItem.Upper.Lights.Length) { newArray = new LightBase[mEditorItem.Upper.FrameCount]; for (var i = 0; i < newArray.Length; i++) { if (mEditorItem.Upper.Lights != null && i < mEditorItem.Upper.Lights.Length) { newArray[i] = mEditorItem.Upper.Lights[i]; } else { newArray[i] = new LightBase(-1, -1); } } mEditorItem.Upper.Lights = newArray; } }
public override void RenderBeforeChildren(RenderEventArgs arg) { if (!this.IsInitialized) { Initialize(); } this.RotationAngle += this.RotateSpeed; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); List <LightBase> lights = arg.CurrentLights.Peek(); LightBase light = lights[0];// now we only use one light for testing. mat4 lightBias = glm.translate(mat4.identity(), new vec3(1, 1, 1) * 0.5f); lightBias = glm.scale(lightBias, new vec3(1, 1, 1) * 0.5f); mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); var method = this.RenderUnit.Methods[1]; ShaderProgram program = method.Program; program.SetUniform(mvpMatrix, projection * view * model); program.SetUniform(model_matrix, model); program.SetUniform(view_matrix, view); program.SetUniform(projection_matrix, projection); program.SetUniform(shadow_matrix, lightBias * lightProjection * lightView); program.SetUniform(depth_texture, light.BindingTexture); program.SetUniform(light_position, new vec3(view * new vec4(light.Position, 1.0f))); //program.SetUniform(light_position, light.Position); program.SetUniform(material_ambient, this.Ambient); program.SetUniform(material_diffuse, this.Diffuse); program.SetUniform(material_specular, this.Specular); program.SetUniform(material_specular_power, this.SpecularPower); method.Render(); }
public void Init(LightBase lightSource, ShadowEdgeBase.Side illuminatedSide, Opaque caster) { this.caster = caster; this.lightSource = lightSource; this.illuminatedSide = illuminatedSide; }
protected static void SetAmbientLight(Microsoft.Xna.Framework.Graphics.BasicEffect effect, LightBase light) { effect.AmbientLightColor = light.DiffuseColor; }
public void RenderAfterChildren(RenderEventArgs arg, LightBase light) { }
protected static void SetAmbientLight(GenericEffect effect, LightBase light) { effect.AmbientLightColor = light.DiffuseColor; }
public RenderContext(RenderConfig config) { m_config = config; float aspectRatio = config.width * 1.0f / config.height; viewPlane = new ViewPlane(config.width, config.height, 1f, 2); viewPlane.SAMPLES = config.samples; viewPlane.SetSampler(new JitteredSampler()); ToneMapping.type = ToneMapping.ToneMappingType.Reinhard; camera = new PerspectiveCamera(new Vector3(0, 0, -5f), Vector3.Forward, Vector3.Up, viewPlane, 60f); //tracer = new Tracer(this); tracer = new TracerAreaLigting(this); MatAmbientOccluder matao = new MatAmbientOccluder(); MatPhong matphong = new MatPhong(0.25f, 0.7f, 0.3f, ColourF.White, ColourF.Red, ColourF.White, 100F); MatPhong matphongW = new MatPhong(0.25f, 0.7f, 0.3f, ColourF.White, ColourF.White, ColourF.White, 10F); Plane p1 = new Plane(new Vector3(0, 0, 4), Vector3.Backward); p1.SetMaterial(matphongW); Plane pup = new Plane(new Vector3(0, -1f, 0f), new Vector3(0, 1f, 0f)); pup.SetMaterial(matphongW); Sphere spr1 = new Sphere(new Vector3(0.5f, 0f, 0f), 1.3f); spr1.SetMaterial(matphongW); Sphere spr2 = new Sphere(new Vector3(-0.8f, -0.3f, -0.5f), 0.75f); spr2.SetMaterial(matphong); //Disk disk1 = new Disk(new Vector3(3.0f, 0f, 0f), new Vector3(-0.5f, 0f, -0.1f), 0.7f); //disk1.SetMaterial(matphongW); objects.Add(pup); objects.Add(spr1); objects.Add(spr2); //objects.Add(disk1); AmbientOccluder ao = new AmbientOccluder(Vector3.One * 0.5f, Vector3.One, 0.3f); ao.SetSampler(new JitteredSampler(), config.samples, 5); ambientLight = ao; lights = new List <LightBase>(); PointLight pl = new PointLight(Vector3.Ctor(-1f, 2.5f, 2.3f), ColourF.White, 1f, 5f); pl.CAST_SHADOW = true; PointLight pl2 = new PointLight(Vector3.Ctor(0, 0f, -2.3f), Vector3.Ctor(1.0f, 0.3f, 0.1f), 1.0f, 1f); pl2.CAST_SHADOW = true; AreaLight areaLit = new AreaLight(); areaLit.CAST_SHADOW = true; Disk areaLitGeom = new Disk(new Vector3(3.0f, 0.5f, 0f), new Vector3(-0.5f, 0f, -0.1f), 0.7f, false); areaLitGeom.SetSampler(new JitteredSampler(), config.samples, 10); areaLit.GEOMETRY = areaLitGeom; MaterialEmissive areaLitMat = new MaterialEmissive(Vector3.Ctor(1.0f, 1.0f, 1.0f), 20f); areaLit.MATERIAL = areaLitMat; areaLitGeom.SetMaterial(areaLitMat); objects.Add(areaLitGeom); //DirectionalLight dl = new DirectionalLight(Vector3.Ctor(0f,-1f,0.2f), ColourF.White, 5.0f); //dl.CAST_SHADOW = true; //lights.Add(dl); lights.Add(pl); lights.Add(pl2); lights.Add(areaLit); }
//public static public void LoadConfig(out List <string> errList) { #region >>>>Hardware init errList = new List <string>(); try { var json_string = File.ReadAllText(File_HardwareCfg); HardwareCfgMgr = JsonConvert.DeserializeObject <HardwareCfgManager>(json_string); } catch (Exception ex) { errList.Add($"Unable to load config file { File_HardwareCfg}, { ex.Message}"); } IMotion motionBase = null; IIO ioBase = null; InstrumentBase instrumentBase = null; LightBase lightBase = null; Type hardWareMgrType = HardwareCfgMgr.GetType(); //先初始化通信端口 foreach (var it in hardWareMgrType.GetProperties()) { switch (it.Name) { case "Comports": foreach (var comportCfg in HardwareCfgMgr.Comports) { CommunicationPortBase port = new Comport(comportCfg); CommunicationMgr.Instance.AddCommunicationPort(comportCfg.PortName, port); } break; case "Ethernets": case "Gpibs": case "Visas": break; default: break; } } foreach (var it in hardWareMgrType.GetProperties()) { switch (it.Name) { case "MotionCards": var motionCfgs = it.GetValue(HardwareCfgMgr) as MotionCardCfg[]; if (motionCfgs == null) { break; } foreach (var motionCfg in motionCfgs) { if (motionCfg.Enabled) { motionBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.MotionCards." + motionCfg.Name.Substring(0, motionCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, /*new object[] { motionCfg }*/ null, null, null) as IMotion; if (motionBase != null) { if (motionCfg.ConnectMode.ToLower() != "none") { var p = hardWareMgrType.GetProperty($"{motionCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == motionCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (motionBase.Init(motionCfg, ports.ElementAt(0))) { //设置单位,轴类型, 软限位等 for (int i = 0; i < motionBase.MAX_AXIS - motionBase.MIN_AXIS + 1; i++) { var settings = HardwareCfgMgr.AxisSettings.Where(a => a.AxisNo == i + motionBase.MIN_AXIS); try { motionBase.SetAxisPara(i, settings == null ? null : settings.First()); } catch (Exception ex) { errList.Add($"{ex.Message}"); } } MotionMgr.Instance.AddMotionCard(motionCfg.Name, motionBase); } else { errList.Add($"{motionCfg.Name} init failed"); } } else { errList.Add($"{motionCfg.Name} init failed"); } } else //无需选择通信端口 { if (motionBase.Init(motionCfg, null)) { //设置单位,轴类型, 软限位等 for (int i = 0; i < motionBase.MAX_AXIS - motionBase.MIN_AXIS; i++) { var settings = HardwareCfgMgr.AxisSettings.Where(a => a.AxisNo == i + motionBase.MIN_AXIS); try { motionBase.SetAxisPara(i, settings == null ? null : settings.First()); } catch (Exception ex) { errList.Add($"{ex.Message}"); } } MotionMgr.Instance.AddMotionCard(motionCfg.Name, motionBase); } else { errList.Add($"{motionCfg.Name} init failed"); } } } else { errList.Add($"{motionCfg.Name} Create instanse failed"); } } } break; case "IOCards": var ioCfgs = it.GetValue(HardwareCfgMgr) as IOCardCfg[]; if (ioCfgs == null) { break; } foreach (var ioCfg in ioCfgs) { if (ioCfg.Enabled) { ioBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.IOCards." + ioCfg.Name.Substring(0, ioCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as IIO; if (ioBase != null) { ioBase.ioCfg = ioCfg; if (ioCfg.ConnectMode.ToLower() != "none") //没有屏蔽端口 { var p = hardWareMgrType.GetProperty($"{ioCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == ioCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (ioBase.Init(ioCfg, ports.ElementAt(0))) { IOCardMgr.Instance.AddIOCard(ioCfg.Name, ioBase); } else { errList.Add($"{ioCfg.Name} init failed"); } } else { errList.Add($"{ioCfg.Name} init failed"); } } else //无需选择通信端口 { if (ioBase.Init(ioCfg, null)) { IOCardMgr.Instance.AddIOCard(ioCfg.Name, ioBase); } else { errList.Add($"{ioCfg.Name} init failed"); } } } else { errList.Add($"{ioCfg.Name} Create instanse failed"); } } } break; case "Instruments": var instrumentCfgs = it.GetValue(HardwareCfgMgr) as InstrumentCfg[]; if (instrumentCfgs == null) { break; } foreach (var instrumentCfg in instrumentCfgs) { if (instrumentCfg.Enabled) { instrumentBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.Instruments." + instrumentCfg.InstrumentName.Substring(0, instrumentCfg.InstrumentName.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as InstrumentBase; if (instrumentBase != null) { if (instrumentBase.Init()) { } } } } break; case "Cameras": var cameraCfgs = it.GetValue(HardwareCfgMgr) as CameraCfg[]; break; case "Lights": var lightCfgs = it.GetValue(HardwareCfgMgr) as LightCfg[]; foreach (var lightCfg in lightCfgs) { if (lightCfg.Enabled) { lightBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.Vision.Light." + lightCfg.Name.Substring(0, lightCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as LightBase; if (lightBase != null) { if (lightCfg.ConnectMode.ToLower() != "none") { var p = hardWareMgrType.GetProperty($"{lightCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == lightCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (lightBase.Init(lightCfg, ports.ElementAt(0))) //如果不需要初始化就直接加入字典 { LigtMgr.Instance.AddLight(lightCfg.Name, lightBase); } else { errList.Add($"{lightCfg.Name} init failed"); } } else { errList.Add($"{lightCfg.Name} init failed"); } } else //无需选择通信端口 { if (lightBase.Init(lightCfg, null)) { LigtMgr.Instance.AddLight(lightCfg.Name, lightBase); } else { errList.Add($"{lightCfg.Name} init failed"); } } } else { errList.Add($"{lightCfg.Name} Create instanse failed"); } } } break; default: break; } } #endregion #region >>>>Software init try { var json_string = File.ReadAllText(File_SoftwareCfg); SoftwareCfgMgr = JsonConvert.DeserializeObject <SoftwareCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_SoftwareCfg, ex.Message)); } Type tStationCfg = SoftwareCfgMgr.GetType(); PropertyInfo[] pis = tStationCfg.GetProperties(); WorkFlowConfig[] WorkFlowCfgs = null; WorkFlowBase workFlowBase = null; foreach (PropertyInfo pi in pis) { if (pi.Name == "WorkFlowConfigs") { WorkFlowCfgs = pi.GetValue(SoftwareCfgMgr) as SoftwareManager.WorkFlowConfig[]; foreach (var it in WorkFlowCfgs) { if (it.Enable) { workFlowBase = tStationCfg.Assembly.CreateInstance("JPT_TosaTest.WorkFlow." + it.Name, true, BindingFlags.CreateInstance, null, new object[] { it }, null, null) as WorkFlowBase; if (workFlowBase == null) { errList.Add($"Station: {it.Name} Create instance failed!"); } else { WorkFlowMgr.Instance.AddStation(it.Name, workFlowBase); } } } } } #endregion #region >>>>SystemCfg try { var json_string = File.ReadAllText(File_SystemParaCfg); SystemParaCfgMgr = JsonConvert.DeserializeObject <SystemParaCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_SystemParaCfg, ex.Message)); } #endregion #region >>>> UserCfg init try { var json_string = File.ReadAllText(File_UserCfg); UserCfgMgr = JsonConvert.DeserializeObject <UserCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_UserCfg, ex.Message)); } #endregion #region >>>>ProcessPara //从文件中读取参数 try { var json_string = File.ReadAllText(File_ProcessPara); ProcessDataMgr = JsonConvert.DeserializeObject <ProcessParaMgr>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_UserCfg, ex.Message)); } #endregion }
//public override void Init(LightBase lightSource, Side illuminatedSide) { // Debug.Assert(false); //} public void Init(LightBase lightSource, Side illuminatedSide, Opaque caster) { base.Init(lightSource, illuminatedSide); this.caster = caster; }
protected static void SetDirectionalLight(Microsoft.Xna.Framework.Graphics.DirectionalLight directionalLight, LightBase light, Vector3 objectPosition) { directionalLight.DiffuseColor = light.DiffuseColor; directionalLight.SpecularColor = light.SpecularColor; directionalLight.Direction = light.GetDirectionTo(objectPosition); directionalLight.Enabled = true; }