Example #1
0
        private void XBuild_OnClick(object sender, RoutedEventArgs e)
        {
            CPPFileAnalyzer analyzer;
            try
            {
                analyzer = new CPPFileAnalyzer(GetString(XSource));
            }
            catch
            {
                MessageBox.Show("Error parsing code! Please check your code before building chart!", "CChart error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                Visualizer visualizer = new Visualizer(analyzer.Result);
                SaveFileDialog sfd=new SaveFileDialog();
                sfd.DefaultExt = ".png";
                sfd.Filter = "Images (.png)|*.png";
                if (sfd.ShowDialog().Value)
                {
                    visualizer.Image.Save(sfd.FileName);
                }

            }
            catch
            {
                MessageBox.Show("Error building chart!", "CChart error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
 static void Main(string[] args)
 {
     for (int i = 2; i < 6; i++)
     {
         GC.Collect();
         DateTime start = DateTime.Now;
         var c = new CPPFileAnalyzer(File.ReadAllText(i + ".cpp", Encoding.Default));
         var v = new Visualizer(c.Result);
         v.Image.Save(i+".png");
         Console.WriteLine((DateTime.Now-start).TotalMilliseconds);
         Process.Start(i + ".png");
         return;
     }
 }
Example #3
0
 public static void Main()
 {
     Visualizer.Init(typeof(TestingClass).Assembly, VisualizerState.Standard);
     Visualizer.Deserialize();
 }
Example #4
0
 public void MoveVisualizer(int cell)
 {
     Visualizer.transform.SetPosition(Grid.CellToPosCBC(cell, DigTool.Instance.visualizerLayer));
     Visualizer.SetActive(IsPlaceable(cell));
 }
 public override void Do(Visualizer viz)
 {
     viz.RemoveParticle(index);
 }
 public override void OnVisualize(Visualizer visualizer)
 {
     Debug.Assert(visualizer != null);
     visualizer.UpdateRenderTexture(Camera.activeTexture, Camera.aspect);
 }
Example #7
0
 public override void Do(Visualizer viz)
 {
     viz.Camera.Position = ConvertToPoint3D(ConvertVector(position));
 }
Example #8
0
        private void buttonInit_Click(object sender, EventArgs e)
        {
            reset();

            // 32 bit color
            if (Screen.PrimaryScreen.BitsPerPixel != 32)
            {
                failure(pictureInit32Bit, "The screen must be set to 32 bit colors");
                return;
            }
            else
            {
                success(pictureInit32Bit);
            }

            // ms. pacman is loaded
            // find process
            Process[] processes = Process.GetProcesses();
            foreach (Process p in processes)
            {
                if (p.MainWindowTitle.StartsWith("Ms. Pac-Man"))
                {
                    //if( p.MainWindowTitle.StartsWith("WebPacMan") ) {
                    msPacmanProcess = p;
                }
            }
            // set as foreground window
            try {
                Comm.ShowWindow(msPacmanProcess.MainWindowHandle, (int)WindowShowStyle.Restore);
                Comm.SetWindowPos(msPacmanProcess.MainWindowHandle, (IntPtr)Comm.HWND_TOP, this.Left + this.Width, this.Top, 0, 0, 0);
                success(pictureInitFoundGame);
            } catch {
                failure(pictureInitFoundGame, "Please make sure Microsoft Ms. Pacman is running");
                return;
            }

            // entire window: 234, 344
            // working area: 224, 288
            // locate game area
            try{
                WINDOWINFO info = Comm.GetWindowInfoEasy(msPacmanProcess.MainWindowHandle);
                gameRect = new Rectangle(info.rcClient.Left, info.rcClient.Top, info.rcClient.Width, info.rcClient.Height);
                success(pictureInitLocated);
            } catch (Exception ex) {
                failure(pictureInitLocated, ex.Message);
            }

            // start window
            if (checkBoxVisualizer.Checked && vThread == null)                // seeing problems? remember to debug with this first!
            {
                vThread = new System.Threading.Thread(delegate() {
                    v               = new Visualizer();
                    v.Location      = new Point(this.Right, this.Top + this.Height);
                    v.StartPosition = FormStartPosition.Manual;
                    try {
                        System.Windows.Forms.Application.Run(v);
                    } catch { }
                });
                vThread.Start();
                System.Threading.Thread.Sleep(2000);
            }

            // success
            buttonStart.Enabled      = true;
            labelInitialized.Visible = true;

            // autoplay
            if (checkBoxAutoPlay.Checked)
            {
                buttonStart_Click(null, null);
            }
            else
            {
                this.BringToFront();
            }
        }
    public void Details()
    {
        positionTable.Add("Dungeon Generated", false);
        PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
        visualizer = GetComponent <Visualizer>();
        width      = visualizer.width;
        height     = visualizer.height;
        location   = new int[2];
        objects    = new List <GameObject>();
        //if (firstTime != true)
        //{
        //    for(int i = 0; i < objects.Count; i++)
        //    {
        //        Destroy(objects[i]);
        //    }
        //    objects.Clear();
        //}
        //else if (firstTime == true)
        //{
        //    firstTime = false;
        //}
        if (visualizer.firstTime == false)
        {
            int heighMultiplier = 1;
            int widthMultiplier = 0;
            //details.SetActive(true);
            //visualizers.SetActive(false);
            mapData = visualizer.mapData;
            for (int i = 0; i < mapData.Length; i++)
            {
                if (i > width * heighMultiplier)
                {
                    heighMultiplier++;
                    widthMultiplier = 0;
                }
                location[0] = widthMultiplier * 49;
                location[1] = heighMultiplier * 49;
                position    = new Vector3(location[1], 0, location[0] - 200);
                if (mapData[i] == 2 || mapData[i] == 3 || mapData[i] == 4)
                {
                    //Top
                    if (mapData[i - width] == 2 || mapData[i - width] == 3 || mapData[i - width] == 4)
                    {
                        //Top, Bottom
                        if (mapData[i + width] == 2 || mapData[i + width] == 3 || mapData[i + width] == 4)
                        {
                            //Top, Bottom, Forward
                            if (mapData[i - 1] == 2 || mapData[i - 1] == 3 || mapData[i - 1] == 4)
                            {
                                //Top, Bottom, Forward, Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 0, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 3 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[3].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 4 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[4].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 5 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[5].name, position, rotation));
                                    }
                                }
                                //Top, Bottom, Forward
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 180, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 6 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[6].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                            //objects.Add(Instantiate(player, position, Quaternion.identity));
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 7 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[7].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 8 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[8].name, position, rotation));
                                    }
                                }
                            }
                            //Top, Bottom
                            else
                            {
                                //Top, Bottom, back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 0, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 6 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[6].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 7 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[7].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 8 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[8].name, position, rotation));
                                    }
                                }
                                //Top, Bottom
                                else
                                {
                                    randomNumber = Random.Range(1, 3);
                                    rotation     = Quaternion.Euler(0, 0, 0);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 12 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[12].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 10 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[10].name, position, rotation));
                                    }
                                }
                            }
                        }
                        //Top
                        else
                        {
                            //Top, Front
                            if (mapData[i - 1] == 2 || mapData[i - 1] == 3 || mapData[i - 1] == 4)
                            {
                                //Top, Front, Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 270, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 6 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[6].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 7 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[7].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 8 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[8].name, position, rotation));
                                    }
                                }
                                //Top, Front
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 180, 0);
                                    randomNumber = Random.Range(1, 3);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 9 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[9].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 11 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[11].name, position, rotation));
                                    }
                                }
                            }

                            else //Top
                            {
                                //Top, Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 270, 0);
                                    randomNumber = Random.Range(1, 3);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 9 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[9].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            // photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 11 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[11].name, position, rotation));
                                    }
                                }
                                //Top
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 270, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 0 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[0].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 1 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[1].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 2 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[2].name, position, rotation));
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //Bottom
                        if (mapData[i + width] == 2 || mapData[i + width] == 3 || mapData[i + width] == 4)
                        {
                            //Bottom, Forward
                            if (mapData[i - 1] == 2 || mapData[i - 1] == 3 || mapData[i - 1] == 4)
                            {
                                //Bottom, Forward, Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 90, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 6 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[6].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 7 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[7].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 8 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[8].name, position, rotation));
                                    }
                                }
                                //Bottom, Forward
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 90, 0);
                                    randomNumber = Random.Range(1, 3);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 9 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[9].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 11 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[11].name, position, rotation));
                                    }
                                }
                            }
                            //Bottom
                            else
                            {
                                //Bottom, back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 0, 0);
                                    randomNumber = Random.Range(1, 3);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 9 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[9].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 11 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[11].name, position, rotation));
                                    }
                                }
                                //Bottom
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 90, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 0 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[0].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 1 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[1].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 2 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[2].name, position, rotation));
                                    }
                                }
                            }
                        }
                        //None
                        else
                        {
                            //Front
                            if (mapData[i - 1] == 2 || mapData[i - 1] == 3 || mapData[i - 1] == 4)
                            {
                                //Front, Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    randomNumber = Random.Range(1, 3);
                                    rotation     = Quaternion.Euler(0, 90, 0);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 12 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[12].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 10 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[10].name, position, rotation));
                                    }
                                }
                                //Front
                                else
                                {
                                    rotation     = Quaternion.Euler(0, 180, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 0 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[0].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 1 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[1].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 2 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[2].name, position, rotation));
                                    }
                                }
                            }

                            else //None
                            {
                                //Back
                                if (mapData[i + 1] == 2 || mapData[i + 1] == 3 || mapData[i + 1] == 4)
                                {
                                    rotation     = Quaternion.Euler(0, 0, 0);
                                    randomNumber = Random.Range(1, 4);
                                    if (randomNumber == 1 || mapData[i] == 3 || mapData[i] == 4)
                                    {
                                        //Load from array at index 0 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[0].name, position, rotation));
                                        position = new Vector3(location[1], 2, location[0] - 200);
                                        if (mapData[i] == 3)
                                        {
                                            finalPosition = position;
                                            positionTable.Add("Players", finalPosition);
                                            PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
                                            //photonView.RPC("PositionSetUp", RpcTarget.AllBufferedViaServer);
                                        }
                                        else if (mapData[i] == 4)
                                        {
                                            //objects.Add(Instantiate(boss, position, Quaternion.identity));
                                        }
                                    }
                                    else if (randomNumber == 2)
                                    {
                                        //Load from array at index 1 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[1].name, position, rotation));
                                    }
                                    else if (randomNumber == 3)
                                    {
                                        //Load from array at index 2 instantiating it at this spot, and maybe rotating it
                                        objects.Add(PhotonNetwork.Instantiate(rooms[2].name, position, rotation));
                                    }
                                }
                                //None, Final
                                else
                                {
                                }
                            }
                        }
                    }
                }
                widthMultiplier++;
            }
        }
        positionTable["Dungeon Generated"] = true;
        PhotonNetwork.CurrentRoom.SetCustomProperties(positionTable);
    }
