Represents a visual element that shows translation and rotation manipulators.
Inheritance: System.Windows.Media.Media3D.ModelVisual3D
コード例 #1
0
        private void AllFramesModeButton_Click(object sender, RoutedEventArgs e)
        {
            HelixViewportLeft.Children.Remove(FrameStartEulerManipulator);
            HelixViewportLeft.Children.Remove(FrameEndEulerManipulator);
            HelixViewportRight.Children.Remove(FrameStartQuaternionManipulator);
            HelixViewportRight.Children.Remove(FrameEndQuaternionManipulator);

            PlayButton.IsEnabled = false;
            PauseButton.IsEnabled = false;
            ResetButton.IsEnabled = false;
            FramesCountBox.IsEnabled = false;
            AllFramesModeButton.IsEnabled = false;
            AllFramesModeClearButton.IsEnabled = true;

            if (FramesCount < 2)
                FramesCount = 2;

            allFramesEuler = new CombinedManipulator[FramesCount];
            allFramesQuaternion = new CombinedManipulator[FramesCount];

            CalibrateEulerAngles();
            for (int i = 0; i < FramesCount; i++)
            {
                var timeFactor = i / (FramesCount - 1.0);
                CalculateCurrentPosition(timeFactor);
                CalculateCurrentAngle(timeFactor);
                CalculateCurrentQuaternion(timeFactor);
                SetupCurrentConfiguration();

                allFramesEuler[i] = new CombinedManipulator()
                {
                    Transform = new MatrixTransform3D(frameEuler.Transform.Value),
                    CanRotateX = false,
                    CanRotateY = false,
                    CanRotateZ = false
                };
                allFramesQuaternion[i] = new CombinedManipulator()
                {
                    Transform = new MatrixTransform3D(frameQuaternion.Transform.Value),
                    CanRotateX = false,
                    CanRotateY = false,
                    CanRotateZ = false
                };

                HelixViewportLeft.Children.Add(allFramesEuler[i]);
                HelixViewportRight.Children.Add(allFramesQuaternion[i]);
            }
        }
コード例 #2
0
ファイル: JointMover.cs プロジェクト: loic-lavergne/mckineap
        /// <summary>
        /// Draw a manipulator over the specified model3D
        /// </summary>
        /// <param name="m3D">Model 3D</param>
        public void DrawManipulators(System.Windows.Media.Media3D.Model3D m3D)
        {
            Rect3D r = m3D.Bounds;

            if (Session.CurrentSession.ModelVisual.Children.Contains(manipulator))
            {
                Session.CurrentSession.ModelVisual.Children.Remove(manipulator);
                manipulator = new CombinedManipulator();
            }

            manipulator.CanRotateX = false;
            manipulator.CanRotateY = false;
            manipulator.CanRotateZ = false;

            manipulator.Position = new Point3D(r.X, r.Y, r.Z);
            manipulator.Offset = new Vector3D((r.SizeX / 2), (r.SizeY / 2), (r.SizeZ / 2));
            //manipulator.Pivot = new Point3D((r.SizeX / 2), (r.SizeY / 2), (r.SizeZ / 2));
            manipulator.Diameter = Math.Max(r.SizeX, Math.Max(r.SizeY, r.SizeZ)) * 1.2;
            
            Session.CurrentSession.ModelVisual.Children.Add(manipulator);
        }
