Пример #1
0
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bLeftTriggerReleased || input.bAButtonReleased)
     {
         SORayHit rayHit;
         if (selectSO != null && selectSO.FindRayIntersection(input.vGamepadWorldRay, out rayHit))
         {
             if (input.bAButtonDown)
             {
                 if (scene.Scene.IsSelected(selectSO))
                 {
                     scene.Scene.Deselect(selectSO);
                 }
                 else
                 {
                     scene.Scene.Select(selectSO, false);
                 }
             }
             else
             {
                 scene.Scene.Select(selectSO, true);
             }
         }
         selectSO = null;
         return(Capture.End);
     }
     else
     {
         return(Capture.Continue);
     }
 }
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bLeftMouseReleased)
     {
         SORayHit rayHit;
         if (selectSO != null && selectSO.FindRayIntersection(input.vMouseWorldRay, out rayHit))
         {
             if ((EnableShiftModifier && input.bShiftKeyDown) ||
                 (EnableControlModifier && input.bCtrlKeyDown))
             {
                 if (scene.Scene.IsSelected(selectSO))
                 {
                     scene.Scene.Deselect(selectSO);
                 }
                 else
                 {
                     scene.Scene.Select(selectSO, false);
                 }
             }
             else
             {
                 scene.Scene.Select(selectSO, true);
             }
         }
         selectSO = null;
         return(Capture.End);
     }
     else
     {
         return(Capture.Continue);
     }
 }
Пример #3
0
        public void BeginDraw_Ray(Ray3f ray)
        {
            CreateNewCurve();

            SORayHit hit;
            bool     bHit = target.FindRayIntersection(ray, out hit);

            if (!bHit)
            {
                throw new Exception("DrawSurfaceCurveTool.BeginDraw_Ray: how did we get here if no target hit???");
            }

            float    offset = SurfaceOffset * scene.GetSceneScale();
            Vector3f vHit   = hit.hitPos + offset * hit.hitNormal;
            float    fScale = scene.GetSceneScale();

            smooth_append(preview,
                          scene.SceneFrame.ToFrameP(vHit) / fScale, dist_thresh(SamplingRate, fScale));
        }
Пример #4
0
        public virtual void BeginDraw_Ray_Continuous(Ray3f ray)
        {
            CreateNewCurve();
            in_draw = true;

            SORayHit hit;
            bool     bHit = target.FindRayIntersection(ray, out hit);

            if (!bHit)
            {
                throw new Exception("DrawSurfaceCurveTool.BeginDraw_Ray: how did we get here if no target hit???");
            }

            float    offset = Scene.ToWorldDimension(SurfaceOffsetScene);
            Vector3f vHit   = hit.hitPos + offset * hit.hitNormal;
            float    fScale = Scene.GetSceneScale();

            smooth_append(preview, Scene.ToSceneP(vHit), dist_thresh(SamplingRateScene, fScale));
        }