Example #10
0
 public override void OnVisualize(Visualizer visualizer)
 {
     //
 }
Example #11
0
    private List <Visualizer.Content> PixelContent; // list of pixel color control


    // Use this for initialization
    void Start()
    {
        // finish initialization
        Vis   = new Visualizer("PixelParent", "Pixel", "Line", DefaultMaterial);
        Trans = TransmitterContainer.GetComponent <Transmitter>();
    }
Example #12
0
 void StartVisualizer()
 {
     //visualizer.Begin ();
     visualizerInstance = Instantiate(visualizerPrefab);
 }
            // Complete paint area
            public static void CompletePaintArea()
            {
                // Get current mouse position on grid
                Vector3 paintAreaEnd = Helper.GetPositionOnGridClosestToMousePointer();

                paintAreaEnd.y = Settings.Data.gui.grid.gridHeight *
                                 Settings.Data.gui.grid.yUnitSize + Const.Grid.yOffsetToAvoidTearing;

                // If selected Prefab can be scaled
                if (Helper.GetPaintAreaStretch())
                {
                    // Place the prefab
                    GameObject placedPrefab = Placement.PlacePrefabInScene();

                    // Move prefab centerpoint between both paint areas
                    placedPrefab.transform.position = (new Vector3(paintAreaStart.x, Settings.Data.gui.grid.gridHeight * Settings.Data.gui.grid.yUnitSize, paintAreaStart.z)
                                                       + new Vector3(paintAreaEnd.x, Settings.Data.gui.grid.gridHeight * Settings.Data.gui.grid.yUnitSize, paintAreaEnd.z))
                                                      / 2;

                    // Apply position offset
                    placedPrefab.transform.position += Helper.GetOffsetPosition();

                    //----------------------------------------------
                    // Scale prefab X and Z to match paint area
                    //----------------------------------------------
                    Vector3 scale;

                    // Get Y angle of Visualizer, divide by 90, and round.  Result will be 0-3 instead of 0-360
                    int prefabRotationQuadrant = Mathf.RoundToInt(Visualizer.GetGameObject().transform.rotation.eulerAngles.y / 90f);

                    // If prefab is rotated 0 or 180 degrees, then scale normally
                    if (prefabRotationQuadrant == 0 || prefabRotationQuadrant == 2)
                    {
                        scale = new Vector3(
                            Mathf.Abs(paintAreaStart.x - paintAreaEnd.x) + Settings.Data.gui.grid.xzUnitSize,
                            1,
                            Mathf.Abs(paintAreaStart.z - paintAreaEnd.z) + Settings.Data.gui.grid.xzUnitSize);
                    }
                    // If prefab is rotated 90 or 270 degrees, then swap X and Z for the scale
                    else
                    {
                        scale = new Vector3(
                            Mathf.Abs(paintAreaStart.z - paintAreaEnd.z) + Settings.Data.gui.grid.xzUnitSize,
                            1,
                            Mathf.Abs(paintAreaStart.x - paintAreaEnd.x) + Settings.Data.gui.grid.xzUnitSize);
                    }

                    // Apply calculate scale
                    placedPrefab.transform.localScale = scale;

                    // Apply rotation from the Visualizer
                    placedPrefab.transform.rotation = Visualizer.GetGameObject().transform.rotation;
                }

                // If selected Prefab cannot be scaled
                else
                {
                    // Get base of rows and columns "lowest value"
                    float xBase = paintAreaStart.x < paintAreaEnd.x ? paintAreaStart.x : paintAreaEnd.x;
                    float zBase = paintAreaStart.z < paintAreaEnd.z ? paintAreaStart.z : paintAreaEnd.z;

                    // Get count of rows and columns in paint area
                    int xCount = (int)(Mathf.Abs(paintAreaStart.x - paintAreaEnd.x) / Settings.Data.gui.grid.xzUnitSize);
                    int zCount = (int)(Mathf.Abs(paintAreaStart.z - paintAreaEnd.z) / Settings.Data.gui.grid.xzUnitSize);

                    // Loop through each grid space in the area
                    for (int x = 0; x <= xCount; x++)
                    {
                        for (int z = 0; z <= zCount; z++)
                        {
                            // Set visualizer position
                            Visualizer.GetGameObject().transform.position =
                                new Vector3(xBase + (x * Settings.Data.gui.grid.xzUnitSize),
                                            Settings.Data.gui.grid.gridHeight * Settings.Data.gui.grid.yUnitSize,
                                            zBase + (z * Settings.Data.gui.grid.xzUnitSize)) + Helper.GetOffsetPosition();

                            // Add Prefab to scene
                            Placement.PlacePrefabInScene();
                        }
                    }
                }

                // Delete painting area
                DeletePaintArea();
            }
