Exemplo n.º 1
0
        static void Main(string[] args)
        {
            RemoteControl remoteControl = new RemoteControl(3);

            // Creating objects to control
            Light garageLight     = new Light1("Garage Light");
            Light livingRoomLight = new Light2("Living Room Light");
            // Creating commands for objects to control
            LightOn  garageLightOnCommand      = new LightOn(garageLight);
            LightOff garageLightOffCommand     = new LightOff(garageLight);
            LightOn  livingRoomLightOnCommand  = new LightOn(livingRoomLight);
            LightOff livingRoomLightOffCommand = new LightOff(livingRoomLight);
            // Creating Collection for AllLightOff and AllLightOff commands.
            var LightsOn  = new Command[] { garageLightOnCommand, livingRoomLightOnCommand };
            var LightsOff = new Command[] { garageLightOffCommand, livingRoomLightOffCommand };

            // Creating Macro commands
            AllLightOn  houseLightsOnCommand  = new AllLightOn(LightsOn);
            AllLightOff houseLightsOffCommand = new AllLightOff(LightsOff);


            // Loading commands into the remoteControl
            remoteControl.SetCommand(0, garageLightOnCommand, garageLightOffCommand);
            remoteControl.SetCommand(1, livingRoomLightOnCommand, livingRoomLightOffCommand);
            remoteControl.SetCommand(2, houseLightsOnCommand, houseLightsOffCommand);
            // Simulating button clicks
            remoteControl.OnButtonPushed(0);
            remoteControl.OffButtonPushed(0);
            remoteControl.OnButtonPushed(1);
            remoteControl.OffButtonPushed(1);
            remoteControl.OnButtonPushed(2);
            remoteControl.OffButtonPushed(2);
        }
Exemplo n.º 2
0
        //Button: top head default setting
        private void button9_Click(object sender, EventArgs e)
        {
            VRP0.Text = "54.0";
            VRP0.Show();
            VRP1.Text = "64.0";
            VRP1.Show();
            VRP2.Text = "-200.0";
            VRP2.Show();

            VPN0.Text = "0.0";
            VPN0.Show();
            VPN1.Text = "0.0";
            VPN1.Show();
            VPN2.Text = "1.0";
            VPN2.Show();

            VUP0.Text = "0.0";
            VUP0.Show();
            VUP1.Text = "-1.0";
            VUP1.Show();
            VUP2.Text = "0.0";
            VUP2.Show();

            Light0.Text = "1.0";
            Light0.Show();
            Light1.Text = "0.0";
            Light1.Show();
            Light2.Text = "0.0";
            Light2.Show();
        }
Exemplo n.º 3
0
        //Button: side face default setting
        private void default_set2_Click_1(object sender, EventArgs e)
        {
            VRP0.Text = "340.0";
            VRP0.Show();
            VRP1.Text = "64.0";
            VRP1.Show();
            VRP2.Text = "64.0";
            VRP2.Show();

            VPN0.Text = "-1.0";
            VPN0.Show();
            VPN1.Text = "0.0";
            VPN1.Show();
            VPN2.Text = "0.0";
            VPN2.Show();

            VUP0.Text = "0.0";
            VUP0.Show();
            VUP1.Text = "0.0";
            VUP1.Show();
            VUP2.Text = "1.0";
            VUP2.Show();

            Light0.Text = "-1.0";
            Light0.Show();
            Light1.Text = "0.0";
            Light1.Show();
            Light2.Text = "0.0";
            Light2.Show();
        }