コード例 #3
0
        private void InitializeScene()
        {
            linearInterpolator = new LinearInterpolator();
            sphericalLinearInterpolator = new SphericalLinearInterpolator();
            realTimeInterpolator = new RealTimeInterpolator();

            const double maxVal = 8;

            var arrowX = new ArrowVisual3D();
            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1 = new Point3D(0, 0, 0);
            arrowX.Point2 = new Point3D(maxVal, 0, 0);
            arrowX.Diameter = 0.1;
            arrowX.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowX);

            arrowX = new ArrowVisual3D();
            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1 = new Point3D(0, 0, 0);
            arrowX.Point2 = new Point3D(maxVal, 0, 0);
            arrowX.Diameter = 0.1;
            arrowX.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowX);

            var arrowMX = new ArrowVisual3D();
            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1 = new Point3D(0, 0, 0);
            arrowMX.Point2 = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter = 0.1;
            arrowMX.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMX);

            arrowMX = new ArrowVisual3D();
            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1 = new Point3D(0, 0, 0);
            arrowMX.Point2 = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter = 0.1;
            arrowMX.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMX);

            var arrowY = new ArrowVisual3D();
            arrowY.Direction = new Vector3D(0, 1, 0);
            arrowY.Point1 = new Point3D(0, 0, 0);
            arrowY.Point2 = new Point3D(0, maxVal, 0);
            arrowY.Diameter = 0.1;
            arrowY.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowY);

            arrowY = new ArrowVisual3D();
            arrowY.Direction = new Vector3D(0, 1, 0);
            arrowY.Point1 = new Point3D(0, 0, 0);
            arrowY.Point2 = new Point3D(0, maxVal, 0);
            arrowY.Diameter = 0.1;
            arrowY.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowY);

            var arrowMY = new ArrowVisual3D();
            arrowMY.Direction = new Vector3D(0, -1, 0);
            arrowMY.Point1 = new Point3D(0, 0, 0);
            arrowMY.Point2 = new Point3D(0, -maxVal, 0);
            arrowMY.Diameter = 0.1;
            arrowMY.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMY);

            arrowMY = new ArrowVisual3D();
            arrowMY.Direction = new Vector3D(0, -1, 0);
            arrowMY.Point1 = new Point3D(0, 0, 0);
            arrowMY.Point2 = new Point3D(0, -maxVal, 0);
            arrowMY.Diameter = 0.1;
            arrowMY.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMY);

            var arrowZ = new ArrowVisual3D();
            arrowZ.Direction = new Vector3D(0, 0, 1);
            arrowZ.Point1 = new Point3D(0, 0, 0);
            arrowZ.Point2 = new Point3D(0, 0, maxVal);
            arrowZ.Diameter = 0.1;
            arrowZ.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowZ);

            arrowZ = new ArrowVisual3D();
            arrowZ.Direction = new Vector3D(0, 0, 1);
            arrowZ.Point1 = new Point3D(0, 0, 0);
            arrowZ.Point2 = new Point3D(0, 0, maxVal);
            arrowZ.Diameter = 0.1;
            arrowZ.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowZ);

            var arrowMZ = new ArrowVisual3D();
            arrowMZ.Direction = new Vector3D(0, 0, -1);
            arrowMZ.Point1 = new Point3D(0, 0, 0);
            arrowMZ.Point2 = new Point3D(0, 0, -maxVal);
            arrowMZ.Diameter = 0.1;
            arrowMZ.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMZ);

            arrowMZ = new ArrowVisual3D();
            arrowMZ.Direction = new Vector3D(0, 0, -1);
            arrowMZ.Point1 = new Point3D(0, 0, 0);
            arrowMZ.Point2 = new Point3D(0, 0, -maxVal);
            arrowMZ.Diameter = 0.1;
            arrowMZ.Fill = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMZ);

            var xArrowText = new TextVisual3D();
            xArrowText.Text = "X";
            xArrowText.Position = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(xArrowText);

            xArrowText = new TextVisual3D();
            xArrowText.Text = "X";
            xArrowText.Position = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(xArrowText);

            var yArrowText = new TextVisual3D();
            yArrowText.Text = "Y";
            yArrowText.Position = new Point3D(0, maxVal - 0.5, 0.5);
            yArrowText.Height = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(yArrowText);

            yArrowText = new TextVisual3D();
            yArrowText.Text = "Y";
            yArrowText.Position = new Point3D(0, maxVal - 0.5, 0.5);
            yArrowText.Height = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(yArrowText);

            var zArrowText = new TextVisual3D();
            zArrowText.Text = "Z";
            zArrowText.Position = new Point3D(0.5, 0, maxVal - 0.5);
            zArrowText.Height = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(zArrowText);

            zArrowText = new TextVisual3D();
            zArrowText.Text = "Z";
            zArrowText.Position = new Point3D(0.5, 0, maxVal - 0.5);
            zArrowText.Height = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(zArrowText);

            var leftText = new TextVisual3D();
            leftText.Text = "Internal Coordinates Interpolation";
            leftText.Position = new Point3D(0, 0, maxVal + 0.5);
            leftText.Height = 1;
            leftText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(leftText);

            var rightText = new TextVisual3D();
            rightText.Text = "Effector Position Interpolation";
            rightText.Position = new Point3D(0, 0, maxVal + 0.5);
            rightText.Height = 1;
            rightText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(rightText);

            SetupStartConfiguration();
            SetupEndConfiguration();

            frameEuler = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };
            robotForInternalCoordinates.SetMidFrameModel(frameEuler);

            frameQuaternion = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: Arkady92/VR
        private void InitializeScene()
        {
            limitationsCuboid = new RoomVisual3D();
            limitationsCuboid.Initialize(20.0);
            limitationsCuboid.IsDampingActive = Damping;

            bezierCube = new BezierCubeVisual3D();
            bezierCube.Initialize(cubeSize);
            bezierCube.CollisionChecker = limitationsCuboid;
            bezierCube.IsDampingActive = Damping;

            spherePoints = new PointsVisual3D();
            spherePoints.Points = bezierCube.GetSpherePoints();
            spherePoints.Size = 3;

            if (DeformedSolidEnabled)
                HelixViewport.Children.Add(spherePoints);

            if (ControlPointsEnabled)
            {
                HelixViewport.Children.Add(bezierCube.points);
                HelixViewport.Children.Add(bezierCube.lines);
            }

            steeringFrame = new FrameVisual3D();
            steeringFrame.Initialize(cubeSize);
            if (SteeringFrameEnabled)
            {
                HelixViewport.Children.Add(steeringFrame.points);
                HelixViewport.Children.Add(steeringFrame.lines);
                HelixViewport.Children.Add(steeringFrame.GetJointsPoints(bezierCube.GetCornerPoints()));
            }
            manipulator = new CombinedManipulator();
            manipulator.Diameter = 3;
            manipulator.Offset = new Vector3D(0, 0, 5);
            HelixViewport.Children.Add(manipulator);

            //geometry = new MeshGeometryVisual3D();
            //var builder = new MeshBuilder(false, false);
            //builder.AddTriangles(bezierCube.GetSpherePoints());
            //geometry.MeshGeometry = builder.ToMesh(true);
            //HelixViewport.Children.Add(geometry);

            surfaces = new BezierSurface[6];
            for (int i = 0; i < 6; i++)
            {
                surfaces[i] = new BezierSurface()
                {
                    Fill = Brushes.Red,
                    MeshSizeU = 20,
                    MeshSizeV = 20
                };
                surfaces[i].UpdateSurface(bezierCube.GetFaceControlPoints(i));
                surfaces[i].UpdateModel();
                if (BezierCubeEnabled)
                    HelixViewport.Children.Add(surfaces[i]);
            }
            //limitationsCuboid.UpdateViewport(HelixViewport);
        }