Example #14
0
 public void visualize(GameObject gameObject, Vector3[] groundVertices, Vector3 offset, float height = 10)
 {
     if (!useOldVisualizerAndState)
     {
         Stack <State> StateStack   = new Stack <State>();
         State         currentState = new State(gameObject, groundVertices);
         for (int i = 0; i < axiom.Length; i++)
         {
             char symbol = axiom[i];
             if (symbol != '[' && symbol != ']')
             {
                 if (symbol == 'E')
                 {
                     //  Debug.Log("Y PRE EXTRUDE: " + currentState.getTop()[0].y);
                     Visualizer.extrude(currentState, height);
                     //  Debug.Log("Y POST EXTRUDE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'x')
                 {
                     Visualizer.scale(currentState, new Vector3(0.6f, 1, 1));
                 }
                 else if (symbol == 'y')
                 {
                     // Debug.Log("Y PRE SCALE: " + currentState.getTop()[0].y);
                     Visualizer.scale(currentState, new Vector3(1, 0.4f, 1));
                     // Debug.Log("Y POST SCALE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'z')
                 {
                     Visualizer.scale(currentState, new Vector3(1, 1, 0.9f));
                 }
                 else if (symbol == 'X')
                 {
                     Visualizer.translate(currentState, new Vector3(1, 0, 0));
                 }
                 else if (symbol == 'Y')
                 {
                     //  Debug.Log("Y PRE TRANSLATE: " + currentState.getTop()[0].y);
                     Visualizer.translate(currentState, new Vector3(0, -3, 0));
                     //  Debug.Log("Y POST TRANSLATE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'Z')
                 {
                     Visualizer.translate(currentState, new Vector3(0, 0, 0.2f));
                 }
             }
             else if (axiom[i] == '[')
             {
                 StateStack.Push(currentState.clone());
             }
             else if (axiom[i] == ']')
             {
                 currentState = StateStack.Pop();
             }
         }
     }
     else
     {
         Stack <StateOld> StateStack   = new Stack <StateOld>();
         StateOld         currentState = new StateOld(gameObject, groundVertices);
         for (int i = 0; i < axiom.Length; i++)
         {
             char symbol = axiom[i];
             if (symbol != '[' && symbol != ']')
             {
                 if (symbol == 'E')
                 {
                     VisualizerOld.extrude(currentState, height);
                 }
                 else if (symbol == 'x')
                 {
                     VisualizerOld.scale(currentState, 0.6f, 1, 1);
                 }
                 else if (symbol == 'y')
                 {
                     VisualizerOld.scale(currentState, 1, 0.4f, 1);
                 }
                 else if (symbol == 'z')
                 {
                     VisualizerOld.scale(currentState, 1, 1, 0.9f);
                 }
                 else if (symbol == 'X')
                 {
                     VisualizerOld.translate(currentState, 0.2f, 0, 0);
                 }
                 else if (symbol == 'Y')
                 {
                     VisualizerOld.translate(currentState, 0, -1, 0);
                 }
                 else if (symbol == 'Z')
                 {
                     VisualizerOld.translate(currentState, 0, 0, 0.2f);
                 }
             }
             else if (axiom[i] == '[')
             {
                 StateStack.Push(currentState.clone());
             }
             else if (axiom[i] == ']')
             {
                 currentState = StateStack.Pop();
             }
         }
     }
     if (offset != null)
     {
         gameObject.transform.Translate(offset);
     }
 }
Example #15
0
 public static Converter CreateConverter(SensorUnity expectedUnity, SensorUnity realUnity, Sensor sensor, Visualizer visualizer)
 {
     foreach (Type converterType in typeof(Converter).Assembly.GetTypes())
     {
         ConverterAttribute converterAttribute = (ConverterAttribute)converterType.GetCustomAttribute(typeof(ConverterAttribute));
         if (converterAttribute != null && converterAttribute.inputUnity == realUnity && converterAttribute.outputUnity == expectedUnity)
         {
             return((Converter)Activator.CreateInstance(converterType, sensor, visualizer));
         }
     }
     throw new Exception("There is no converter supporting this conversion, expected: " + expectedUnity.ToString() + ", real: " + realUnity);
 }
Example #16
0
 public override void OnVisualize(Visualizer visualizer)
 {
     Debug.Assert(visualizer != null);
     visualizer.UpdateRenderTexture(Distorted ? DistortedTexture : SensorCamera.activeTexture, SensorCamera.aspect);
 }
Example #17
0
 public void RegisterVisualizer(Visualizer visualizer)
 {
     this.visualizers.Add(visualizer);
 }
 private void Awake()
 {
     visualizer = GetComponentInParent <Visualizer>();
 }
Example #19
0
    private List <Visualizer.Content> PixelContent; // list of pixel color control


    // Use this for initialization
    void Start()
    {
        // finish initialization
        Vis      = new Visualizer("PixelParent", "Pixel", "Line", DefaultMaterial);
        Producer = DataProducerContainer.GetComponent <DataProducer>();
    }
Example #20
0
 public void OnFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate)
 {
     lightOrganProcessor.ProcessFftData(visualizer, fft, samplingRate);
 }
Example #21
0
 public DigVisual(int cell, Vector2I offset)
 {
     Visualizer = GameUtil.KInstantiate(DigTool.Instance.visualizer, Grid.CellToPosCBC(cell, DigTool.Instance.visualizerLayer), DigTool.Instance.visualizerLayer, "BlueprintModDigVisualizer");
     Visualizer.SetActive(IsPlaceable(cell));
     Offset = offset;
 }
Example #22
0
 public abstract void OnVisualize(Visualizer visualizer);
Example #23
0
        public bool TryUse(int cell)
        {
            if (BlueprintsState.InstantBuild)
            {
                if (ValidCell(cell))
                {
                    Vector3    positionCBC = Grid.CellToPosCBC(cell, buildingConfig.BuildingDef.SceneLayer);
                    GameObject building    = buildingConfig.BuildingDef.Create(positionCBC, null, buildingConfig.SelectedElements, buildingConfig.BuildingDef.CraftRecipe, 293.15F, buildingConfig.BuildingDef.BuildingComplete);
                    if (building == null)
                    {
                        return(false);
                    }

                    buildingConfig.BuildingDef.MarkArea(cell, buildingConfig.Orientation, buildingConfig.BuildingDef.ObjectLayer, building);

                    if (building.GetComponent <Deconstructable>() != null)
                    {
                        building.GetComponent <Deconstructable>().constructionElements = buildingConfig.SelectedElements.ToArray();
                    }

                    if (building.GetComponent <Rotatable>() != null)
                    {
                        building.GetComponent <Rotatable>().SetOrientation(buildingConfig.Orientation);
                    }

                    if (Visualizer.GetComponent <KBatchedAnimController>() != null)
                    {
                        Visualizer.GetComponent <KBatchedAnimController>().TintColour = BlueprintsAssets.BLUEPRINTS_COLOR_INVALIDPLACEMENT;
                    }

                    building.SetActive(true);
                    return(true);
                }
            }

            else if (IsPlaceable(cell))
            {
                Vector3    positionCBC = Grid.CellToPosCBC(cell, buildingConfig.BuildingDef.SceneLayer);
                GameObject building    = buildingConfig.BuildingDef.Instantiate(positionCBC, buildingConfig.Orientation, buildingConfig.SelectedElements);
                if (building == null)
                {
                    return(false);
                }

                if (building.GetComponent <Rotatable>() != null)
                {
                    building.GetComponent <Rotatable>().SetOrientation(buildingConfig.Orientation);
                }

                if (Visualizer.GetComponent <KBatchedAnimController>() != null)
                {
                    Visualizer.GetComponent <KBatchedAnimController>().TintColour = BlueprintsAssets.BLUEPRINTS_COLOR_INVALIDPLACEMENT;
                }

                if (ToolMenu.Instance != null)
                {
                    building.FindOrAddComponent <Prioritizable>().SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority());
                }

                building.SetActive(true);
                return(true);
            }

            return(false);
        }
Example #24
0
        // The main function call for processing sequences
        private void ProcessSequence(SequenceReader reader)
        {
            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            SetupFeatureExtractionMode();

            thread_running = true;

            face_model_params.optimiseForVideo();

            // Setup the visualization
            Visualizer visualizer_of = new Visualizer(ShowTrackedVideo || RecordTracked, ShowAppearance, ShowAppearance);

            // Initialize the face analyser
            face_analyser = new FaceAnalyserManaged(AppDomain.CurrentDomain.BaseDirectory, DynamicAUModels, image_output_size, MaskAligned);

            // Reset the tracker
            landmark_detector.Reset();

            // Loading an image file
            var frame      = new RawImage(reader.GetNextImage());
            var gray_frame = new RawImage(reader.GetCurrentFrameGray());

            // Setup recording
            RecorderOpenFaceParameters rec_params = new RecorderOpenFaceParameters(true, reader.IsWebcam(),
                                                                                   Record2DLandmarks, Record3DLandmarks, RecordModelParameters, RecordPose, RecordAUs,
                                                                                   RecordGaze, RecordHOG, RecordTracked, RecordAligned,
                                                                                   reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), reader.GetFPS());

            RecorderOpenFace recorder = new RecorderOpenFace(reader.GetName(), rec_params, record_root);

            // For FPS tracking
            DateTime?startTime     = CurrentTime;
            var      lastFrameTime = CurrentTime;

            // Empty image would indicate that the stream is over
            while (gray_frame.Width != 0)
            {
                if (!thread_running)
                {
                    break;
                }

                double progress             = reader.GetProgress();
                bool   detection_succeeding = landmark_detector.DetectLandmarksInVideo(gray_frame, face_model_params);

                // The face analysis step (for AUs and eye gaze)
                face_analyser.AddNextFrame(frame, landmark_detector.CalculateAllLandmarks(), detection_succeeding, false);
                gaze_analyser.AddNextFrame(landmark_detector, detection_succeeding, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy());

                // Only the final face will contain the details
                VisualizeFeatures(frame, visualizer_of, landmark_detector.CalculateAllLandmarks(), landmark_detector.GetVisibilities(), detection_succeeding, true, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), progress);

                // Record an observation
                RecordObservation(recorder, visualizer_of.GetVisImage(), detection_succeeding, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), reader.GetTimestamp());

                while (thread_running & thread_paused && skip_frames == 0)
                {
                    Thread.Sleep(10);
                }

                if (skip_frames > 0)
                {
                    skip_frames--;
                }

                frame      = new RawImage(reader.GetNextImage());
                gray_frame = new RawImage(reader.GetCurrentFrameGray());

                lastFrameTime = CurrentTime;
                processing_fps.AddFrame();
            }

            // Finalize the recording and flush to disk
            recorder.Close();

            // Post-process the AU recordings
            if (RecordAUs)
            {
                face_analyser.PostProcessOutputFile(recorder.GetCSVFile());
            }

            // Close the open video/webcam
            reader.Close();

            EndMode();
        }
 public override void Do(Visualizer viz)
 {
     throw new NotImplementedException();
     //var obj = viz.RetrieveObject(index);
     //obj.GeoModel.Material = material.Material;
 }
