示例#1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Trackball setup
            _trackball = new Trackball();
            _trackball.Attach(this);
            _trackball.Slaves.Add(_viewport3D);
            _trackball.Enabled = true;

            if (this.ItemsSource is ChartPlanes)
            {
                _planes = this.ItemsSource as ChartPlanes;
            }
            else
            {
                return;
            }

            // Add 3D model Content
            _viewport3D.Children.Clear();

            _modelGroup = new Model3DGroup();

            ScaleTransform3D      GroupScaleTransform     = new ScaleTransform3D(new Vector3D(0.74, 1, 1));
            RotateTransform3D     GroupRotateTransform    = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0), new Point3D(0, 0, 0));
            TranslateTransform3D  GroupTranslateTransform = new TranslateTransform3D(new Vector3D(0, 0, 0));
            Transform3DCollection tcollection             = new Transform3DCollection();

            tcollection.Add(GroupScaleTransform);
            tcollection.Add(GroupRotateTransform);
            tcollection.Add(GroupTranslateTransform);
            Transform3DGroup tGroupDefault = new Transform3DGroup();

            tGroupDefault.Children = tcollection;
            _modelGroup.Transform  = tGroupDefault;


            Model3DGroup submodelGroup = new Model3DGroup();

            submodelGroup.Children.Add(new AmbientLight(Colors.White));
            _modelGroup.Children.Add(submodelGroup);

            ModelVisual3D mv3d = new ModelVisual3D();

            GroupScaleTransform     = new ScaleTransform3D(new Vector3D(1, 1, 1));
            GroupRotateTransform    = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0), new Point3D(0, 0, 0));
            GroupTranslateTransform = new TranslateTransform3D(new Vector3D(0, 0, 0));
            tcollection             = new Transform3DCollection();
            tcollection.Add(GroupScaleTransform);
            tcollection.Add(GroupRotateTransform);
            tcollection.Add(GroupTranslateTransform);
            tGroupDefault          = new Transform3DGroup();
            tGroupDefault.Children = tcollection;
            mv3d.Transform         = tGroupDefault;
            mv3d.Content           = _modelGroup;

            _viewport3D.Children.Add(mv3d);
        }
示例#2
0
 private void OnInitialized(object sender, EventArgs e)
 {
     //init the items collection
     _planes = new ChartPlanes();
 }