Beispiel #1
0
        public Window1()
        {
            InitializeComponent();

            Flickr.Initialize();

            cv = new PhotoCarouselView();
            ps = new PhotoStack3D();

            Transform3DGroup cvTG = new Transform3DGroup();
            cvTG.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 5)));
            cvTG.Children.Add(new TranslateTransform3D(0, 0, -1));
            cv.Transform = cvTG;

            Transform3DGroup tg = new Transform3DGroup();
            tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -13)));
            tg.Children.Add(new TranslateTransform3D(0, ps.Height / 2, -1.2));
            ps.Transform = tg;

            MainViewport.Children.Add(cv);
            MainViewport.Children.Add(ps);

            cv.ItemClickedOn += new PhotoBrowser.CarouselView.CarouselView.ItemClickedOnEvent(cv_ItemClickedOn);
            cv.GeoLocationAvailable += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationAvailable);
            cv.GeoLocationHidden += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationHidden);

            ps.GeoLocationSelected += new PhotoStack3D.GeoLocationSelectedDelegate(ps_GeoLocationSelected);
            ps.SelectionChanged += new PhotoBrowser.Stack3D.Stack3D.StackSelectionChangedEvent(ps_SelectionChanged);
            ps.BlogRequested += new PhotoStack3D.BlogRequestedDelegate(ps_BlogRequested);

            // create the globe we'll use
            earth = new InteractiveSphere();
            mapVisual = new MapVisual();
            mapVisual.searchMenuItem.Click += new RoutedEventHandler(searchMenuItem_Click);
            earth.Visual = mapVisual;

            // create the transformation applied to the globe
            earthTransform = new Transform3DGroup();
            Point3D earthPos = new Point3D(-0.2, 0.05, -1.1);
            Vector3D earthToCam = new Vector3D(0 - earthPos.X,
                                               0 - earthPos.Y,
                                               0 - earthPos.Z);
            earthToCam.Normalize();

            earthTransform.Children.Add(new ScaleTransform3D(0.0, 0.0, 0.0));
            _myQuaternionRotLong = new QuaternionRotation3D(new Quaternion(new Vector3D(0, 1, 0), 0));
            _myQuaternionRotLat = new QuaternionRotation3D(new Quaternion(new Vector3D(1, 0, 0), 0));

            earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLong));
            earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLat));
            earthTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0),
                                        Math.Acos(Vector3D.DotProduct(new Vector3D(0, 0, 1), earthToCam)) / Math.PI * 180)));

            earthTransform.Children.Add(new TranslateTransform3D((Vector3D)earthPos));
            earth.Transform = earthTransform;

            // add in the earth
            HookUpEarthEvents();
        }
Beispiel #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;
            }
        }