Example #26
0
        private void ProcessIndividualImages(ImageReader reader)
        {
            // Make sure the GUI is setup appropriately
            SetupFeatureExtractionMode();

            // Indicate we will start running the thread
            thread_running = true;

            // Setup the parameters optimized for working on individual images rather than sequences
            face_model_params.optimiseForImages();

            // Setup the visualization
            Visualizer visualizer_of = new Visualizer(ShowTrackedVideo || RecordTracked, ShowAppearance, ShowAppearance);

            // Initialize the face detector if it has not been initialized yet
            if (face_detector == null)
            {
                face_detector = new FaceDetector();
            }

            // Initialize the face analyser
            face_analyser = new FaceAnalyserManaged(AppDomain.CurrentDomain.BaseDirectory, false, image_output_size, MaskAligned);

            // Loading an image file
            var frame      = new RawImage(reader.GetNextImage());
            var gray_frame = new RawImage(reader.GetCurrentFrameGray());

            // For FPS tracking
            DateTime?startTime     = CurrentTime;
            var      lastFrameTime = CurrentTime;

            // This will be false when the image is not available
            while (reader.isOpened())
            {
                if (!thread_running)
                {
                    break;
                }

                // Setup recording
                RecorderOpenFaceParameters rec_params = new RecorderOpenFaceParameters(false, false,
                                                                                       Record2DLandmarks, Record3DLandmarks, RecordModelParameters, RecordPose, RecordAUs,
                                                                                       RecordGaze, RecordHOG, RecordTracked, RecordAligned,
                                                                                       reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), 0);

                RecorderOpenFace recorder = new RecorderOpenFace(reader.GetName(), rec_params, record_root);

                // Detect faces here and return bounding boxes
                List <Rect>   face_detections = new List <Rect>();
                List <double> confidences     = new List <double>();
                face_detector.DetectFacesHOG(face_detections, gray_frame, confidences);

                // For visualization
                double progress = reader.GetProgress();

                for (int i = 0; i < face_detections.Count; ++i)
                {
                    bool detection_succeeding = landmark_detector.DetectFaceLandmarksInImage(gray_frame, face_detections[i], face_model_params);

                    var landmarks = landmark_detector.CalculateAllLandmarks();

                    // Predict action units
                    var au_preds = face_analyser.PredictStaticAUsAndComputeFeatures(frame, landmarks);

                    // Predic eye gaze
                    gaze_analyser.AddNextFrame(landmark_detector, detection_succeeding, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy());

                    // Only the final face will contain the details
                    VisualizeFeatures(frame, visualizer_of, landmarks, landmark_detector.GetVisibilities(), detection_succeeding, i == 0, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), progress);

                    // Record an observation
                    RecordObservation(recorder, visualizer_of.GetVisImage(), detection_succeeding, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), 0);
                }

                frame      = new RawImage(reader.GetNextImage());
                gray_frame = new RawImage(reader.GetCurrentFrameGray());

                // Do not cary state accross images
                landmark_detector.Reset();
                face_analyser.Reset();
                recorder.Close();

                lastFrameTime = CurrentTime;
                processing_fps.AddFrame();

                // TODO how to report errors from the reader here? exceptions? logging? Problem for future versions?
            }

            EndMode();
        }
 public override void Do(Visualizer viz)
 {
     viz.TransformParticle(objectIndex, position, scale, rotation);
 }
