Beispiel #1
0
        public void UpdateControl(SceneViewSelectedScaleAxisType selectedMoveTranslationAxis, bool selectedModelChanged)
        {
            if (selectedMoveTranslationAxis != SceneViewSelectedScaleAxisType.Hidden)
            {
                if (selectedMoveTranslationAxis != SelectedScaleAxis || this.Triangles == null || this.Triangles.Count == 0 || selectedModelChanged)
                {
                    this.SelectedScaleAxis = selectedMoveTranslationAxis;

                    var selectedModel = ObjectView.SelectedModel;
                    if (selectedModel != null && !(selectedModel is SupportCone))
                    {
                        var stlModel        = selectedModel;
                        var scaleAxisXColor = new Byte4Class(240, 255, 0, 0);
                        if (this.SelectedScaleAxis == SceneViewSelectedScaleAxisType.X)
                        {
                            scaleAxisXColor = new Byte4Class(240, 255, 255, 255);
                        }
                        var centerLeftSide = new Vector3((stlModel.LeftPoint - stlModel.RightPoint) / 2, stlModel.Center.Y, 0);
                        var leftSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight - centerLeftSide.X, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Red);
                        leftSideCone.Rotate(0, -90, 0, RotationEventArgs.TypeAxis.Y, true);
                        foreach (var triangle in leftSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisXColor;
                        }

                        var centerRightSide = new Vector3((stlModel.RightPoint - stlModel.LeftPoint) / 2, stlModel.Center.Y, 0);
                        var rightSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerRightSide.X, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Red);
                        rightSideCone.Rotate(0, 90, 0, Events.RotationEventArgs.TypeAxis.Y, true);
                        foreach (var triangle in rightSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisXColor;
                        }

                        //front back
                        var scaleAxisYColor = new Byte4Class(241, 0, 255, 0);
                        if (this.SelectedScaleAxis == SceneViewSelectedScaleAxisType.Y)
                        {
                            scaleAxisYColor = new Byte4Class(241, 255, 255, 0);
                        }
                        var centerFrontSide = new Vector3(stlModel.Center.X, (stlModel.FrontPoint - stlModel.BackPoint) / 2, 0);
                        var frontSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerFrontSide.Y, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Green);
                        frontSideCone.Rotate(90, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                        foreach (var triangle in frontSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisYColor;
                        }

                        var centerBackSide = new Vector3Class(stlModel.Center.X, (stlModel.FrontPoint - stlModel.BackPoint) / 2, 0);
                        var backSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerBackSide.Y, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Green);
                        backSideCone.Rotate(-90, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                        foreach (var triangle in backSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisYColor;
                        }

                        //top bottom
                        var scaleAxisZColor = new Byte4Class(242, 255, 0, 0);
                        if (this.SelectedScaleAxis == SceneViewSelectedScaleAxisType.Z)
                        {
                            scaleAxisZColor = new Byte4Class(242, 255, 255, 255);
                        }
                        var centerTopSide = new Vector3Class(stlModel.Center.X, stlModel.Center.Y, 0);
                        var topSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + ((stlModel.TopPoint - stlModel.BottomPoint) / 2), AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, centerTopSide, Color.Blue);
                        foreach (var triangle in topSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisZColor;
                        }

                        var centerBottomSide = new Vector3Class(stlModel.Center.X, stlModel.Center.Y, 0);
                        var bottomSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + ((stlModel.TopPoint - stlModel.BottomPoint) / 2), AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, centerBottomSide, Color.Blue);
                        bottomSideCone.Rotate(180, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                        foreach (var triangle in bottomSideCone.Triangles[0])
                        {
                            triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = scaleAxisZColor;
                        }

                        //initialize triangle array
                        this.Triangles = new TriangleInfoList();
                        this.Triangles[0].AddRange(leftSideCone.Triangles[0]);
                        this.Triangles[0].AddRange(rightSideCone.Triangles[0]);
                        this.Triangles[0].AddRange(frontSideCone.Triangles[0]);
                        this.Triangles[0].AddRange(backSideCone.Triangles[0]);
                        this.Triangles[0].AddRange(topSideCone.Triangles[0]);
                        this.Triangles[0].AddRange(bottomSideCone.Triangles[0]);

                        //change all triangles center to center of model
                        if (stlModel.PreviewMoveTranslation.X != 0 || stlModel.PreviewMoveTranslation.Y != 0)
                        {
                            this.MoveTranslation = stlModel.PreviewMoveTranslation + new Vector3Class(0, 0, (stlModel.TopPoint - stlModel.BottomPoint) / 2);
                        }
                        else
                        {
                            this.MoveTranslation = stlModel.MoveTranslation + new Vector3Class(0, 0, (stlModel.TopPoint - stlModel.BottomPoint) / 2);
                        }
                    }
                }
            }
            else
            {
                this.Triangles = new TriangleInfoList();
            }


            if (this.VBOIndexes == null && ObjectView.SelectedModel != null)
            {
                this.BindModel();
            }
            else
            {
                this.UpdateBinding();
            }
        }