Exemplo n.º 4
0
 public LightFacade(Light1 light1, Light2 light2, Light3 light3, Light4 light4, Light5 light5)
 {
     this.light1 = light1;
     this.light2 = light2;
     this.light3 = light3;
     this.light4 = light4;
     this.light5 = light5;
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            foreach (GameObject item in FindObjectsOfType(typeof(GameObject)) as GameObject[])
            {
                if (item.GetComponent <Renderer>())
                {
                    if (item.GetComponent <Renderer>().name != "No Name")
                    {
                        worldObjects.Add(new ColorConvertObject(item, item.GetComponent <Renderer>().material));
                    }
                }
            }
            Debug.Log("List created");
            lerping = true;
            Light1.GetComponent <Light>().color   = Color.white;
            Light2.GetComponent <Light>().color   = Color.white;
            DirLight.GetComponent <Light>().color = Color.white;
            RenderSettings.ambientLight           = new Color(.62f, .62f, .62f);
            RenderSettings.skybox = skybox;
            DynamicGI.UpdateEnvironment();
        }

        if (lerping)
        {
            foreach (ColorConvertObject item in worldObjects)
            {
                if (item.m_object.GetComponent <Renderer>())
                {
                    item.m_object.GetComponent <Renderer>().material.Lerp(item.m_material, whitematerial, Time.deltaTime);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.G))
        {
            if (worldObjects != null)
            {
                foreach (ColorConvertObject item in worldObjects)
                {
                    if (item.m_object.GetComponent <Renderer>())
                    {
                        item.m_object.GetComponent <Renderer>().material = item.m_material;
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            SceneManager.LoadScene("_scenes/OtherSceneTest", LoadSceneMode.Single);
            Debug.Log("SceneLoad!");
        }
    }
Exemplo n.º 6
0
    // Start is called before the first frame update
    void Start()
    {
        light1 = light1Obj.GetComponent <Light1>();
        light2 = light2Obj.GetComponent <Light2>();
        light3 = light3Obj.GetComponent <Light3>();
        light4 = light4Obj.GetComponent <Light4>();
        light5 = light5Obj.GetComponent <Light5>();

        lightFacade = new LightFacade(light1, light2, light3, light4, light5);

        winText.SetActive(false);

        GameStart();
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        Light1 = GameObject.Find("RoomCollider and NavMesh/Light/SphereGreen");
        Light2 = GameObject.Find("RoomCollider and NavMesh/Light 2/SphereGreen");

        Light1Red = GameObject.Find("RoomCollider and NavMesh/Light/SphereRed");
        Light2Red = GameObject.Find("RoomCollider and NavMesh/Light 2/SphereRed");


        halo1  = (Behaviour)Light1.GetComponent("Halo");
        halo1r = (Behaviour)Light1Red.GetComponent("Halo");
        halo2  = (Behaviour)Light2.GetComponent("Halo");
        halo2r = (Behaviour)Light2Red.GetComponent("Halo");


        halo1.enabled = false;
        halo2.enabled = false;


        WallMidle = GameObject.Find("RoomCollider and NavMesh/Back Wall Middle");
        Door      = GameObject.Find("RoomCollider and NavMesh/Door");
        ACDoor    = Door.GetComponent <Animator>();
    }
        private bool RenderSceneToTexture2()
        {
            // Set the render target to be the render to texture.
            RenderTexture2.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            RenderTexture2.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the light view matrix based on the light's position.
            Light2.GenerateViewMatrix();

            // Get the world matrix from the d3d object.
            Matrix worldMareix = D3D.WorldMatrix;

            // Get the view and orthographic matrices from the light object.
            Matrix lightViewMatrix  = Light2.ViewMatrix;
            Matrix lightOrthoMatrix = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMareix);

            // Render the cube model with the depth shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMareix);

            // Render the sphere model with the depth shader.
            SphereModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMareix);

            // Render the ground model with the depth shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }
        public bool Render()
        {
            // First render the scene to a texture.
            if (!RenderSceneToTexture())
            {
                return(false);
            }

            // Render the scene to texture again but use the second light's view point.
            if (!RenderSceneToTexture2())
            {
                return(false);
            }

            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Do the same for the second light.
            Light2.GenerateViewMatrix();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the light's view and projection matrices from the light object.
            Matrix lightViewMatrix       = Light.ViewMatrix;
            Matrix lightProjectionMatrix = Light.ProjectionMatrix;

            // Do the same for the second light.
            Matrix lightViewMatrix2       = Light2.ViewMatrix;
            Matrix lightProjectionMatrix2 = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMatrix);

            // Put the cube model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            CubeModel.Render(D3D.DeviceContext);

            // Render the model using the shadow shader.
            if (!ShadowShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, CubeModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMatrix);

            // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            SphereModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, SphereModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, GroundModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Exemplo n.º 10
0
        private static void _lightThread()
        {
            Console.WriteLine("_lightThread started.");
            Tuple <Int32, byte> lval;

            while (!Stop)
            {
                // light 1 led
                lval = Light1.GetLEDValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                OpenDMX.setDmxValue(lval.Item1 + 1, lval.Item2);
                // light 1 strobe
                lval = Light1.GetStrobeValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 gobo
                lval = Light1.GetGoboValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 color
                lval = Light1.GetColorValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 pan
                lval = Light1.GetPanValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 pan fine
                lval = Light1.GetPanfValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 tilt
                lval = Light1.GetTiltValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 1 tile fine
                lval = Light1.GetTiltfValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);

                // light 2 led
                lval = Light2.GetLEDValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                OpenDMX.setDmxValue(lval.Item1 + 1, lval.Item2);
                // light 2 strobe
                lval = Light2.GetStrobeValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 gobo
                lval = Light2.GetGoboValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 color
                lval = Light2.GetColorValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 pan
                lval = Light2.GetPanValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 pan fine
                lval = Light2.GetPanfValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 tilt
                lval = Light2.GetTiltValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);
                // light 2 tile fine
                lval = Light2.GetTiltfValue();
                OpenDMX.setDmxValue(lval.Item1, lval.Item2);

                Thread.Sleep(100);
                OpenDMX.writeData();
            }
            Console.WriteLine("_lightThread stopped.");
        }