コード例 #5
0
        public void displayManipulator()
        {
            this.parent.cleanManipulator();
            if (_manipulator == null)
            {
                Rect3D r = this.Content.Bounds;
                _manipulator = new CombinedManipulator();
                //_manipulator.Position = new Point3D(r.X + (r.SizeX/2),r.Y + (r.SizeY / 2),r.Z + (r.SizeZ/2));
                _manipulator.Offset = new Vector3D(r.X + (r.SizeX / 2), r.Y + (r.SizeY / 2), r.Z + (r.SizeZ / 2));
                _manipulator.Pivot = new Point3D(r.X + (r.SizeX / 2), r.Y + (r.SizeY / 2), r.Z + (r.SizeZ / 2));
                //_manipulator.Pivot = new Point3D(0, 0, 0);
                _manipulator.Diameter = Math.Max(r.SizeX, Math.Max(r.SizeY, r.SizeZ)) + 1;
                _manipulator.Length = _manipulator.Diameter * 0.75;
                _manipulator.Bind(this);
                Bind(_manipulator);

                //addTeethRoot();
                //test
                //MeshGeometry3D mesh = GetMesh();
                //drawBorderEdges(mesh);
            }
            tc.Children.Add(_manipulator);

        }
コード例 #6
0
        internal void cleanManipulator()
        {
            //Remove all Tooth manipulators
            List<Visual3D> childs = tc.Children.ToList();
            foreach (var m in childs)
            {
                if (m is CombinedManipulator)
                {
                    tc.Children.Remove(m);
                }
            }

            try
            {
                //Remove all Brace manipulators
                childs = bc.Children.ToList();
                foreach (var m in childs)
                {
                    if (m is BraceVisual3D)
                    {
                        ((BraceVisual3D)m).cleanManipulator();
                    }
                }

            }
            catch (Exception e) { }
            //this.parent.Children.Remove(_manipulator);
            _manipulator = null;
        }
