コード例 #1
0
        public override void OnMouseUp(MouseEventArgs mouseEvent)
        {
            Invalidate();

            if (SuppressUiVolumes)
            {
                return;
            }

            Ray              ray = this.World.GetRayForLocalBounds(mouseEvent.Position);
            IntersectInfo    info;
            bool             anyInteractionVolumeHit = FindInteractionVolumeHit(ray, out InteractionVolume iaVolume, out info);
            MouseEvent3DArgs mouseEvent3D            = new MouseEvent3DArgs(mouseEvent, ray, info);

            if (MouseDownOnInteractionVolume && mouseDownIAVolume != null)
            {
                mouseDownIAVolume.OnMouseUp(mouseEvent3D);
                SelectedInteractionVolume = null;

                mouseDownIAVolume = null;
            }
            else
            {
                mouseDownIAVolume = null;

                if (anyInteractionVolumeHit)
                {
                    iaVolume.OnMouseUp(mouseEvent3D);
                }
                SelectedInteractionVolume = null;
            }

            base.OnMouseUp(mouseEvent);
        }
コード例 #2
0
 private void Awake()
 {
     interactionVolume = gameObject.transform.Find("Interaction Volume").GetComponent <InteractionVolume>();
     Client            = GameObject.Find("Network").GetComponent <UnityClient>();
     Assert.IsNotNull(interactionVolume);
     objManager = GameObject.Find("Network").GetComponent <NetworkObjectManager>();
 }