Beispiel #2
0
        public void UpdateControl(SceneViewSelectedMoveTranslationAxisType selectedMoveTranslationAxis, bool selectedModelChanged)
        {
            if (selectedMoveTranslationAxis != SceneViewSelectedMoveTranslationAxisType.Hidden)
            {
                if (selectedMoveTranslationAxis != SelectedMoveTranslationAxis || this.Triangles == null || this.Triangles.Count == 0 || selectedModelChanged || this.SelectedObject.LinkedClones.Count > 1)
                {
                    this.SelectedMoveTranslationAxis = selectedMoveTranslationAxis;
                    this.SelectedObject = (STLModel3D)ObjectView.SelectedModel;

                    if (SelectedObject != null)
                    {
                        if (SceneView.CurrentViewMode == SceneView.ViewMode.ModelRotation && this.SelectedObject.LinkedClones.Count > 1)
                        {
                            this.Hidden = true;
                            SceneControlToolbarManager.ShowRotationSelectedModelContainsLinkedClonesToolTip();
                        }
                        else
                        {
                            LinkedClone selectedLinkedClone = null;
                            for (var i = 0; i < SelectedObject.LinkedClones.Count; i++)
                            {
                                if (SelectedObject.LinkedClones[i].Selected)
                                {
                                    selectedLinkedClone = SelectedObject.LinkedClones[i];
                                    break;
                                }
                            }

                            var stlModel = SelectedObject;
                            var moveTranslationAxisXColor = new Byte4Class(240, 255, 0, 0);
                            if (this.SelectedMoveTranslationAxis == SceneViewSelectedMoveTranslationAxisType.X)
                            {
                                moveTranslationAxisXColor = new Byte4Class(240, 255, 255, 255);
                            }
                            var centerLeftSide = new Vector3((stlModel.LeftPoint - stlModel.RightPoint) / 2, stlModel.Center.Y, 0);
                            var leftSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight - centerLeftSide.X, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Red);
                            leftSideCone.Rotate(0, -90, 0, Events.RotationEventArgs.TypeAxis.Y, true);
                            foreach (var triangle in leftSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisXColor;
                            }

                            var centerRightSide = new Vector3((stlModel.RightPoint - stlModel.LeftPoint) / 2, stlModel.Center.Y, 0);
                            var rightSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerRightSide.X, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Red);
                            rightSideCone.Rotate(0, 90, 0, Events.RotationEventArgs.TypeAxis.Y, true);
                            foreach (var triangle in rightSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisXColor;
                            }

                            //front back
                            var moveTranslationAxisYColor = new Byte4Class(241, 0, 255, 0);
                            if (this.SelectedMoveTranslationAxis == SceneViewSelectedMoveTranslationAxisType.Y)
                            {
                                moveTranslationAxisYColor = new Byte4Class(241, 255, 255, 255);
                            }
                            var centerFrontSide = new Vector3(stlModel.Center.X, (stlModel.FrontPoint - stlModel.BackPoint) / 2, 0);
                            var frontSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerFrontSide.Y, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Green);
                            frontSideCone.Rotate(90, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                            foreach (var triangle in frontSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisYColor;
                            }

                            var centerBackSide = new Vector3(stlModel.Center.X, (stlModel.FrontPoint - stlModel.BackPoint) / 2, 0);
                            var backSideCone   = new SceneMoveTranslationGizmoCone(AxisConeHeight + centerBackSide.Y, AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Green);
                            backSideCone.Rotate(-90, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                            foreach (var triangle in backSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisYColor;
                            }

                            //top bottom
                            var moveTranslationAxisZColor = new Byte4Class(242, 0, 0, 255);
                            if (this.SelectedMoveTranslationAxis == SceneViewSelectedMoveTranslationAxisType.Z)
                            {
                                moveTranslationAxisZColor = new Byte4Class(242, 255, 255, 255);
                            }
                            var topSideCone = new SceneMoveTranslationGizmoCone(AxisConeHeight + ((stlModel.TopPoint - stlModel.BottomPoint) / 2), AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Blue);
                            foreach (var triangle in topSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisZColor;
                            }

                            var bottomSideCone = new SceneMoveTranslationGizmoCone(AxisConeHeight + ((stlModel.TopPoint - stlModel.BottomPoint) / 2), AxisConeTopHeight, AxisConeTopRadius, AxisConeMiddleRadius, 10, new Vector3Class(), Color.Blue);
                            bottomSideCone.Rotate(180, 0, 0, Events.RotationEventArgs.TypeAxis.X, true);
                            foreach (var triangle in bottomSideCone.Triangles[0])
                            {
                                triangle.Vectors[0].Color = triangle.Vectors[1].Color = triangle.Vectors[2].Color = moveTranslationAxisZColor;
                            }

                            //initialize triangle array
                            this.Triangles = new TriangleInfoList();
                            this.Triangles[0].AddRange(leftSideCone.Triangles[0]);
                            this.Triangles[0].AddRange(rightSideCone.Triangles[0]);
                            this.Triangles[0].AddRange(frontSideCone.Triangles[0]);
                            this.Triangles[0].AddRange(backSideCone.Triangles[0]);

                            if (SelectedObject != null && SelectedObject is SupportCone)
                            {
                                var selectedSupportCone = SelectedObject as SupportCone;
                                var moveTranslation     = new Vector3Class(selectedSupportCone.Center.X, selectedSupportCone.Center.Y, 0);
                                foreach (var triangle in this.Triangles[0])
                                {
                                    triangle.Vectors[0].Position += moveTranslation;
                                    triangle.Vectors[1].Position += moveTranslation;
                                    triangle.Vectors[2].Position += moveTranslation;
                                }

                                this.MoveTranslation = selectedSupportCone.MoveTranslation + new Vector3Class(selectedSupportCone.Model.MoveTranslation.X, selectedSupportCone.Model.MoveTranslation.Y, ((selectedSupportCone.TopPoint - selectedSupportCone.BottomPoint) / 2) + selectedSupportCone.BottomPoint);
                            }
                            else if (selectedLinkedClone != null)
                            {
                                this.Triangles[0].AddRange(topSideCone.Triangles[0]);
                                this.Triangles[0].AddRange(bottomSideCone.Triangles[0]);

                                this.MoveTranslation = selectedLinkedClone.Translation + new Vector3Class(0, 0, ((stlModel.TopPoint - stlModel.BottomPoint) / 2) + stlModel.BottomPoint);
                            }
                            else
                            {
                                this.Triangles[0].AddRange(topSideCone.Triangles[0]);
                                this.Triangles[0].AddRange(bottomSideCone.Triangles[0]);

                                //change all triangles center to center of model
                                if (stlModel.PreviewMoveTranslation.X != 0 || stlModel.PreviewMoveTranslation.Y != 0)
                                {
                                    this.MoveTranslation = stlModel.PreviewMoveTranslation + new Vector3Class(0, 0, (stlModel.TopPoint - stlModel.BottomPoint) / 2);
                                }
                                else
                                {
                                    this.MoveTranslation = stlModel.MoveTranslation + new Vector3Class(0, 0, (stlModel.TopPoint - stlModel.BottomPoint) / 2);
                                }
                            }

                            this.PreviousSelectedObject = SelectedObject;
                        }
                    }
                }
            }
            else
            {
                this.Triangles = new TriangleInfoList();
            }


            if (this.VBOIndexes == null && ObjectView.SelectedModel != null)
            {
                this.BindModel();
            }
            else
            {
                this.UpdateBinding();
            }
        }