Beispiel #1
0
        public bool NetHandle_FrameDataV2_Names(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Names [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    int instID      = c.ReadInt32();
                    string instName = c.ReadString();
                    foreach (var item in MeshGrid.Items)
                    {
                        MeshObject mo = item as MeshObject;
                        if (mo != null && mo.InstID == instID)
                        {
                            mo.Name = instName;
                        }
                    }
                }

                MeshGrid.Items.Refresh();
            }));

            return(true);
        }
Beispiel #2
0
 private void HighlightMeshByMaterial(MaterialObject material, Color c)
 {
     foreach (var item in MeshGrid.Items)
     {
         MeshObject mo = item as MeshObject;
         if (mo != null && material.RefList.Contains(mo.InstID))
         {
             DataGridUtil.MarkAsHighlighted(MeshGrid, item, c);
         }
     }
 }
 private List<MaterialObject> HighlightMaterialByMesh(MeshObject mesh, Color c)
 {
     List<MaterialObject> highlighted = new List<MaterialObject>();
     foreach (var item in MaterialGrid.Items)
     {
         MaterialObject mo = item as MaterialObject;
         if (mo != null && mo.RefList.Contains(mesh.InstID))
         {
             DataGridUtil.MarkAsHighlighted(MaterialGrid, item, c);
             highlighted.Add(mo);
         }
     }
     return highlighted;
 }
Beispiel #4
0
        private void NetRequest_FlyToMesh(MeshObject mesh)
        {
            if (mesh == null)
            {
                ModernDialog.ShowMessage("请先选中一个 Mesh", "定位", MessageBoxButton.OK);
                return;
            }

            UsCmd cmd = new UsCmd();

            cmd.WriteNetCmd(eNetCmd.CL_FlyToObject);
            cmd.WriteInt32(mesh.InstID);
            AppNetManager.Instance.Send(cmd);
        }
Beispiel #5
0
        private List <MaterialObject> HighlightMaterialByMesh(MeshObject mesh, Color c)
        {
            List <MaterialObject> highlighted = new List <MaterialObject>();

            foreach (var item in MaterialGrid.Items)
            {
                MaterialObject mo = item as MaterialObject;
                if (mo != null && mo.RefList.Contains(mesh.InstID))
                {
                    DataGridUtil.MarkAsHighlighted(MaterialGrid, item, c);
                    highlighted.Add(mo);
                }
            }
            return(highlighted);
        }
Beispiel #6
0
        private List <MeshObject> HighlightMeshes(List <int> selection, Color c)
        {
            List <MeshObject> highlighted = new List <MeshObject>();

            foreach (var item in MeshGrid.Items)
            {
                MeshObject mo = item as MeshObject;
                if (mo != null && selection.Contains(mo.InstID))
                {
                    DataGridUtil.MarkAsHighlighted(MeshGrid, item, c);
                    highlighted.Add(mo);
                }
            }
            return(highlighted);
        }
Beispiel #7
0
        private void MeshGrid_OnVisibleChecked(object sender, EventArgs e)
        {
            CheckBox cb = sender as CheckBox;

            MeshObject mo = MeshGrid.SelectedItem as MeshObject;

            if (mo == null)
            {
                return;
            }

            if (mo.Name == null)    // is in initialization process
            {
                return;
            }

            NetManager.Instance.ExecuteCmd(string.Format("{0} {1}", ((bool)cb.IsChecked ? "showmesh" : "hidemesh"), mo.InstID));
        }
Beispiel #8
0
        private bool NetHandle_FrameDataV2_Meshes(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Meshes [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    var m     = new MeshObject();
                    m.InstID  = c.ReadInt32();
                    m.VertCnt = c.ReadInt32();
                    m.TriCnt  = c.ReadInt32();
                    m.MatCnt  = c.ReadInt32();
                    m.Size    = c.ReadFloat();
                    ((ObservableCollection <MeshObject>)(MeshGrid.DataContext)).Add(m);
                }
            }));

            return(true);
        }
Beispiel #9
0
        private bool NetHandle_FrameData_Mesh(eNetCmd cmd, UsCmd c)
        {
            short subCmd = c.ReadInt16();

            switch ((eSubCmd_TransmitStage)subCmd)
            {
            case eSubCmd_TransmitStage.DataBegin:
            {
                MeshGrid.Dispatcher.Invoke(new Action(() =>
                    {
                        if (_meshes == null)
                        {
                            _meshes = new ObservableCollection <MeshObject>();
                        }
                        else
                        {
                            _meshes.Clear();
                        }
                        _meshExpectedCount = c.ReadInt32();
                        UsLogging.Printf("eNetCmd.NetHandle_FrameData_Mesh [b](DataBegin)[/b] ({0}).", _meshExpectedCount);
                    }));
            }
            break;

            case eSubCmd_TransmitStage.DataSlice:
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameData_Mesh [b](DataSlice)[/b] ({0}).", count);
                if (count > 0)
                {
                    MeshGrid.Dispatcher.Invoke(new Action(() =>
                        {
                            for (int i = 0; i < count; i++)
                            {
                                var m     = new MeshObject();
                                m.InstID  = c.ReadInt32();
                                m.Name    = c.ReadString();
                                m.VertCnt = c.ReadInt32();
                                m.MatCnt  = c.ReadInt32();
                                m.Size    = (float)c.ReadFloat();
                                _meshes.Add(m);
                            }
                        }));
                }
            }
            break;

            case eSubCmd_TransmitStage.DataEnd:
            {
                UsLogging.Printf("eNetCmd.NetHandle_FrameData_Mesh [b](DataEnd)[/b] (expected: {0} actual: {1}).", _meshExpectedCount, _meshes.Count);
                if (_meshExpectedCount != _meshes.Count)
                {
                    UsLogging.Printf(LogWndOpt.Bold, "The actually received mesh count is mismatched with expected.");
                }

                MeshGrid.Dispatcher.Invoke(new Action(() =>
                    {
                        title_mesh.Text      = string.Format("Meshes ({0})", _meshes.Count);
                        MeshGrid.DataContext = _meshes;
                    }));
            }
            break;

            default:
                break;
            }
            return(true);
        }
Beispiel #10
0
        public void NetRequest_FlyToMesh(MeshObject mesh)
        {
            if (mesh == null)
            {
                ModernDialog.ShowMessage("请先选中一个 Mesh", "定位", MessageBoxButton.OK);
                return;
            }

            UsCmd cmd = new UsCmd();
            cmd.WriteNetCmd(eNetCmd.CL_FlyToObject);
            cmd.WriteInt32(mesh.InstID);
            NetManager.Instance.Send(cmd);
        }
Beispiel #11
0
        public bool NetHandle_FrameDataV2_Meshes(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Meshes [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    var m = new MeshObject();
                    m.Visible = true;
                    m.InstID = c.ReadInt32();
                    m.VertCnt = c.ReadInt32();
                    m.TriCnt = c.ReadInt32();
                    m.MatCnt = c.ReadInt32();
                    m.Size = c.ReadFloat();
                    ((ObservableCollection<MeshObject>)(MeshGrid.DataContext)).Add(m);
                }
            }));

            return true;
        }