Пример #5
0
        public virtual bool RayIntersect(Ray3d ray, out Vector3d vHit, out Vector3d vHitNormal)
        {
            vHit = vHitNormal = Vector3d.Zero;
            SORayHit hit;

            if (Target.FindRayIntersection((Ray3f)ray, out hit))
            {
                vHit       = hit.hitPos;
                vHitNormal = hit.hitNormal;
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// called on click-down
        /// </summary>
        override public void Begin(SceneObject so, Vector2d downPos, Ray3f downRay)
        {
            SORayHit hit;

            if (TargetSO.FindRayIntersection(downRay, out hit) == false)
            {
                return;
            }

            Vector3d scenePos = SceneTransforms.WorldToSceneP(this.Scene, hit.hitPos);

            CurrentHitPosS = new Frame3f(scenePos);

            float fObjectT = (CurrentHitPosS.Origin - ObjectFrameS.Origin).Dot(ObjectFrameS.Y);

            CurrentPlaneFrameS = ObjectFrameS.Translated(fObjectT, 1);

            if (have_set_plane == false)
            {
                sphereIndicator = IndicatorBuilder.MakeSphereIndicator(0, "hit_point",
                                                                       fDimension.Scene(sphere_indicator_size * 0.5),
                                                                       () => { return(CurrentHitPosS); },
                                                                       () => { return(Colorf.Orange); },
                                                                       () => { return(true); });
                Indicators.AddIndicator(sphereIndicator);
                sphereIndicator.RootGameObject.SetName("hit_point");

                planeIndicator = IndicatorBuilder.MakeSectionPlaneIndicator(1, "section_plane",
                                                                            fDimension.Scene(plane_indicator_width),
                                                                            () => { return(CurrentPlaneFrameS); },
                                                                            () => { return(new Colorf(Colorf.LightGreen, 0.5f)); },
                                                                            () => { return(true); });
                Indicators.AddIndicator(planeIndicator);
                planeIndicator.RootGameObject.SetName("section_plane");

                have_set_plane = true;
            }
        }
Пример #7
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            // [RMS] this is a hack to release input for shoulder+trigger gestures
            if ((data.which == CaptureSide.Left && input.bLeftShoulderPressed) ||
                (data.which == CaptureSide.Right && input.bRightShoulderPressed))
            {
                return(Capture.End);
            }

            if ((data.which == CaptureSide.Left && input.bLeftTriggerReleased) ||
                (data.which == CaptureSide.Right && input.bRightTriggerReleased))
            {
                Ray3f       useRay = (data.which == CaptureSide.Left) ? input.vLeftSpatialWorldRay : input.vRightSpatialWorldRay;
                SceneObject so     = data.custom_data as SceneObject;
                SORayHit    rayHit;
                if (so != null && so.FindRayIntersection(useRay, out rayHit))
                {
                    // if other trigger is down we do multi-select add/remove toggling
                    bool bOtherDown =
                        (data.which == CaptureSide.Left && input.bRightTriggerDown) ||
                        (data.which == CaptureSide.Right && input.bLeftTriggerDown);
                    if (bOtherDown)
                    {
                        if (scene.Scene.IsSelected(so))
                        {
                            scene.Scene.Deselect(so);
                        }
                        else
                        {
                            scene.Scene.Select(so, false);
                        }
                    }
                    else
                    {
                        scene.Scene.Select(so, true);
                    }
                }
                return(Capture.End);
            }
            else
            {
                return(Capture.Continue);
            }
        }
Пример #8
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            BaseSurfacePointTool tool =
                (context.ToolManager.ActiveRightTool as BaseSurfacePointTool);

            if (Released(input))
            {
                tool.End();
                return(Capture.End);
            }
            else
            {
                SORayHit rayHit;
                bool     bHit = targetSO.FindRayIntersection(WorldRay(input), out rayHit);
                if (bHit)
                {
                    tool.Update(ClickPoint(input), WorldRay(input));
                }
                return(Capture.Continue);
            }
        }
Пример #9
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            BaseSurfacePointTool tool = context.ToolManager.GetActiveTool((int)data.which) as BaseSurfacePointTool;
            Ray3f worldRay            = (data.which == CaptureSide.Left) ? input.vLeftSpatialWorldRay : input.vRightSpatialWorldRay;
            bool  bReleased           = (data.which == CaptureSide.Left) ? input.bLeftTriggerReleased : input.bRightTriggerReleased;

            if (bReleased)
            {
                tool.End();
                return(Capture.End);
            }
            else
            {
                SORayHit rayHit;
                bool     bHit = targetSO.FindRayIntersection(worldRay, out rayHit);
                if (bHit)
                {
                    tool.Update(Vector2d.Zero, worldRay);
                }
                return(Capture.Continue);
            }
        }
Пример #10
0
        /// <summary>
        /// called each frame as cursor moves
        /// </summary>
        virtual public void Update(Ray3f downRay)
        {
            if (active_surface_point == -1)
            {
                return;
            }
            ControlPoint pt;

            if (GizmoPoints.TryGetValue(active_surface_point, out pt) == false)
            {
                active_surface_point = -1;
                return;
            }

            if (pt is SurfacePoint)
            {
                SORayHit hit;
                if (TargetSO.FindRayIntersection(downRay, out hit))
                {
                    Frame3f hitFrameW = new Frame3f(hit.hitPos, hit.hitNormal);
                    Frame3f hitFrameS = this.Scene.ToSceneFrame(hitFrameW);
                    SetPointPosition(active_surface_point, hitFrameS, CoordSpace.SceneCoords);
                }
            }
            else if (pt is TargetPoint)
            {
                TargetPoint targetPt = pt as TargetPoint;
                Vector3d    hitS, hitNormal;
                Ray3d       sceneRay = (Ray3d)Scene.ToSceneRay(downRay);
                if (targetPt.RayTarget.RayIntersect(sceneRay, out hitS, out hitNormal))
                {
                    Frame3f hitFrameS = new Frame3f(hitS, hitNormal);
                    SetPointPosition(active_surface_point, hitFrameS, CoordSpace.SceneCoords);
                }
            }
        }