Example #28
0
        private void VisualizeFeatures(RawImage frame, Visualizer visualizer, List <Tuple <double, double> > landmarks, List <bool> visibilities, bool detection_succeeding,
                                       bool new_image, float fx, float fy, float cx, float cy, double progress)
        {
            List <Tuple <Point, Point> >   lines         = null;
            List <Tuple <double, double> > eye_landmarks = null;
            List <Tuple <Point, Point> >   gaze_lines    = null;
            Tuple <double, double>         gaze_angle    = new Tuple <double, double>(0, 0);

            List <double> pose = new List <double>();

            landmark_detector.GetPose(pose, fx, fy, cx, cy);
            List <double> non_rigid_params = landmark_detector.GetNonRigidParams();

            double confidence = landmark_detector.GetConfidence();

            if (confidence < 0)
            {
                confidence = 0;
            }
            else if (confidence > 1)
            {
                confidence = 1;
            }

            double scale = landmark_detector.GetRigidParams()[0];

            // Helps with recording and showing the visualizations
            if (new_image)
            {
                visualizer.SetImage(frame, fx, fy, cx, cy);
            }
            visualizer.SetObservationHOG(face_analyser.GetLatestHOGFeature(), face_analyser.GetHOGRows(), face_analyser.GetHOGCols());
            visualizer.SetObservationLandmarks(landmarks, confidence, visibilities);
            visualizer.SetObservationPose(pose, confidence);
            visualizer.SetObservationGaze(gaze_analyser.GetGazeCamera().Item1, gaze_analyser.GetGazeCamera().Item2, landmark_detector.CalculateAllEyeLandmarks(), landmark_detector.CalculateAllEyeLandmarks3D(fx, fy, cx, cy), confidence);

            if (detection_succeeding)
            {
                eye_landmarks = landmark_detector.CalculateVisibleEyeLandmarks();
                lines         = landmark_detector.CalculateBox(fx, fy, cx, cy);

                gaze_lines = gaze_analyser.CalculateGazeLines(fx, fy, cx, cy);
                gaze_angle = gaze_analyser.GetGazeAngle();
            }

            // Visualisation (as a separate function)
            Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() =>
            {
                if (ShowAUs)
                {
                    var au_classes = face_analyser.GetCurrentAUsClass();
                    var au_regs = face_analyser.GetCurrentAUsReg();

                    auClassGraph.Update(au_classes);

                    var au_regs_scaled = new Dictionary <String, double>();
                    foreach (var au_reg in au_regs)
                    {
                        au_regs_scaled[au_reg.Key] = au_reg.Value / 5.0;
                        if (au_regs_scaled[au_reg.Key] < 0)
                        {
                            au_regs_scaled[au_reg.Key] = 0;
                        }

                        if (au_regs_scaled[au_reg.Key] > 1)
                        {
                            au_regs_scaled[au_reg.Key] = 1;
                        }
                    }
                    auRegGraph.Update(au_regs_scaled);
                }

                if (ShowGeometry)
                {
                    int yaw = (int)(pose[4] * 180 / Math.PI + 0.5);
                    int roll = (int)(pose[5] * 180 / Math.PI + 0.5);
                    int pitch = (int)(pose[3] * 180 / Math.PI + 0.5);

                    YawLabel.Content = yaw + "°";
                    RollLabel.Content = roll + "°";
                    PitchLabel.Content = pitch + "°";

                    XPoseLabel.Content = (int)pose[0] + " mm";
                    YPoseLabel.Content = (int)pose[1] + " mm";
                    ZPoseLabel.Content = (int)pose[2] + " mm";

                    nonRigidGraph.Update(non_rigid_params);

                    // Update eye gaze
                    String x_angle = String.Format("{0:F0}°", gaze_angle.Item1 * (180.0 / Math.PI));
                    String y_angle = String.Format("{0:F0}°", gaze_angle.Item2 * (180.0 / Math.PI));
                    GazeXLabel.Content = x_angle;
                    GazeYLabel.Content = y_angle;
                }

                if (ShowTrackedVideo)
                {
                    if (new_image)
                    {
                        latest_img = frame.CreateWriteableBitmap();
                    }

                    frame.UpdateWriteableBitmap(latest_img);

                    overlay_image.Source = latest_img;
                    overlay_image.Confidence = confidence;
                    overlay_image.FPS = processing_fps.GetFPS();
                    overlay_image.Progress = progress;
                    overlay_image.FaceScale = scale;

                    if (!detection_succeeding)
                    {
                        overlay_image.OverlayLines.Clear();
                        overlay_image.OverlayPoints.Clear();
                        overlay_image.OverlayPointsVisibility.Clear();
                        overlay_image.OverlayEyePoints.Clear();
                        overlay_image.GazeLines.Clear();
                    }
                    else
                    {
                        List <Point> landmark_points = new List <Point>();
                        foreach (var p in landmarks)
                        {
                            landmark_points.Add(new Point(p.Item1, p.Item2));
                        }

                        List <Point> eye_landmark_points = new List <Point>();
                        foreach (var p in eye_landmarks)
                        {
                            eye_landmark_points.Add(new Point(p.Item1, p.Item2));
                        }


                        if (new_image)
                        {
                            overlay_image.OverlayLines = lines;
                            overlay_image.OverlayPoints = landmark_points;
                            overlay_image.OverlayPointsVisibility = visibilities;
                            overlay_image.OverlayEyePoints = eye_landmark_points;
                            overlay_image.GazeLines = gaze_lines;
                        }
                        else
                        {
                            // In case of multiple faces just add them to the existing drawing list
                            overlay_image.OverlayLines.AddRange(lines.GetRange(0, lines.Count));
                            overlay_image.OverlayPoints.AddRange(landmark_points.GetRange(0, landmark_points.Count));
                            overlay_image.OverlayPointsVisibility.AddRange(visibilities.GetRange(0, visibilities.Count));
                            overlay_image.OverlayEyePoints.AddRange(eye_landmark_points.GetRange(0, eye_landmark_points.Count));
                            overlay_image.GazeLines.AddRange(gaze_lines.GetRange(0, gaze_lines.Count));
                        }
                    }
                }

                if (ShowAppearance)
                {
                    RawImage aligned_face = face_analyser.GetLatestAlignedFace();
                    RawImage hog_face = visualizer.GetHOGVis();

                    if (latest_aligned_face == null)
                    {
                        latest_aligned_face = aligned_face.CreateWriteableBitmap();
                        latest_HOG_descriptor = hog_face.CreateWriteableBitmap();
                    }

                    aligned_face.UpdateWriteableBitmap(latest_aligned_face);
                    hog_face.UpdateWriteableBitmap(latest_HOG_descriptor);

                    AlignedFace.Source = latest_aligned_face;
                    AlignedHOG.Source = latest_HOG_descriptor;
                }
            }));
        }
Example #29
0
 /// <summary>
 /// Executes the NuGet Visualizer.
 /// </summary>
 private void Visualize(object sender, EventArgs e)
 {
     DTE2 dte = GetService(typeof(SDTE)) as DTE2;
     var soulution = dte.Solution;
     var packageInstaller = componentModel.GetService<IVsPackageInstallerServices>();
     var visualizer = new Visualizer(packageInstaller, soulution);
     string outputFile = visualizer.CreateGraph();
     dte.ItemOperations.OpenFile(outputFile);
 }
Example #30
0
        public void Do(Visualizer viz)
        {
            Object3D obj = viz.RetrieveObject(index);

            obj.Position = newPosition;
        }
Example #31
0
 public void RegisterVisualizer(Visualizer visualizer)
 {
     this.visualizers.Add(visualizer);
 }
Example #32
0
 void Awake()
 {
     _instance             = this;
     _lineRenderer         = this.GetComponent <LineRenderer>();
     _lineRenderer.enabled = false;
 }