コード例 #7
0
        /// <summary>
        /// @Deprecated
        /// Not used anymore since changes in CONTAINER design.
        /// <see cref="cleanManipulator"/>
        /// </summary>
        internal void clearManipulator()
        {
            if (this.parent.Children.Count > 0)
            {
                List<Visual3D> childs = this.parent.Children.ToList();
                foreach (var m in childs)
                {
                    if (m is CombinedManipulator)
                    {
                        this.parent.Children.Remove(m);
                    }
                }            

                try
                {
                    childs = this.Children.ToList();
                    foreach (var m in childs)
                    {
                        if (m is BraceVisual3D)
                        {
                            ((BraceVisual3D)m).clearManipulator();
                        }
                    }

                }
                catch (Exception e) { }
            }
            //this.parent.Children.Remove(_manipulator);
            _manipulator = null;
        }
コード例 #8
0
 /// <summary>
 /// @Deprecated
 /// Not used anymore since changes in CONTAINER design.
 /// <see cref="displayManipulator"/>
 /// </summary>
 public void showHideManipulator()
 {
     this.parent.clearManipulator();
     if (_manipulator == null)
     {
         Rect3D r = this.Content.Bounds;
         _manipulator = new CombinedManipulator();
         //_manipulator.Position = new Point3D(r.X + (r.SizeX/2),r.Y + (r.SizeY / 2),r.Z + (r.SizeZ/2));
         _manipulator.Offset = new Vector3D(r.X + (r.SizeX / 2), r.Y + (r.SizeY / 2), r.Z + (r.SizeZ / 2));
         _manipulator.Pivot = new Point3D(r.X + (r.SizeX / 2), r.Y + (r.SizeY / 2), r.Z + (r.SizeZ / 2));
         //_manipulator.Pivot = new Point3D(0, 0, 0);
         _manipulator.Diameter = Math.Max(r.SizeX, Math.Max(r.SizeY, r.SizeZ)) + 1;
         _manipulator.Length = _manipulator.Diameter * 0.75;
         _manipulator.Bind(this);
         Bind(_manipulator);
     }
     this.parent.Children.Add(_manipulator);
 }
コード例 #9
0
        /// <summary>
        /// @Deprecated
        /// Not used anymore since changes in CONTAINER design.
        /// <see cref="cleanManipulator"/>
        /// </summary>
        internal void clearManipulator()
        {
            List<Visual3D> childs = this.brace1.Children.ToList();
            foreach (var m in childs)
            {
                if (m is CombinedManipulator)
                {
                    this.brace1.Children.Remove(m);
                }
            }

            childs = this.Children.ToList();
            foreach (var m in childs)
            {
                if (m is BraceVisual3D)
                {
                    ((BraceVisual3D)m).clearManipulator();
                }
            }

            //this.parent.Children.Remove(_manipulator);
            _manipulator = null;
        }
