示例#1
0
        public override void SetPosition()
        {
            AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();
            Vector3 boundsCenter = selectedBounds.Center;
            Vector3 centerTop    = new Vector3(boundsCenter.x, boundsCenter.y, selectedBounds.maxXYZ.z);

            Vector2 centerTopScreenPosition = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(centerTop);

            double distBetweenPixelsWorldSpace = MeshViewerToDrawWith.TrackballTumbleWidget.GetWorldUnitsPerScreenPixelAtPosition(centerTop);

            Matrix4X4 arrowTransform = Matrix4X4.CreateTranslation(new Vector3(centerTop.x, centerTop.y, centerTop.z + 20 * distBetweenPixelsWorldSpace));

            arrowTransform = Matrix4X4.CreateScale(distBetweenPixelsWorldSpace) * arrowTransform;

            TotalTransform = arrowTransform;

            if (MouseOver || MouseDownOnControl)
            {
                heightDisplay.Visible = true;
            }
            else if (!view3DWidget.DisplayAllValueData)
            {
                heightDisplay.Visible = false;
            }
        }
示例#2
0
        public override void OnMouseMove(MouseEvent3DArgs mouseEvent3D)
        {
            IntersectInfo info = hitPlane.GetClosestIntersection(mouseEvent3D.MouseRay);

            if (info != null && MeshViewerToDrawWith.SelectedMeshGroupIndex != -1)
            {
                Vector3 delta = new Vector3(0, 0, info.hitPosition.z - zHitHeight);

                // move it back to where it started
                MeshViewerToDrawWith.SelectedMeshGroupTransform *= Matrix4X4.CreateTranslation(new Vector3(-lastMoveDelta));

                if (MeshViewerToDrawWith.SnapGridDistance > 0)
                {
                    // snap this position to the grid
                    double snapGridDistance = MeshViewerToDrawWith.SnapGridDistance;
                    AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();

                    // snap the z position
                    double bottom        = selectedBounds.minXYZ.z + delta.z;
                    double snappedBottom = (Math.Round((bottom / snapGridDistance))) * snapGridDistance;
                    delta.z = snappedBottom - selectedBounds.minXYZ.z;
                }

                // and move it from there to where we are now
                MeshViewerToDrawWith.SelectedMeshGroupTransform *= Matrix4X4.CreateTranslation(new Vector3(delta));

                lastMoveDelta = delta;

                view3DWidget.PartHasBeenChanged();
                Invalidate();
            }

            base.OnMouseMove(mouseEvent3D);
        }
示例#3
0
        public override void SetPosition()
        {
            AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();
            Vector3 boundsCenter = selectedBounds.Center;

            TotalTransform = Matrix4X4.CreateTranslation(new Vector3(boundsCenter.x, boundsCenter.y, 0.1));
        }
示例#4
0
        public override void DrawGlContent(EventArgs e)
        {
            if (MeshViewerToDrawWith.SelectedMeshGroup != null)
            {
                // draw the bounds on the bed
                AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();

                Mesh bottomBounds = PlatonicSolids.CreateCube(selectedBounds.XSize, selectedBounds.YSize, .1);
                RenderMeshToGl.Render(bottomBounds, new RGBA_Bytes(22, 80, 220, 30), TotalTransform, RenderTypes.Shaded);
            }

            base.DrawGlContent(e);
        }
示例#5
0
        public override void DrawGlContent(EventArgs e)
        {
            if (MeshViewerToDrawWith.SelectedMeshGroup != null)
            {
                if (MouseOver)
                {
                    RenderMeshToGl.Render(upArrow, RGBA_Bytes.Red, TotalTransform, RenderTypes.Shaded);

                    // draw the hight from the bottom to the bed
                    AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();

                    Vector3 bottomRight = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.maxXYZ.y, selectedBounds.minXYZ.z);
                    Vector2 bottomRightScreenPosition = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(bottomRight);
                }
                else
                {
                    RenderMeshToGl.Render(upArrow, RGBA_Bytes.Black, TotalTransform, RenderTypes.Shaded);
                }
            }

            base.DrawGlContent(e);
        }
        public override void SetPosition()
        {
            if (MeshViewerToDrawWith.HaveSelection)
            {
                // draw the hight from the bottom to the bed
                AxisAlignedBoundingBox selectedBounds = MeshViewerToDrawWith.GetBoundsForSelection();

                MeshSelectInfo meshSelectInfo = view3DWidget.CurrentSelectInfo;

                switch (meshSelectInfo.HitQuadrant)
                {
                case HitQuadrant.LB:
                {
                    Vector3 cornerPoint = new Vector3(selectedBounds.minXYZ.x, selectedBounds.minXYZ.y, 0);
                    double  distBetweenPixelsWorldSpace = MeshViewerToDrawWith.TrackballTumbleWidget.GetWorldUnitsPerScreenPixelAtPosition(cornerPoint);

                    lines[0] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0));
                    lines[1] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3((distToStart + lineLength) * distBetweenPixelsWorldSpace, 0, 0));

                    lines[2] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(0, distToStart * distBetweenPixelsWorldSpace, 0));
                    lines[3] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(0, (distToStart + lineLength) * distBetweenPixelsWorldSpace, 0));
                }
                break;

                case HitQuadrant.LT:
                {
                    Vector3 cornerPoint = new Vector3(selectedBounds.minXYZ.x, selectedBounds.maxXYZ.y, 0);
                    double  distBetweenPixelsWorldSpace = MeshViewerToDrawWith.TrackballTumbleWidget.GetWorldUnitsPerScreenPixelAtPosition(cornerPoint);

                    lines[0] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0));
                    lines[1] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3((distToStart + lineLength) * distBetweenPixelsWorldSpace, 0, 0));

                    lines[2] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(0, distToStart * distBetweenPixelsWorldSpace, 0));
                    lines[3] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(0, (distToStart + lineLength) * distBetweenPixelsWorldSpace, 0));
                }
                break;

                case HitQuadrant.RB:
                {
                    Vector3 cornerPoint = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.minXYZ.y, 0);
                    double  distBetweenPixelsWorldSpace = MeshViewerToDrawWith.TrackballTumbleWidget.GetWorldUnitsPerScreenPixelAtPosition(cornerPoint);

                    lines[0] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0));
                    lines[1] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3((distToStart + lineLength) * distBetweenPixelsWorldSpace, 0, 0));

                    lines[2] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(0, distToStart * distBetweenPixelsWorldSpace, 0));
                    lines[3] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint - new Vector3(0, (distToStart + lineLength) * distBetweenPixelsWorldSpace, 0));
                }
                break;

                case HitQuadrant.RT:
                {
                    Vector3 cornerPoint = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.maxXYZ.y, 0);
                    double  distBetweenPixelsWorldSpace = MeshViewerToDrawWith.TrackballTumbleWidget.GetWorldUnitsPerScreenPixelAtPosition(cornerPoint);

                    lines[0] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(distToStart * distBetweenPixelsWorldSpace, 0, 0));
                    lines[1] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3((distToStart + lineLength) * distBetweenPixelsWorldSpace, 0, 0));

                    lines[2] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(0, distToStart * distBetweenPixelsWorldSpace, 0));
                    lines[3] = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(cornerPoint + new Vector3(0, (distToStart + lineLength) * distBetweenPixelsWorldSpace, 0));
                }
                break;
                }
            }
        }