Пример #1
0
        /// <summary>
        /// Creates a new carousel view
        /// </summary>
        public CarouselView()
        {
            RowPadding = 0.01;
            ColumnPadding = 0.01;

            holderVisual = new ModelVisual3D();
            this.Children.Add(holderVisual);

            viewController = new PartialSphere(220, -80, 89, 2, 10, 10, false);

            slider = new Slider();
            slider.Width = 800;
            slider.Background = Brushes.Transparent;
            slider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(slider_ValueChanged);

            viewController.Visual = slider;
            viewController.Transform = new TranslateTransform3D(0,
                                            0.5 * (finalMeshWidth * Rows + RowPadding * (Rows - 1)) + 3 * RowPadding, 0);

            slider.IsMouseCaptureWithinChanged += new DependencyPropertyChangedEventHandler(slider_IsMouseCaptureWithinChanged);
        }
Пример #2
0
        public void outerGridKeyDown(Object sender, KeyEventArgs e)
        {
            InteractiveVisual3D newVis = null;

            // figure out what mesh is requested
            if (e.Key == Key.F2)
            {
                newVis = reallyFakeIV3D;
            }
            else if (e.Key == Key.F3)
            {
                newVis = new PartialSphere(0, 360, 60, 60, 30, 30, false);
            }
            else if (e.Key == Key.F4)
            {
                newVis = new InteractiveSphere();
            }
            else if (e.Key == Key.F5)
            {
                newVis = new InteractiveCylinder();
            }
            else if (e.Key == Key.F6)
            {
                newVis = new InteractiveCone();
            }

            // add it to the scene
            if (newVis != null)
            {
                Visual oldVisual;
                if (cachedNewVis == null) { oldVisual = reallyFakeIV3D.Visual; reallyFakeIV3D.Visual = null; }
                else { oldVisual = cachedNewVis.Visual; cachedNewVis.Visual = null; }

                newVis.Visual = oldVisual;

                if (cachedNewVis != null)
                {
                    MainViewportOuter.Children.Remove(cachedNewVis);
                }
                else
                {
                    MainViewportOuter.Children.Remove(reallyFakeIV3D);
                    oldCameraTransform = MainViewportOuter.Camera.Transform;
                    twoAxisValuator.Enabled = true;
                }

                MainViewportOuter.Children.Add(newVis);

                //transform
                if (newVis == reallyFakeIV3D)
                {
                    MainViewportOuter.Camera.Transform = oldCameraTransform;
                    twoAxisValuator.Enabled = false;
                }
                else
                {
                    Transform3DGroup tgroup = new Transform3DGroup();
                    tgroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 15)));
                    tgroup.Children.Add(new ScaleTransform3D(0.68, 0.68, 0.68));
                    twoAxisValuator.Up = new Vector3D(0, Math.Cos(15 * Math.PI / 180), Math.Sin(15 * Math.PI / 180));
                    newVis.Transform = tgroup;
                }

                if (newVis == reallyFakeIV3D)
                {
                    cachedNewVis = null;
                }
                else
                {
                    cachedNewVis = newVis;
                }

                e.Handled = true;
            }
        }