コード例 #3
0
        private bool FindInteractionVolumeHit(Ray ray, out InteractionVolume hitIAVolume, out IntersectInfo info)
        {
            var iaVolumes = this.InteractionVolumes;

            hitIAVolume = null;

            if (!iaVolumes.Any())
            {
                info = null;
                return(false);
            }

            // TODO: Rewrite as projection without extra list
            // - Looks like the extra list is always required as CreateNewHierachy requires a List and we can only produce an IEnumerable without the list overhead
            // - var uiTraceables = iaVolumes.Where(ia => ia.CollisionVolume != null).Select(ia => new Transform(ia.CollisionVolume, ia.TotalTransform)).ToList<IPrimitive>();
            var uiTraceables = new List <IPrimitive>();

            foreach (var interactionVolume in iaVolumes.OfType <InteractionVolume>())
            {
                if (interactionVolume.CollisionVolume != null)
                {
                    IPrimitive traceData = interactionVolume.CollisionVolume;
                    uiTraceables.Add(new Transform(traceData, interactionVolume.TotalTransform));
                }
            }

            if (uiTraceables.Count <= 0)
            {
                info = null;
                return(false);
            }

            IPrimitive allUiObjects = BoundingVolumeHierarchy.CreateNewHierachy(uiTraceables);

            info = allUiObjects.GetClosestIntersection(ray);
            if (info != null)
            {
                foreach (var iaVolume in iaVolumes.OfType <InteractionVolume>())
                {
                    var insideBounds = new List <IBvhItem>();
                    if (iaVolume.CollisionVolume != null)
                    {
                        iaVolume.CollisionVolume.GetContained(insideBounds, info.closestHitObject.GetAxisAlignedBoundingBox());
                        if (insideBounds.Contains(info.closestHitObject))
                        {
                            hitIAVolume = iaVolume;
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #4
0
        private void MeshViewerToDrawWith_Draw(object drawingWidget, DrawEventArgs drawEvent)
        {
            if (Visible)
            {
                if (drawEvent != null)
                {
                    Vector2 startLineGroundPos    = Vector2.Zero;
                    Vector2 startLineSelectionPos = Vector2.Zero;
                    Vector2 midLinePos            = Vector2.Zero;

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

                        Vector2   screenPosition = new Vector2(-100, 0);
                        Vector3[] bottomPoints   = new Vector3[4];
                        bottomPoints[0] = new Vector3(selectedBounds.minXYZ.x, selectedBounds.minXYZ.y, selectedBounds.minXYZ.z);
                        bottomPoints[1] = new Vector3(selectedBounds.minXYZ.x, selectedBounds.maxXYZ.y, selectedBounds.minXYZ.z);
                        bottomPoints[2] = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.minXYZ.y, selectedBounds.minXYZ.z);
                        bottomPoints[3] = new Vector3(selectedBounds.maxXYZ.x, selectedBounds.maxXYZ.y, selectedBounds.minXYZ.z);

                        for (int i = 0; i < 4; i++)
                        {
                            Vector2 testScreenPosition = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(bottomPoints[i]);
                            if (testScreenPosition.x > screenPosition.x)
                            {
                                startLineSelectionPos = testScreenPosition;
                                startLineGroundPos    = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(bottomPoints[i] + new Vector3(0, 0, -bottomPoints[i].z));
                                midLinePos            = MeshViewerToDrawWith.TrackballTumbleWidget.GetScreenPosition(bottomPoints[i] + new Vector3(0, 0, -bottomPoints[i].z / 2));
                                screenPosition        = testScreenPosition + new Vector2(HorizontalLineLength, 0);
                            }
                        }
                        heightValueDisplayInfo.DisplaySizeInfo(drawEvent.graphics2D, midLinePos, selectedBounds.minXYZ.z);


                        OriginRelativeParent = screenPosition;

                        // draw the line that is on the ground
                        double yGround = Math.Round(startLineGroundPos.y) + .5;
                        drawEvent.graphics2D.Line(startLineGroundPos.x, yGround, startLineGroundPos.x + HorizontalLineLength - 5, yGround, RGBA_Bytes.Black);
                        // and the line that is at the base of the selection
                        double ySelection = Math.Round(startLineSelectionPos.y) + .5;
                        drawEvent.graphics2D.Line(startLineSelectionPos.x, ySelection, startLineSelectionPos.x + HorizontalLineLength - 5, ySelection, RGBA_Bytes.Black);

                        // draw the vertical line that shows the measurement
                        Vector2 pointerBottom = new Vector2(startLineGroundPos.x + HorizontalLineLength / 2, yGround);
                        Vector2 pointerTop    = new Vector2(startLineSelectionPos.x + HorizontalLineLength / 2, ySelection);

                        InteractionVolume.DrawMeasureLine(drawEvent.graphics2D, pointerBottom, pointerTop, RGBA_Bytes.Black, InteractionVolume.LineArrows.End);
                    }
                }
            }
        }
コード例 #5
0
        private void MeshViewerToDrawWith_Draw(GuiWidget drawingWidget, DrawEventArgs drawEvent)
        {
            if (Visible)
            {
                if (drawEvent != null)
                {
                    // draw the line that is on the ground
                    double yGround = (int)(startLineGroundPos.y + .5) + .5;
                    drawEvent.graphics2D.Line(startLineGroundPos.x, yGround, startLineGroundPos.x + HorizontalLineLength - 5, yGround, RGBA_Bytes.Black);
                    // and the line that is at the base of the selection
                    double ySelection = (int)(startLineSelectionPos.y + .5) + .5;
                    drawEvent.graphics2D.Line(startLineSelectionPos.x, ySelection, startLineSelectionPos.x + HorizontalLineLength - 5, ySelection, RGBA_Bytes.Black);

                    // draw the verticle line that shows the measurment
                    Vector2 pointerBottom = new Vector2(startLineGroundPos.x + HorizontalLineLength / 2, yGround);
                    Vector2 pointerTop    = new Vector2(startLineSelectionPos.x + HorizontalLineLength / 2, ySelection);

                    InteractionVolume.DrawMeasureLine(drawEvent.graphics2D, pointerBottom, pointerTop, RGBA_Bytes.Black, InteractionVolume.LineArrows.End);
                }
            }
        }
コード例 #6
0
 public void RegisterIAVolume(InteractionVolume interactionVolume)
 {
     registeredIAVolumes.Add(interactionVolume);
 }