private void RemoveGroupModel(object o)
 {
     if (GroupModelSource.Count > 0)
     {
         GroupModelSource.RemoveAt(GroupModelSource.Count - 1);
     }
 }
        private void AddGroupModel(object o)
        {
            var model = new MeshGeometryModel3D();

            model.Geometry  = SphereModel;
            model.Material  = BlueMaterial;
            model.Transform = new Media3D.TranslateTransform3D(0, (GroupModelSource.Count + 1) * 2, 0);
            GroupModelSource.Add(model);
        }
        public MainViewModel()
        {
            //    RenderTechniquesManager = new DefaultRenderTechniquesManager();
            EffectsManager = new DefaultEffectsManager();
            // ----------------------------------------------
            // titles
            this.Title    = "GroupElement Test";
            this.SubTitle = "WPF & SharpDX";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(10, 2, 10), LookDirection = new Vector3D(-10, -2, -10), UpDirection = new Vector3D(0, 1, 0)
            };

            var lineBuilder = new LineBuilder();

            lineBuilder.AddLine(new Vector3(0, 0, 0), new Vector3(10, 0, 0));
            lineBuilder.AddLine(new Vector3(0, 0, 0), new Vector3(0, 10, 0));
            lineBuilder.AddLine(new Vector3(0, 0, 0), new Vector3(0, 0, 10));
            AxisModel        = lineBuilder.ToLineGeometry3D();
            AxisModel.Colors = new Color4Collection(AxisModel.Positions.Count);
            AxisModel.Colors.Add(Colors.Red.ToColor4());
            AxisModel.Colors.Add(Colors.Red.ToColor4());
            AxisModel.Colors.Add(Colors.Green.ToColor4());
            AxisModel.Colors.Add(Colors.Green.ToColor4());
            AxisModel.Colors.Add(Colors.Blue.ToColor4());
            AxisModel.Colors.Add(Colors.Blue.ToColor4());

            AxisLabel = new BillboardText3D();
            AxisLabel.TextInfo.Add(new TextInfo()
            {
                Origin = new Vector3(11, 0, 0), Text = "X", Foreground = Colors.Red.ToColor4()
            });
            AxisLabel.TextInfo.Add(new TextInfo()
            {
                Origin = new Vector3(0, 11, 0), Text = "Y", Foreground = Colors.Green.ToColor4()
            });
            AxisLabel.TextInfo.Add(new TextInfo()
            {
                Origin = new Vector3(0, 0, 11), Text = "Z", Foreground = Colors.Blue.ToColor4()
            });

            var meshBuilder = new MeshBuilder(true);

            meshBuilder.AddSphere(new Vector3(0, 0, 0), 0.5);
            SphereModel = meshBuilder.ToMesh();
            meshBuilder = new MeshBuilder(true);
            meshBuilder.AddBox(Vector3.Zero, 0.5, 0.5, 0.5);
            BoxModel    = meshBuilder.ToMesh();
            meshBuilder = new MeshBuilder(true);
            meshBuilder.AddCone(Vector3.Zero, new Vector3(0, 2, 0), 1, true, 24);
            ConeModel = meshBuilder.ToMesh();

            AddGroupModelCommand               = new RelayCommand(AddGroupModel);
            RemoveGroupModelCommand            = new RelayCommand(RemoveGroupModel);
            AddTransparentGroupModelCommand    = new RelayCommand(AddTransparentMesh);
            RemoveTransparentGroupModelCommand = new RelayCommand(RemoveTransparentModel);
            ClearGroupModelCommand             = new RelayCommand((o) => { GroupModelSource.Clear(); });
            AnimateGroupModelCommand           = new RelayCommand(AnimateGroupModel);
            AddItemsModelCommand               = new RelayCommand(AddItemsModel);
            RemoveItemsModelCommand            = new RelayCommand(RemoveItemsModel);
            ClearItemsModelCommand             = new RelayCommand((o) => { ItemsSource.Clear(); });
            AnimateItemsModelCommand           = new RelayCommand(AnimateItemsModel);
        }