Beispiel #1
0
 public void Remove(CameraPoolVisual visual)
 {
     //  The visual is in all the viewports
     foreach (TaskWrapper task in _tasks)
     {
         task.AddRemoves.Enqueue(new Tuple <object, bool>(visual, false));
     }
 }
Beispiel #2
0
 //NOTE: Lights can be added as well with this method
 public void Add(CameraPoolVisual visual)
 {
     //  A visual will be added to all the viewports
     foreach (TaskWrapper task in _tasks)
     {
         task.AddRemoves.Enqueue(new Tuple <object, bool>(visual, true));
     }
 }
Beispiel #3
0
 //NOTE: Lights can be added as well with this method
 public void Add(CameraPoolVisual visual)
 {
     //  A visual will be added to all the viewports
     foreach (TaskWrapper task in _tasks)
     {
         task.AddRemoves.Enqueue(new Tuple<object, bool>(visual, true));
     }
 }
Beispiel #4
0
 public void Remove(CameraPoolVisual visual)
 {
     //  The visual is in all the viewports
     foreach (TaskWrapper task in _tasks)
     {
         task.AddRemoves.Enqueue(new Tuple<object, bool>(visual, false));
     }
 }
        private void AddVisual(Model3D model)
        {
            #region Standard

            ModelVisual3D visual = new ModelVisual3D();
            visual.Content = model;

            _visuals.Add(visual);
            _viewport.Children.Add(visual);

            #endregion

            #region Offline 1

            if (_offline1 == null)
            {
                Brush background = null;
                if (radSceneBlack.IsChecked.Value)
                {
                    background = Brushes.Black;
                }
                else if (radSceneTransparent.IsChecked.Value)
                {
                    background = Brushes.Transparent;
                }
                else
                {
                    throw new ApplicationException("Unknown background color");
                }

                _offline1 = new ViewportOffline(background);

                radSceneBlack.IsEnabled = false;        //  crude, but I don't want to listen to events
                radSceneTransparent.IsEnabled = false;
            }

            visual = new ModelVisual3D();
            visual.Content = model;

            _offline1.Visuals.Add(visual);
            _offline1.Viewport.Children.Add(visual);

            #endregion

            #region Camera Pool

            //  Create pool
            if (_cameraPool == null)
            {
                _cameraPool = new CameraPool(1, radSceneBlack.IsChecked.Value ? Colors.Black : Colors.Transparent);
            }

            //  Serialize model
            byte[] modelBytes = null;

            using (MemoryStream stream = new MemoryStream())
            {
                XamlServices.Save(stream, model);
                stream.Position = 0;

                modelBytes = stream.ToArray();
            }

            CameraPoolVisual poolVisual = new CameraPoolVisual(TokenGenerator.NextToken(), modelBytes, null);

            //  Add it
            _cameraPoolVisuals.Add(poolVisual);
            _cameraPool.Add(poolVisual);

            #endregion
        }