public Light( LightBlock lightBlock, Func<Light, IRoadInformation> conductorFactory ) { this._lightBlock = lightBlock; this._stateMachine = new LightStateMachine( this, lightBlock.Times ); this._drawer = new LightDrawer( this ); conductorFactory( this ); }
public LightEditorViewModel( LightBlock control ) { this._light = control; this._basicInformation = new BasiInformationAboutControlViewModel( control ); this.SetupDealy = this._light.Times.SetupDealy.Seconds; this.RedLightTime = this._light.Times.RedLightTime.Seconds; this.YellowLightTime = this._light.Times.YellowLightTime.Seconds; this.GreenLightTime = this._light.Times.GreenLightTime.Seconds; }
private IEnumerable<IAction> Convert( LightBlock control ) { yield return Actions.CreateControl( control.Id, () => new LightBlock( Is.Const( control.Location ), Is.IsTexture( control.TextureName) ) ); Debug.Assert( control.Connector.Owner != null ); yield return Actions.Call<LightBlock>( control.Id, () => control.Connector.ConnectWith( Is.Control( control.Connector.Owner ) ) ); yield return Actions.Property( control, c => c.Times.GreenLightTime ); yield return Actions.Property( control, c => c.Times.RedLightTime ); yield return Actions.Property( control, c => c.Times.YellowLightTime ); yield return Actions.Property( control, c => c.Times.SetupDealy ); }
private static void RegisterBuiltinBlocks() { if (_builtin) { return; } _builtin = true; var lightBlockVariantMapper = new BlockStateVariantMapper(); for (byte i = 0; i < 15; i++) { BlockState bs = new BlockState() { Default = i == 0, Name = "minecraft:light_block", VariantMapper = lightBlockVariantMapper, Values = new Dictionary <string, string>() { { "block_light_level", i.ToString() } } }; var block = new LightBlock() { LightValue = i }; bs.Block = block; block.BlockState = bs; lightBlockVariantMapper.TryAdd(bs); } BlockStateByName.TryAdd("minecraft:light_block", lightBlockVariantMapper); //RegisteredBlockStates.Add(Block.GetBlockStateID(), StationairyWaterModel); }
void BuildLights(Matrix4 camMatrix) { LightBlock lightData = new LightBlock(NUMBER_OF_LIGHTS); lightData.ambientIntensity = new Vector4(0.2f, 0.2f, 0.2f, 1.0f); lightData.lightAttenuation = 1.0f / (5.0f * 5.0f); lightData.maxIntensity = 3.0f; lightData.lights[0].lightIntensity = new Vector4(2.0f, 2.0f, 2.5f, 1.0f); lightData.lights[0].cameraSpaceLightPos = Vector4.Transform(new Vector4(-0.2f, 0.5f, 0.5f, 0.0f), camMatrix); lightData.lights[1].lightIntensity = new Vector4(3.5f, 6.5f, 3.0f, 1.0f) * 1.2f; lightData.lights[1].cameraSpaceLightPos = Vector4.Transform(new Vector4(5.0f, 6.0f, 0.5f, 1.0f), camMatrix); g_lightNumBinder.SetValue(2); lightData.SetUniforms(g_unlitProg); lightData.UpdateInternal(); lightData.SetUniforms(g_litProg); lightData.UpdateInternal(); }
public override void display() { g_lightTimer.Update(); GL.ClearColor(0.75f, 0.75f, 1.0f, 1.0f); GL.ClearDepth(1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); if((g_pObjectMesh != null) && (g_pCubeMesh != null)) { MatrixStack modelMatrix = new MatrixStack(); modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); Matrix4 worldToCamMat = modelMatrix.Top(); LightBlock lightData = new LightBlock(NUMBER_OF_LIGHTS); lightData.ambientIntensity = new Vector4(0.2f, 0.2f, 0.2f, 1.0f); lightData.lightAttenuation = g_fLightAttenuation; Vector3 globalLightDirection = new Vector3(0.707f, 0.707f, 0.0f); lightData.lights[0].cameraSpaceLightPos = Vector4.Transform(new Vector4(globalLightDirection, 0.0f), worldToCamMat); lightData.lights[0].lightIntensity = new Vector4(0.6f, 0.6f, 0.6f, 1.0f); lightData.lights[1].cameraSpaceLightPos = Vector4.Transform(CalcLightPosition(), worldToCamMat); lightData.lights[1].lightIntensity = new Vector4(0.4f, 0.4f, 0.4f, 1.0f); g_litShaderProg.lightBlock.Update(lightData); g_litTextureProg.lightBlock.Update(lightData); using ( PushStack pushstack = new PushStack(modelMatrix)) { modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); modelMatrix.Scale(2.0f); Matrix3 normMatrix = new Matrix3(modelMatrix.Top()); normMatrix.Transpose(); //TEST normMatrix = Matrix3.Identity; //normMatrix = glm::transpose(glm::inverse(normMatrix)); ProgramData prog = g_bUseTexture ? g_litTextureProg : g_litShaderProg; GL.UseProgram(prog.theProgram); Matrix4 mm = modelMatrix.Top(); GL.UniformMatrix4(prog.modelToCameraMatrixUnif, false, ref mm); GL.UniformMatrix3(prog.normalModelToCameraMatrixUnif, false, ref normMatrix); GL.ActiveTexture(TextureUnit.Texture0 + g_gaussTexUnit); GL.BindTexture(TextureTarget.Texture1D, g_gaussTextures[g_currTexture]); GL.BindSampler(g_gaussTexUnit, g_gaussSampler); g_pObjectMesh.Render("lit"); GL.BindSampler(g_gaussTexUnit, 0); GL.BindTexture(TextureTarget.Texture1D, 0); GL.UseProgram(0); } if(g_bDrawLights) { using (PushStack pushstack = new PushStack(modelMatrix)) { modelMatrix.Translate(new Vector3(CalcLightPosition())); modelMatrix.Scale(0.25f); GL.UseProgram(g_Unlit.theProgram); Matrix4 mm = modelMatrix.Top(); GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm); Vector4 lightColor = new Vector4(1f, 1f, 1f, 1f); GL.Uniform4(g_Unlit.objectColorUnif, ref lightColor); g_pCubeMesh.Render("flat"); } modelMatrix.Translate(globalLightDirection * 100.0f); modelMatrix.Scale(5.0f); Matrix4 mm2 = modelMatrix.Top(); GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm2); g_pCubeMesh.Render("flat"); GL.UseProgram(0); } if(g_bDrawCameraPos) { using (PushStack pushstack = new PushStack(modelMatrix)) { modelMatrix.SetIdentity(); modelMatrix.Translate(new Vector3(0.0f, 0.0f, -g_viewPole.GetView().radius)); modelMatrix.Scale(0.25f); GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); GL.UseProgram(g_Unlit.theProgram); Matrix4 mm = modelMatrix.Top(); GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm); GL.Uniform4(g_Unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f); g_pCubeMesh.Render("flat"); GL.DepthMask(true); GL.Enable(EnableCap.DepthTest); GL.Uniform4(g_Unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f); g_pCubeMesh.Render("flat"); } } } }
public void RemoveLight() { this.Light = null; }
public void ConnectWithLight( LightBlock light ) { this.Light = light; }
public override String keyboard(Keys keyCode, int x, int y) { StringBuilder result = new StringBuilder(); result.AppendLine(keyCode.ToString()); if (displayOptions) { SetDisplayOptions(keyCode); } else { switch (keyCode) { case Keys.Enter: displayOptions = true; break; case Keys.D1: break; case Keys.D2: break; case Keys.D3: break; case Keys.D4: break; case Keys.D5: break; case Keys.D6: break; case Keys.D7: break; case Keys.D8: break; case Keys.D9: break; case Keys.D0: break; case Keys.A: ballProgram = Programs.AddProgram(VertexShaders.HDR_PCN2, FragmentShaders.DiffuseSpecularHDR); ball.SetProgram(ballProgram); Programs.SetUpLightBlock(ballProgram, numberOfLights); LightBlock lightBlock = new LightBlock(numberOfLights); lightBlock.ambientIntensity = new Vector4(0.1f, 0.1f, 0.1f, 1.0f); lightBlock.lightAttenuation = 0.1f; lightBlock.maxIntensity = 0.5f; lightBlock.lights[0].cameraSpaceLightPos = new Vector4(0.5f, 0.0f, 0.0f, 1f); lightBlock.lights[0].lightIntensity = new Vector4(0.0f, 0.0f, 0.6f, 1.0f); lightBlock.lights[1].cameraSpaceLightPos = new Vector4(0.0f, 0.5f, 1.0f, 1f); lightBlock.lights[1].lightIntensity = new Vector4(0.4f, 0.0f, 0.0f, 1.0f); Programs.UpdateLightBlock(ballProgram, lightBlock); MaterialBlock materialBlock = new MaterialBlock(); materialBlock.diffuseColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f); materialBlock.specularColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f) * 0.4f; materialBlock.specularShininess = 0.2f; Programs.SetUpMaterialBlock(ballProgram); Programs.UpdateMaterialBlock(ballProgram, materialBlock); Programs.SetNormalModelToCameraMatrix(ballProgram, Matrix3.Identity); break; case Keys.B: break; case Keys.C: break; case Keys.D: break; case Keys.F: break; case Keys.I: result.AppendLine("g_fzNear = " + g_fzNear.ToString()); result.AppendLine("g_fzFar = " + g_fzFar.ToString()); result.AppendLine("perspectiveAngle = " + perspectiveAngle.ToString()); result.AppendLine("textureRotation = " + textureRotation.ToString()); result.AppendLine("BallPosition = " + ball.GetOffset().ToString()); result.AppendLine("BallLimits = " + ball.GetLimits()); break; case Keys.P: newPerspectiveAngle = perspectiveAngle + 5f; if (newPerspectiveAngle > 170f) { newPerspectiveAngle = 30f; } result.AppendLine("newPerspectiveAngle = " + newPerspectiveAngle.ToString()); break; case Keys.R: if (rotateWorld) { rotateWorld = false; result.AppendLine("rotateWorld disabled"); } else { rotateWorld = true; result.AppendLine("rotateWorld enabled"); } break; } } return result.ToString(); }
private void updateProgram() { ballProgram = Programs.AddProgram(VertexShaders.HDR_PCN2, FragmentShaders.DiffuseSpecularHDR); ball.SetProgram(ballProgram); Programs.SetUpLightBlock(ballProgram, numberOfLights); LightBlock lightBlock = new LightBlock(numberOfLights); lightBlock.ambientIntensity = new Vector4(0.1f, 0.1f, 0.1f, 1.0f); lightBlock.lightAttenuation = 0.1f; lightBlock.maxIntensity = 0.5f; lightBlock.lights[0].cameraSpaceLightPos = new Vector4(0.5f, 0.0f, 0.0f, 1f); lightBlock.lights[0].lightIntensity = new Vector4(0.0f, 0.0f, 0.6f, 1.0f); lightBlock.lights[1].cameraSpaceLightPos = new Vector4(0.0f, 0.5f, 1.0f, 1f); lightBlock.lights[1].lightIntensity = new Vector4(0.4f, 0.0f, 0.0f, 1.0f); Programs.UpdateLightBlock(ballProgram, lightBlock); MaterialBlock materialBlock = new MaterialBlock(); materialBlock.diffuseColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f); materialBlock.specularColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f) * 0.4f; materialBlock.specularShininess = 0.2f; Programs.SetUpMaterialBlock(ballProgram); Programs.UpdateMaterialBlock(ballProgram, materialBlock); Programs.SetNormalModelToCameraMatrix(ballProgram, Matrix3.Identity); }
public LightConnector( LightBlock owner ) { Contract.Requires( owner != null ); this._owner = owner; }
public static void UpdateLightBlock(int program, LightBlock lb) { ActivePrograms[program].UpdateLightBlock(lb); }