コード例 #10
0
ファイル: JointMover.cs プロジェクト: loic-lavergne/mckineap
 /// <summary>
 /// Constructor
 /// </summary>
 public JointMover()
 {
     manipulator = new CombinedManipulator();
 }
コード例 #11
0
        //==============using Container ==========

        public void cleanManipulator()
        {
            List<Visual3D> childs = bc.Children.ToList();
            foreach (var m in childs)
            {
                if (m is CombinedManipulator)
                {
                    bc.Children.Remove(m);
                }
            }
            _manipulator = null;
        }
コード例 #12
0
 /// <summary>
 /// @Deprecated
 /// Will be removed soon.
 /// <see cref="cleanManipulator"/>
 /// </summary>
 public void clearManipulator()
 {
     List<Visual3D> childs = this.parent.Children.ToList();
     foreach (var m in childs)
     {
         if (m is CombinedManipulator)
         {
             this.parent.Children.Remove(m);
         }
     }
     
     //this.parent.Children.Remove(_manipulator);
     _manipulator = null;
 }
コード例 #13
0
        private void backup_alignObject_Click(object sender, RoutedEventArgs e)
        {
            if (alignObjectBool)
            {
                //ModelVisual3D m = new ModelVisual3D();
                //m.Content = vmodel.Content.Clone();

                //view1.Children.Clear();
                //view1.Children.Add(m);
                alignObjectBool = false;
            }
            else
            {
                alignObjectBool = true;
                Model3DGroup d = (Model3DGroup)vm.CurrentModel;

                if (d != null)
                {
                    Rect3D r = d.Bounds;
                    RotateTransform3D rt = new RotateTransform3D();
                    Console.WriteLine("rect3D:" + r.X + "," + r.Y + "," + r.Z);
                    Console.WriteLine("rect3D:" + r.SizeX + "," + r.SizeY + "," + r.SizeZ);
                    //rect3D:105.253304,-5.142087,17.12525
                    //rect3D:64.387794,75.531301,78.013559

                    CombinedManipulator vModelManipulator = new CombinedManipulator();
                    vModelManipulator.Diameter = r.SizeX;
                    vmodel.Content = vm.CurrentModel;
                    vModelManipulator.Bind(vmodel);
                    //view1.Children.Clear();
                    view1.Children.Add(vModelManipulator);
                }
            }            
        }
コード例 #14
0
        private void manip(object sender, MouseButtonEventArgs e)
        {
            var pt = view1.FindNearestPoint(e.GetPosition(view1));
            if (cutLineBool && pt != null)
            {
                Point3D endPoint = pt.Value;


                Model3D d = vm.CurrentModel;

                //var position = new Point3D(startPoint.Y + ((endPoint.Y - startPoint.Y) / 2), startPoint.X, startPoint.Z);
                //Vector3D v = (endPoint - startPoint);
                var position = startPoint + (endPoint - startPoint) * 0.5;
                //var position = new Point3D(0, 0, 0);

                RectangleVisual3D r = new RectangleVisual3D();
                //r.LengthDirection = new Vector3D(0, 1, 0);
                if (d != null)
                {
                    r.Normal = new Vector3D(1,0,0);
                    r.LengthDirection = new Vector3D(0,1,0);
                    //startPoint + (endPoint - startPoint) * 0.5;
                    r.Width = (d.Bounds.SizeX* 1.5);
                    r.Length = (d.Bounds.SizeY * 1.5);
                    r.Origin = position;
                }

                var combinedM = new CombinedManipulator();
                combinedM.Position = position;
                combinedM.Offset = new Vector3D(0, 0, 0);
                combinedM.Diameter = r.Length/2;
                combinedM.Bind(r);

                view1.Children.Add(combinedM);
                view1.Children.Add(r);

                cutLineBool = false;
            }

        }